SF.net SVN: geany:[3809] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Wed May 20 15:38:04 UTC 2009


Revision: 3809
          http://geany.svn.sourceforge.net/geany/?rev=3809&view=rev
Author:   ntrel
Date:     2009-05-20 15:38:04 +0000 (Wed, 20 May 2009)

Log Message:
-----------
Parse Python calltips.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/TODO
    trunk/src/editor.c
    trunk/tagmanager/python.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-05-20 15:01:04 UTC (rev 3808)
+++ trunk/ChangeLog	2009-05-20 15:38:04 UTC (rev 3809)
@@ -4,6 +4,8 @@
    Fix multiline indent when selection covers text on the last line.
  * src/notebook.c:
    Show current document in bold in tab popup menu.
+ * src/editor.c, tagmanager/python.c, TODO:
+   Parse Python calltips.
 
 
 2009-05-19  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2009-05-20 15:01:04 UTC (rev 3808)
+++ trunk/TODO	2009-05-20 15:38:04 UTC (rev 3809)
@@ -20,10 +20,6 @@
 	o (better search & replace regex support - use
 	   SCI_GETCHARACTERPOINTER and GNU regex?)
 	o (parsing tags from a memory buffer instead of a file on disk)
-	o (calltip support for non-C-like languages that use
-	   function_name(arguments) syntax)
-	o (better tags support for popular languages? - this is a moving
-	   target...)
 	o (tango-like icons for the symbol list)
 	o (show autocompletion symbol icons - see SCI_REGISTERIMAGE)
 
@@ -40,6 +36,10 @@
 --------
 Note: these items might not get worked on.
 
+	o (calltip support for non-C-like languages that use
+	   function_name(arguments) syntax - see python.c:parseArglist())
+	o (better tags support for popular languages? - this is a moving
+	   target...)
 	o Some kind of support for CTags tags files
 	o Scope resolution for object members
 	o Python plugin interface (different concept from Lua scripting)

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2009-05-20 15:01:04 UTC (rev 3808)
+++ trunk/src/editor.c	2009-05-20 15:38:04 UTC (rev 3809)
@@ -1377,7 +1377,8 @@
 
 	g_return_val_if_fail(ft && word && *word, NULL);
 
-	tags = tm_workspace_find(word, arg_types | tm_tag_class_t, attrs, FALSE, ft->lang);
+	/* use all types in case language uses wrong tag type e.g. python "members" instead of "methods" */
+	tags = tm_workspace_find(word, tm_tag_max_t, attrs, FALSE, ft->lang);
 	if (tags->len == 0)
 		return NULL;
 

Modified: trunk/tagmanager/python.c
===================================================================
--- trunk/tagmanager/python.c	2009-05-20 15:01:04 UTC (rev 3808)
+++ trunk/tagmanager/python.c	2009-05-20 15:38:04 UTC (rev 3809)
@@ -61,13 +61,14 @@
  * extract all relevant information and create a tag.
  */
 static void makeFunctionTag (vString *const function,
-	vString *const parent, int is_class_parent)
+	vString *const parent, int is_class_parent, const char *arglist)
 {
 	tagEntryInfo tag;
 	initTagEntry (&tag, vStringValue (function));
 
 	tag.kindName = "function";
 	tag.kind = 'f';
+	tag.extensionFields.arglist = arglist;
 
 	if (vStringLength (parent) > 0)
 	{
@@ -291,11 +292,39 @@
 	vStringDelete (name_next);
 }
 
+/* modified from get.c getArglistFromStr().
+ * warning: terminates rest of string past arglist!
+ * note: does not ignore brackets inside strings! */
+static char *parseArglist(const char *buf)
+{
+	char *start, *end;
+	int level;
+	if (NULL == buf)
+		return NULL;
+	if (NULL == (start = strchr(buf, '(')))
+		return NULL;
+	for (level = 1, end = start + 1; level > 0; ++end)
+	{
+		if ('\0' == *end)
+			break;
+		else if ('(' == *end)
+			++ level;
+		else if (')' == *end)
+			-- level;
+	}
+	*end = '\0';
+	return strdup(start);
+}
+
 static void parseFunction (const char *cp, vString *const def,
 	vString *const parent, int is_class_parent)
 {
+	char *arglist;
+
 	cp = parseIdentifier (cp, def);
-	makeFunctionTag (def, parent, is_class_parent);
+	arglist = parseArglist (cp);
+	makeFunctionTag (def, parent, is_class_parent, arglist);
+	eFree (arglist);
 }
 
 /* Get the combined name of a nested symbol. Classes are separated with ".",


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