From f35d0b9c0c8f54b75eff4f12bc762cc5ced0d390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Sun, 2 Nov 2014 11:34:44 +0100 Subject: [PATCH] Move tm_get_current_tag() from tm_workspace to tm_tag This function has nothing to do with the workspace so it rather belongs to tm_tag. --- tagmanager/src/tm_tag.c | 41 +++++++++++++++++++++++++++++++++++ tagmanager/src/tm_tag.h | 2 ++ tagmanager/src/tm_workspace.c | 40 ---------------------------------- tagmanager/src/tm_workspace.h | 2 -- 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/tagmanager/src/tm_tag.c b/tagmanager/src/tm_tag.c index ac42aa83d9..3d1ed64ee1 100644 --- a/tagmanager/src/tm_tag.c +++ b/tagmanager/src/tm_tag.c @@ -1126,6 +1126,47 @@ TMTag **tm_tags_find(const GPtrArray *tags_array, const char *name, return (TMTag **) result; } +/* Returns TMTag which "own" given line + @param line Current line in edited file. + @param file_tags A GPtrArray of edited file TMTag pointers. + @param tag_types the tag types to include in the match + @return TMTag pointers to owner tag. */ +const TMTag * +tm_get_current_tag (GPtrArray * file_tags, const gulong line, const TMTagType tag_types) +{ + TMTag *matching_tag = NULL; + if (file_tags && file_tags->len) + { + guint i; + gulong matching_line = 0; + + for (i = 0; (i < file_tags->len); ++i) + { + TMTag *tag = TM_TAG (file_tags->pdata[i]); + if (tag && tag->type & tag_types && + tag->line <= line && tag->line > matching_line) + { + matching_tag = tag; + matching_line = tag->line; + } + } + } + return matching_tag; +} + +#if 0 +/* Returns TMTag to function or method which "own" given line + @param line Current line in edited file. + @param file_tags A GPtrArray of edited file TMTag pointers. + @return TMTag pointers to owner function. */ +static const TMTag * +tm_get_current_function (GPtrArray * file_tags, const gulong line) +{ + return tm_get_current_tag (file_tags, line, tm_tag_function_t | tm_tag_method_t); +} +#endif + + #ifdef TM_DEBUG /* various debugging functions */ /* diff --git a/tagmanager/src/tm_tag.h b/tagmanager/src/tm_tag.h index 7804250495..3d7e73c37e 100644 --- a/tagmanager/src/tm_tag.h +++ b/tagmanager/src/tm_tag.h @@ -183,6 +183,8 @@ TMTag **tm_tags_find(const GPtrArray *tags_array, const char *name, void tm_tags_array_free(GPtrArray *tags_array, gboolean free_all); +const TMTag *tm_get_current_tag(GPtrArray *file_tags, const gulong line, const TMTagType tag_types); + void tm_tag_unref(TMTag *tag); TMTag *tm_tag_ref(TMTag *tag); diff --git a/tagmanager/src/tm_workspace.c b/tagmanager/src/tm_workspace.c index dd1c7521c6..1272d2b713 100644 --- a/tagmanager/src/tm_workspace.c +++ b/tagmanager/src/tm_workspace.c @@ -834,35 +834,6 @@ tm_workspace_find_scoped (const char *name, const char *scope, TMTagType type, } -/* Returns TMTag which "own" given line - @param line Current line in edited file. - @param file_tags A GPtrArray of edited file TMTag pointers. - @param tag_types the tag types to include in the match - @return TMTag pointers to owner tag. */ -const TMTag * -tm_get_current_tag (GPtrArray * file_tags, const gulong line, const TMTagType tag_types) -{ - TMTag *matching_tag = NULL; - if (file_tags && file_tags->len) - { - guint i; - gulong matching_line = 0; - - for (i = 0; (i < file_tags->len); ++i) - { - TMTag *tag = TM_TAG (file_tags->pdata[i]); - if (tag && tag->type & tag_types && - tag->line <= line && tag->line > matching_line) - { - matching_tag = tag; - matching_line = tag->line; - } - } - } - return matching_tag; -} - - static int find_scope_members_tags (const GPtrArray * all, GPtrArray * tags, const langType langJava, const char *name, @@ -1142,17 +1113,6 @@ void tm_workspace_dump(void) #if 0 -/* Returns TMTag to function or method which "own" given line - @param line Current line in edited file. - @param file_tags A GPtrArray of edited file TMTag pointers. - @return TMTag pointers to owner function. */ -static const TMTag * -tm_get_current_function (GPtrArray * file_tags, const gulong line) -{ - return tm_get_current_tag (file_tags, line, tm_tag_function_t | tm_tag_method_t); -} - - static int find_namespace_members_tags (const GPtrArray * all, GPtrArray * tags, const langType langJava, const char *name, diff --git a/tagmanager/src/tm_workspace.h b/tagmanager/src/tm_workspace.h index 92d6cf3b84..4fc36a3e89 100644 --- a/tagmanager/src/tm_workspace.h +++ b/tagmanager/src/tm_workspace.h @@ -68,8 +68,6 @@ const GPtrArray *tm_workspace_find_scope_members(const GPtrArray *file_tags, gboolean find_global, gboolean no_definitions); -const TMTag *tm_get_current_tag(GPtrArray *file_tags, const gulong line, const TMTagType tag_types); - void tm_workspace_update_source_file_buffer(TMSourceFile *source_file, guchar* text_buf, gint buf_size);