SF.net SVN: geany: [1147] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Dec 26 15:49:35 UTC 2006
Revision: 1147
http://svn.sourceforge.net/geany/?rev=1147&view=rev
Author: ntrel
Date: 2006-12-26 07:49:35 -0800 (Tue, 26 Dec 2006)
Log Message:
-----------
Add calltip support for D constructors.
Add tm_workspace_find_scoped() (adapted from Anjuta 2.02
tm_workspace_find()).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/sci_cb.c
trunk/tagmanager/include/tm_workspace.h
trunk/tagmanager/tm_workspace.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-12-26 15:43:50 UTC (rev 1146)
+++ trunk/ChangeLog 2006-12-26 15:49:35 UTC (rev 1147)
@@ -2,6 +2,11 @@
* tagmanager/tm_tag.c, tagmanager/include/tm_tag.h:
Fix missed matches in tm_tags_find().
+ * src/sci_cb.c, tagmanager/tm_workspace.c,
+ tagmanager/include/tm_workspace.h:
+ Add calltip support for D constructors.
+ Add tm_workspace_find_scoped() (adapted from Anjuta 2.02
+ tm_workspace_find()).
2006-12-24 Nick Treleaven <nick.treleaven at btinternet.com>
Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c 2006-12-26 15:43:50 UTC (rev 1146)
+++ trunk/src/sci_cb.c 2006-12-26 15:49:35 UTC (rev 1147)
@@ -544,17 +544,35 @@
g_return_val_if_fail(ft && word && *word, NULL);
tags = tm_workspace_find(word, tm_tag_max_t, NULL, FALSE, ft->lang);
- if (tags->len == 1 && TM_TAG(tags->pdata[0])->atts.entry.arglist)
+
+ if (tags->len == 0)
+ return NULL;
+
+ tag = TM_TAG(tags->pdata[0]);
+ if (tag->atts.entry.arglist)
{
- tag = TM_TAG(tags->pdata[0]);
if (tag->atts.entry.var_type)
return g_strconcat(tag->atts.entry.var_type, " ", tag->name,
" ", tag->atts.entry.arglist, NULL);
else
return g_strconcat(tag->name, " ", tag->atts.entry.arglist, NULL);
}
- else
- return NULL;
+ else if (tag->type == tm_tag_class_t && FILETYPE_ID(ft) == GEANY_FILETYPES_D)
+ {
+ TMTagAttrType attrs[] = { tm_tag_attr_name_t, 0 };
+
+ // user typed e.g. 'new Classname(' so lookup D constructor Classname::this()
+ tags = tm_workspace_find_scoped("this", tag->name, tm_tag_function_t | tm_tag_prototype_t,
+ attrs, FALSE, ft->lang, TRUE);
+ if (tags->len != 0)
+ {
+ tag = TM_TAG(tags->pdata[0]);
+ if (tag->atts.entry.arglist)
+ return g_strconcat(tag->atts.entry.scope, ".this ",
+ tag->atts.entry.arglist, NULL);
+ }
+ }
+ return NULL;
}
Modified: trunk/tagmanager/include/tm_workspace.h
===================================================================
--- trunk/tagmanager/include/tm_workspace.h 2006-12-26 15:43:50 UTC (rev 1146)
+++ trunk/tagmanager/include/tm_workspace.h 2006-12-26 15:49:35 UTC (rev 1147)
@@ -138,6 +138,20 @@
const GPtrArray *tm_workspace_find(const char *name, int type, TMTagAttrType *attrs
, gboolean partial, langType lang);
+/*! Returns all matching tags found in the workspace.
+ \param name The name of the tag to find.
+ \param scope The scope name of the tag to find, or NULL.
+ \param type The tag types to return (TMTagType). Can be a bitmask.
+ \param attrs The attributes to sort and dedup on (0 terminated integer array).
+ \param partial Whether partial match is allowed.
+ \param lang Specifies the language(see the table in parsers.h) of the tags to be found,
+ -1 for all
+ \return Array of matching tags. Do not free() it since it is a static member.
+*/
+const GPtrArray *
+tm_workspace_find_scoped (const char *name, const char *scope, gint type,
+ TMTagAttrType *attrs, gboolean partial, langType lang, gboolean global_search);
+
/*! 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.
Modified: trunk/tagmanager/tm_workspace.c
===================================================================
--- trunk/tagmanager/tm_workspace.c 2006-12-26 15:43:50 UTC (rev 1146)
+++ trunk/tagmanager/tm_workspace.c 2006-12-26 15:49:35 UTC (rev 1147)
@@ -526,6 +526,70 @@
}
+/* scope can be NULL.
+ * lang can be -1 */
+static int
+fill_find_tags_array (GPtrArray * dst, const GPtrArray * src,
+ const char *name, const char *scope, int type, gboolean partial,
+ gint lang, gboolean first)
+{
+ TMTag **match;
+ int tagIter, count;
+
+ if ((!src) || (!dst) || (!name) || (!*name))
+ return 0;
+
+ match = tm_tags_find (src, name, partial, &count);
+ if (count && match && *match)
+ {
+ for (tagIter = 0; tagIter < count; ++tagIter)
+ {
+ if (! scope || (match[tagIter]->atts.entry.scope &&
+ 0 == strcmp(match[tagIter]->atts.entry.scope, scope)))
+ {
+ if ((lang == -1 || lang == match[tagIter]->atts.entry.file->lang) &&
+ type & match[tagIter]->type)
+ {
+ g_ptr_array_add (dst, match[tagIter]);
+ if (first)
+ break;
+ }
+ }
+ }
+ }
+ return dst->len;
+}
+
+
+// adapted from tm_workspace_find, Anjuta 2.02
+const GPtrArray *
+tm_workspace_find_scoped (const char *name, const char *scope, gint type,
+ TMTagAttrType *attrs, gboolean partial, langType lang, gboolean global_search)
+{
+ static GPtrArray *tags = NULL;
+
+ if ((!theWorkspace))
+ return NULL;
+
+ if (tags)
+ g_ptr_array_set_size (tags, 0);
+ else
+ tags = g_ptr_array_new ();
+
+ fill_find_tags_array (tags, theWorkspace->work_object.tags_array,
+ name, scope, type, partial, lang, TRUE);
+ if (global_search)
+ {
+ // for a scoped tag, I think we always want the same language
+ fill_find_tags_array (tags, theWorkspace->global_tags,
+ name, scope, type, partial, lang, TRUE);
+ }
+ if (attrs)
+ tm_tags_sort (tags, attrs, TRUE);
+ return tags;
+}
+
+
const TMTag *
tm_get_current_function (GPtrArray * file_tags, const gulong line)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list