From 13755122f2c3193d6e630970ab3ec38dabe36f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Fri, 22 May 2015 23:31:18 +0200 Subject: [PATCH] Move symbols_get_context_separator() implementation to TM This way we can use it inside TM. --- src/symbols.c | 26 +------------------------- tagmanager/src/tm_tag.c | 30 ++++++++++++++++++++++++++++++ tagmanager/src/tm_tag.h | 2 ++ tagmanager/src/tm_workspace.c | 5 +---- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/symbols.c b/src/symbols.c index c21c3b25..7b817240 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -322,31 +322,7 @@ GString *symbols_find_typenames_as_string(gint lang, gboolean global) GEANY_API_SYMBOL const gchar *symbols_get_context_separator(gint ft_id) { - switch (ft_id) - { - case GEANY_FILETYPES_C: /* for C++ .h headers or C structs */ - case GEANY_FILETYPES_CPP: - case GEANY_FILETYPES_GLSL: /* for structs */ - /*case GEANY_FILETYPES_RUBY:*/ /* not sure what to use atm*/ - case GEANY_FILETYPES_PHP: - case GEANY_FILETYPES_POWERSHELL: - case GEANY_FILETYPES_RUST: - case GEANY_FILETYPES_ZEPHIR: - return "::"; - - /* avoid confusion with other possible separators in group/section name */ - case GEANY_FILETYPES_CONF: - case GEANY_FILETYPES_REST: - return ":::"; - - /* no context separator */ - case GEANY_FILETYPES_ASCIIDOC: - case GEANY_FILETYPES_TXT2TAGS: - return "\x03"; - - default: - return "."; - } + return tm_tag_context_separator(filetypes[ft_id]->lang); } diff --git a/tagmanager/src/tm_tag.c b/tagmanager/src/tm_tag.c index 778d052a..3819afa9 100644 --- a/tagmanager/src/tm_tag.c +++ b/tagmanager/src/tm_tag.c @@ -17,6 +17,7 @@ #include "read.h" #define LIBCTAGS_DEFINED #include "tm_tag.h" +#include "tm_parser.h" #define TAG_NEW(T) ((T) = g_slice_new0(TMTag)) @@ -1167,6 +1168,35 @@ tm_get_current_tag (GPtrArray * file_tags, const gulong line, const TMTagType ta return matching_tag; } +const gchar *tm_tag_context_separator(langType lang) +{ + switch (lang) + { + case TM_PARSER_C: /* for C++ .h headers or C structs */ + case TM_PARSER_CPP: + case TM_PARSER_GLSL: /* for structs */ + /*case GEANY_FILETYPES_RUBY:*/ /* not sure what to use atm*/ + case TM_PARSER_PHP: + case TM_PARSER_POWERSHELL: + case TM_PARSER_RUST: + case TM_PARSER_ZEPHIR: + return "::"; + + /* avoid confusion with other possible separators in group/section name */ + case TM_PARSER_CONF: + case TM_PARSER_REST: + return ":::"; + + /* no context separator */ + case TM_PARSER_ASCIIDOC: + case TM_PARSER_TXT2TAGS: + return "\x03"; + + default: + return "."; + } +} + #if 0 /* Returns TMTag to function or method which "own" given line @param line Current line in edited file. diff --git a/tagmanager/src/tm_tag.h b/tagmanager/src/tm_tag.h index 15f7388e..b339af89 100644 --- a/tagmanager/src/tm_tag.h +++ b/tagmanager/src/tm_tag.h @@ -191,6 +191,8 @@ TMTag *tm_tag_ref(TMTag *tag); gboolean tm_tags_equal(const TMTag *a, const TMTag *b); +const gchar *tm_tag_context_separator(langType lang); + #ifdef TM_DEBUG /* various debugging functions */ const char *tm_tag_type_name(const TMTag *tag); diff --git a/tagmanager/src/tm_workspace.c b/tagmanager/src/tm_workspace.c index 6de172b1..5018ce3b 100644 --- a/tagmanager/src/tm_workspace.c +++ b/tagmanager/src/tm_workspace.c @@ -857,10 +857,7 @@ find_scope_members (const GPtrArray *tags_array, GPtrArray *member_array, { gchar *tmp_name = type_name; - if (tag->file && tag->file->lang == TM_PARSER_JAVA) - type_name = g_strdup_printf("%s.%s", tag->scope, type_name); - else - type_name = g_strdup_printf("%s::%s", tag->scope, type_name); + type_name = g_strconcat(tag->scope, tm_tag_context_separator(lang), type_name, NULL); g_free(tmp_name); } break;