Kaydet (Commit) 26f161c9 authored tarafından Nick Treleaven's avatar Nick Treleaven

Apply patch from Colomban Wendling to parse Python lambda functions

(thanks) - modified to only parse toplevel or class member lambdas.



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4768 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 57aaf35b
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:
......
......@@ -534,6 +534,49 @@ static const char *skipTypeDecl (const char *cp, boolean *is_class)
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 @@ static void findPythonTags (void)
if (variable)
{
const char *start = variable;
char *arglist;
boolean parent_is_class;
vStringClear (name);
......@@ -667,11 +711,21 @@ static void findPythonTags (void)
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment