Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Mon, 17 Sep 2012 18:07:45 Commit: d83bd409388313503dcad58cb6d601bf92e64fbc https://github.com/geany/geany/commit/d83bd409388313503dcad58cb6d601bf92e64f...
Log Message: ----------- Add tm_get_current_tag()
Modified Paths: -------------- tagmanager/src/tm_workspace.c tagmanager/src/tm_workspace.h
Modified: tagmanager/src/tm_workspace.c 23 files changed, 15 insertions(+), 8 deletions(-) =================================================================== @@ -733,30 +733,37 @@ static gboolean match_langs(gint lang, const TMTag *tag)
const TMTag * -tm_get_current_function (GPtrArray * file_tags, const gulong line) +tm_get_current_tag (GPtrArray * file_tags, const gulong line, const guint tag_types) { - GPtrArray *const local = tm_tags_extract (file_tags, tm_tag_function_t | tm_tag_method_t); - TMTag *function_tag = NULL; + GPtrArray *const local = tm_tags_extract (file_tags, tag_types); + TMTag *matching_tag = NULL; if (local && local->len) { guint i; - gulong function_line = 0; + gulong matching_line = 0; glong delta;
for (i = 0; (i < local->len); ++i) { TMTag *tag = TM_TAG (local->pdata[i]); delta = line - tag->atts.entry.line; - if (delta >= 0 && (gulong)delta < line - function_line) + if (delta >= 0 && (gulong)delta < line - matching_line) { - function_tag = tag; - function_line = tag->atts.entry.line; + matching_tag = tag; + matching_line = tag->atts.entry.line; } } } if (local) g_ptr_array_free (local, TRUE); - return function_tag; + return matching_tag; +} + + +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); }
Modified: tagmanager/src/tm_workspace.h 7 files changed, 7 insertions(+), 0 deletions(-) =================================================================== @@ -152,6 +152,13 @@ const GPtrArray *tm_workspace_find_scope_members(const GPtrArray *file_tags, tm_workspace_find_namespace_members (const GPtrArray * file_tags, const char *name, gboolean search_global);
+/* 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 guint tag_types); + /* 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.
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).