Add tm_get_current_tag()
This commit is contained in:
parent
afb1eaaa01
commit
d83bd40938
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user