SF.net SVN: geany:[4834] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Apr 18 21:42:49 UTC 2010


Revision: 4834
          http://geany.svn.sourceforge.net/geany/?rev=4834&view=rev
Author:   eht16
Date:     2010-04-18 21:42:49 +0000 (Sun, 18 Apr 2010)

Log Message:
-----------
Use tm_source_file_set_tag_arglist() to set the argument list field of Python class tags to the argument list of their __init__() methods.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tagmanager/python.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-04-18 21:42:38 UTC (rev 4833)
+++ trunk/ChangeLog	2010-04-18 21:42:49 UTC (rev 4834)
@@ -5,6 +5,10 @@
    tagmanager/parse.h, tagmanager/tm_source_file.c:
    Add tm_source_file_set_tag_arglist() to manually set the argument
    list of a tag.
+ * tagmanager/python.c:
+   Use tm_source_file_set_tag_arglist() to set the argument list
+   field of Python class tags to the argument list of their
+   __init__() methods.
 
 
 2010-04-17  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/tagmanager/python.c
===================================================================
--- trunk/tagmanager/python.c	2010-04-18 21:42:38 UTC (rev 4833)
+++ trunk/tagmanager/python.c	2010-04-18 21:42:49 UTC (rev 4834)
@@ -57,6 +57,30 @@
 	return (boolean) (isalnum (c) || c == '_');
 }
 
+static const char *get_class_name_from_parent (const char *parent)
+{
+	const char *result;
+
+	if (parent == NULL)
+		return NULL;
+
+	result = strrchr (parent, '.');
+	if (result != NULL)
+	{
+		result++;
+		parent = result;
+	}
+
+	result = strrchr (parent, '/');
+	if (result != NULL)
+		result++;
+	else
+		result = parent;
+
+	return result;
+}
+
+
 /* Given a string with the contents of a line directly after the "def" keyword,
  * extract all relevant information and create a tag.
  */
@@ -69,6 +93,13 @@
 	tag.kindName = "function";
 	tag.kind = 'f';
 	tag.extensionFields.arglist = arglist;
+	/* add argument list of __init__() methods to the class tag */
+	if (strcmp (vStringValue (function), "__init__") == 0 && parent != NULL)
+	{
+		const char *parent_tag_name = get_class_name_from_parent (vStringValue (parent));
+		if (parent_tag_name != NULL)
+			setTagArglistByName (parent_tag_name, arglist);
+	}
 
 	if (vStringLength (parent) > 0)
 	{


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