Revision: 4768 http://geany.svn.sourceforge.net/geany/?rev=4768&view=rev Author: ntrel Date: 2010-03-17 13:39:18 +0000 (Wed, 17 Mar 2010)
Log Message: ----------- Apply patch from Colomban Wendling to parse Python lambda functions (thanks) - modified to only parse toplevel or class member lambdas.
Modified Paths: -------------- trunk/ChangeLog trunk/tagmanager/python.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-03-17 04:34:33 UTC (rev 4767) +++ trunk/ChangeLog 2010-03-17 13:39:18 UTC (rev 4768) @@ -1,9 +1,17 @@ +2010-03-17 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * tagmanager/python.c: + Apply patch from Colomban Wendling to parse Python lambda functions + (thanks) - modified to only parse toplevel or class member lambdas. + + 2010-03-17 Lex Trotman <elextr.at.gmail.dot.com>
- * src/build.c + * src/build.c: Fix using return value without checking return status, caused incorrect sensitivity settings on build dialog.
+ 2010-03-16 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* HACKING: @@ -11,6 +19,7 @@ Add Testing section. Update Libraries section about synchronizing with other projects.
+ 2010-03-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/ui_utils.c:
Modified: trunk/tagmanager/python.c =================================================================== --- trunk/tagmanager/python.c 2010-03-17 04:34:33 UTC (rev 4767) +++ trunk/tagmanager/python.c 2010-03-17 13:39:18 UTC (rev 4768) @@ -534,6 +534,49 @@ return NULL; }
+/* checks if there is a lambda at position of cp, and return its argument list + * if so. + * We don't return the lambda name since it is useless for now since we already + * know it when we call this function, and it would be a little slower. */ +static boolean varIsLambda (const char *cp, char **arglist) +{ + boolean is_lambda = FALSE; + + cp = skipSpace (cp); + cp = skipIdentifier (cp); /* skip the lambda's name */ + cp = skipSpace (cp); + if (*cp == '=') + { + cp++; + cp = skipSpace (cp); + if (strncmp (cp, "lambda", 6) == 0) + { + const char *tmp; + + cp += 6; /* skip the lambda */ + tmp = skipSpace (cp); + /* check if there is a space after lambda to detect assignations + * starting with 'lambdaXXX' */ + if (tmp != cp) + { + vString *args = vStringNew (); + + cp = tmp; + vStringPut (args, '('); + for (; *cp != 0 && *cp != ':'; cp++) + vStringPut (args, *cp); + vStringPut (args, ')'); + vStringTerminate (args); + if (arglist) + *arglist = strdup (vStringValue (args)); + vStringDelete (args); + is_lambda = TRUE; + } + } + } + return is_lambda; +} + static void findPythonTags (void) { vString *const continuation = vStringNew (); @@ -656,6 +699,7 @@ if (variable) { const char *start = variable; + char *arglist; boolean parent_is_class;
vStringClear (name); @@ -667,11 +711,21 @@ vStringTerminate (name);
parent_is_class = constructParentString(nesting_levels, indent, parent); - /* skip variables in methods */ - if (! parent_is_class && vStringLength(parent) > 0) - continue; + if (varIsLambda (variable, &arglist)) + { + /* show class members or top-level script lambdas only */ + if (parent_is_class || vStringLength(parent) == 0) + makeFunctionTag (name, parent, parent_is_class, arglist); + eFree (arglist); + } + else + { + /* skip variables in methods */ + if (! parent_is_class && vStringLength(parent) > 0) + continue;
- makeVariableTag (name, parent); + makeVariableTag (name, parent); + } } /* Find and parse imports */ parseImports(line);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.