Skip to content

Commit

Permalink
Move tm_get_current_tag() from tm_workspace to tm_tag
Browse files Browse the repository at this point in the history
This function has nothing to do with the workspace so it rather belongs
to tm_tag.
  • Loading branch information
techee committed Nov 2, 2014
1 parent 71cc1ec commit f35d0b9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 42 deletions.
41 changes: 41 additions & 0 deletions tagmanager/src/tm_tag.c
Expand Up @@ -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 */

/*
Expand Down
2 changes: 2 additions & 0 deletions tagmanager/src/tm_tag.h
Expand Up @@ -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);
Expand Down
40 changes: 0 additions & 40 deletions tagmanager/src/tm_workspace.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions tagmanager/src/tm_workspace.h
Expand Up @@ -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);

Expand Down

0 comments on commit f35d0b9

Please sign in to comment.