forked from VimPlug/jedi
Further small flow_analysis corrections. Keywords are only equal to other keywords if they are the same. Not in case of the same value anymore.
This commit is contained in:
@@ -210,9 +210,9 @@ class Evaluator(object):
|
|||||||
"""
|
"""
|
||||||
if isinstance(atom, pr.Name):
|
if isinstance(atom, pr.Name):
|
||||||
# This is the first global lookup.
|
# This is the first global lookup.
|
||||||
stmt = atom.get_parent_until((pr.ExprStmt, pr.ReturnStmt, pr.Scope))
|
stmt = atom.get_definition()
|
||||||
return self.find_types(stmt.get_parent_until(pr.IsScope), atom, stmt.start_pos,
|
return self.find_types(stmt.get_parent_until(pr.IsScope), atom,
|
||||||
search_global=True)
|
stmt.start_pos, search_global=True)
|
||||||
elif isinstance(atom, pr.Literal):
|
elif isinstance(atom, pr.Literal):
|
||||||
return [compiled.create(self, atom.eval())]
|
return [compiled.create(self, atom.eval())]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ UNSURE = Status(None, 'unsure')
|
|||||||
|
|
||||||
def break_check(evaluator, base_scope, stmt, origin_scope=None):
|
def break_check(evaluator, base_scope, stmt, origin_scope=None):
|
||||||
from jedi.evaluate.representation import wrap
|
from jedi.evaluate.representation import wrap
|
||||||
base_scope = wrap(evaluator, base_scope)
|
|
||||||
element_scope = wrap(evaluator, stmt.parent)
|
element_scope = wrap(evaluator, stmt.parent)
|
||||||
|
|
||||||
# Direct parents get resolved, we filter scopes that are separate branches.
|
# Direct parents get resolved, we filter scopes that are separate branches.
|
||||||
# This makes sense for autocompletion and static analysis. For actual
|
# This makes sense for autocompletion and static analysis. For actual
|
||||||
# Python it doesn't matter, because we're talking about potentially
|
# Python it doesn't matter, because we're talking about potentially
|
||||||
@@ -46,6 +44,13 @@ def break_check(evaluator, base_scope, stmt, origin_scope=None):
|
|||||||
if element_scope == s:
|
if element_scope == s:
|
||||||
return REACHABLE
|
return REACHABLE
|
||||||
s = s.parent
|
s = s.parent
|
||||||
|
return _break_check(evaluator, stmt, base_scope, element_scope)
|
||||||
|
|
||||||
|
|
||||||
|
def _break_check(evaluator, stmt, base_scope, element_scope):
|
||||||
|
from jedi.evaluate.representation import wrap
|
||||||
|
element_scope = wrap(evaluator, element_scope)
|
||||||
|
base_scope = wrap(evaluator, base_scope)
|
||||||
|
|
||||||
reachable = REACHABLE
|
reachable = REACHABLE
|
||||||
if isinstance(element_scope, pr.IfStmt):
|
if isinstance(element_scope, pr.IfStmt):
|
||||||
@@ -66,7 +71,7 @@ def break_check(evaluator, base_scope, stmt, origin_scope=None):
|
|||||||
return reachable
|
return reachable
|
||||||
|
|
||||||
if base_scope != element_scope and base_scope != element_scope.parent:
|
if base_scope != element_scope and base_scope != element_scope.parent:
|
||||||
return reachable & break_check(evaluator, base_scope, element_scope.parent)
|
return reachable & _break_check(evaluator, stmt, base_scope, element_scope.parent)
|
||||||
return reachable
|
return reachable
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class ExecutedParam(pr.Param):
|
|||||||
def eval(self, evaluator):
|
def eval(self, evaluator):
|
||||||
types = []
|
types = []
|
||||||
for v in self.values:
|
for v in self.values:
|
||||||
if isinstance(v, (pr.Simple, pr.Name, pr.Literal)):
|
if isinstance(v, (pr.Simple, pr.Leaf)):
|
||||||
types += evaluator.eval_element(v)
|
types += evaluator.eval_element(v)
|
||||||
else:
|
else:
|
||||||
types.append(v)
|
types.append(v)
|
||||||
|
|||||||
@@ -334,6 +334,8 @@ class Keyword(Leaf):
|
|||||||
Make comparisons with strings easy.
|
Make comparisons with strings easy.
|
||||||
Improves the readability of the parser.
|
Improves the readability of the parser.
|
||||||
"""
|
"""
|
||||||
|
if isinstance(other, Keyword):
|
||||||
|
return self is other
|
||||||
return self.value == other
|
return self.value == other
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
|
|||||||
Reference in New Issue
Block a user