[geany/geany] d75598: python: Fix resetting scope on anonymous blocks
Colomban Wendling
git-noreply at xxxxx
Sun Jun 14 15:13:46 UTC 2015
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sun, 14 Jun 2015 15:13:46 UTC
Commit: d75598cc4895c0dc68dbd00a5ed819943a31242f
https://github.com/geany/geany/commit/d75598cc4895c0dc68dbd00a5ed819943a31242f
Log Message:
-----------
python: Fix resetting scope on anonymous blocks
The previous fix, coming from [CTags bug #1988026], was incorrect if
the parent was not a root-level element, as it checked the level name
(unqualified) against the parent name (qualified).
However, there is no need to check the level name, all what counts is
the indentation level itself: if it's smaller than an existing level,
it ends it.
This fixes [CTags bug #356].
[CTags bug #1988026]: https://sourceforge.net/p/ctags/bugs/227/
[CTags bug #356]: https://sourceforge.net/p/ctags/bugs/356/
X-Universal-CTags-Commit-ID: ab91e6e1ae84b80870a1e8712fc7f3133e4b5542
Modified Paths:
--------------
tagmanager/ctags/python.c
tests/ctags/Makefile.am
tests/ctags/python-anonymous-nestlevel_ctags-bug-356.py
tests/ctags/python-anonymous-nestlevel_ctags-bug-356.py.tags
Modified: tagmanager/ctags/python.c
18 lines changed, 6 insertions(+), 12 deletions(-)
===================================================================
@@ -463,10 +463,8 @@ static boolean constructParentString(NestingLevels *nls, int indent,
return is_class;
}
-/* Check whether parent's indentation level is higher than the current level and
- * if so, remove it.
- */
-static void checkParent(NestingLevels *nls, int indent, vString *parent)
+/* Check indentation level and truncate nesting levels accordingly */
+static void checkIndent(NestingLevels *nls, int indent)
{
int i;
NestingLevel *n;
@@ -474,14 +472,10 @@ static void checkParent(NestingLevels *nls, int indent, vString *parent)
for (i = 0; i < nls->n; i++)
{
n = nls->levels + i;
- /* is there a better way to compare two vStrings? */
- if (n && strcmp(vStringValue(parent), vStringValue(n->name)) == 0)
+ if (n && indent <= n->indentation)
{
- if (indent <= n->indentation)
- {
- /* remove this level by clearing its name */
- vStringClear(n->name);
- }
+ /* truncate levels */
+ nls->n = i;
break;
}
}
@@ -749,7 +743,7 @@ static void findPythonTags (void)
continue;
}
- checkParent(nesting_levels, indent, parent);
+ checkIndent(nesting_levels, indent);
/* Find global and class variables */
variable = findVariable(line);
Modified: tests/ctags/Makefile.am
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -235,6 +235,7 @@ test_sources = \
pure_elem.f95 \
py_constructor_arglist.py \
py-skipped-string.py \
+ python-anonymous-nestlevel_ctags-bug-356.py \
qualified_types.f90 \
random.sql \
readlob.sql \
Modified: tests/ctags/python-anonymous-nestlevel_ctags-bug-356.py
6 lines changed, 6 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,6 @@
+class Testclass():
+ def main(self):
+ variable = True
+
+if __name__ == "__main__":
+ module_level_attribute = True
Modified: tests/ctags/python-anonymous-nestlevel_ctags-bug-356.py.tags
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,4 @@
+# format=tagmanager
+Testclass�1�0
+main�128�(self)�Testclass�0
+module_level_attribute�16384�0
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list