Skip to content
Browse files

Add tm_get_current_tag()

  • Loading branch information...
1 parent afb1eaa commit d83bd409388313503dcad58cb6d601bf92e64fbc @b4n b4n committed Sep 17, 2012
Showing with 22 additions and 8 deletions.
  1. +15 −8 tagmanager/src/tm_workspace.c
  2. +7 −0 tagmanager/src/tm_workspace.h
View
23 tagmanager/src/tm_workspace.c
@@ -733,30 +733,37 @@ tm_workspace_find_scoped (const char *name, const char *scope, gint type,
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);
}
View
7 tagmanager/src/tm_workspace.h
@@ -152,6 +152,13 @@ const GPtrArray *
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.

0 comments on commit d83bd40

Please sign in to comment.
Something went wrong with that request. Please try again.