Revision: 889 http://svn.sourceforge.net/geany/?rev=889&view=rev Author: ntrel Date: 2006-10-12 09:25:53 -0700 (Thu, 12 Oct 2006)
Log Message: ----------- Backported tm_get_current_function() from Anjuta
Modified Paths: -------------- trunk/tagmanager/include/tm_workspace.h trunk/tagmanager/tm_workspace.c
Modified: trunk/tagmanager/include/tm_workspace.h =================================================================== --- trunk/tagmanager/include/tm_workspace.h 2006-10-12 16:25:11 UTC (rev 888) +++ trunk/tagmanager/include/tm_workspace.h 2006-10-12 16:25:53 UTC (rev 889) @@ -138,6 +138,12 @@ const GPtrArray *tm_workspace_find(const char *name, int type, TMTagAttrType *attrs , gboolean partial, langType lang);
+/*! Returns TMTag to function 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. */ +const TMTag *tm_get_current_function(GPtrArray *file_tags, const gulong line); + /*! Returns a list of parent classes for the given class name \param name Name of the class \return A GPtrArray of TMTag pointers (includes the TMTag for the class) */
Modified: trunk/tagmanager/tm_workspace.c =================================================================== --- trunk/tagmanager/tm_workspace.c 2006-10-12 16:25:11 UTC (rev 888) +++ trunk/tagmanager/tm_workspace.c 2006-10-12 16:25:53 UTC (rev 889) @@ -526,6 +526,34 @@ }
+const TMTag * +tm_get_current_function (GPtrArray * file_tags, const gulong line) +{ + GPtrArray *const local = tm_tags_extract (file_tags, tm_tag_function_t); + if (local && local->len) + { + guint i; + TMTag *tag, *function_tag = NULL; + gulong function_line = 0; + glong delta; + + for (i = 0; (i < local->len); ++i) + { + tag = TM_TAG (local->pdata[i]); + delta = line - tag->atts.entry.line; + if (delta >= 0 && (gulong)delta < line - function_line) + { + function_tag = tag; + function_line = tag->atts.entry.line; + } + } + g_ptr_array_free (local, TRUE); + return function_tag; + } + return NULL; +}; + + const GPtrArray *tm_workspace_get_parents(const gchar *name) { static TMTagAttrType type[] = { tm_tag_attr_name_t, tm_tag_attr_none_t };
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.