1
0
forked from VimPlug/jedi

Fixed a few small things in the parser. Flow analysis is working again. Completely.

This commit is contained in:
Dave Halter
2014-11-06 04:41:16 +01:00
parent 56102e408e
commit aa0c73c9ab
4 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ class NameFinder(object):
check = flow_analysis.break_check(self._evaluator,
scope,
name.get_definition(),
self.scope)
self.name_str.get_definition().parent)
if check is not flow_analysis.UNREACHABLE:
last_names.append(name)
if check is flow_analysis.REACHABLE:
+7 -5
View File
@@ -34,16 +34,18 @@ UNSURE = Status(None, 'unsure')
def break_check(evaluator, base_scope, stmt, origin_scope=None):
from jedi.evaluate.representation import wrap
element_scope = wrap(evaluator, stmt.parent)
element_scope = wrap(evaluator, stmt.get_parent_scope(include_flows=True))
# Direct parents get resolved, we filter scopes that are separate branches.
# This makes sense for autocompletion and static analysis. For actual
# Python it doesn't matter, because we're talking about potentially
# unreachable code.
s = origin_scope
while s is not None:
if element_scope == s:
# e.g. `if 0:` would cause all name lookup within the flow make
# unaccessible. This is not a "problem" in Python, because the code is
# never called. In Jedi though, we still want to infer types.
while origin_scope is not None:
if element_scope == origin_scope:
return REACHABLE
s = s.parent
origin_scope = origin_scope.parent
return _break_check(evaluator, stmt, base_scope, element_scope)