1
0
forked from VimPlug/jedi

fix list comprehensions. they were not implemented in a good way

This commit is contained in:
Dave Halter
2014-06-12 11:10:10 +02:00
parent f8b79b3dd0
commit d5758adb2b
4 changed files with 13 additions and 40 deletions

View File

@@ -192,10 +192,6 @@ class Evaluator(object):
next(call_path, None) # the first one has been used already
return self.follow_path(call_path, r, element.parent)
elif isinstance(element, pr.ListComprehension):
#lc = element.get_most_inner_lc()
# Caveat: parents are being changed, but this doesn't matter,
# because nothing else uses it.
#element.stmt.parent = loop
return self.eval_statement(element.stmt)
elif isinstance(element, pr.Lambda):
return [er.Function(self, element)]

View File

@@ -470,8 +470,8 @@ def get_names_of_scope(evaluator, scope, position=None, star_search=True, includ
:rtype: [(pr.Scope, [pr.Name])]
:return: Return an generator that yields a pair of scope and names.
"""
if isinstance(scope, iterable.ListComprehensionFlow):
position = scope.list_comprehension.parent.start_pos
if isinstance(scope, pr.ListComprehension):
position = scope.parent.start_pos
in_func_scope = scope
non_flow = scope.get_parent_until(pr.Flow, reverse=True)
@@ -497,7 +497,7 @@ def get_names_of_scope(evaluator, scope, position=None, star_search=True, includ
yield scope, _get_defined_names_for_position(scope, position, in_func_scope)
except StopIteration:
reraise(common.MultiLevelStopIteration, sys.exc_info()[2])
if scope.isinstance(iterable.ListComprehensionFlow):
if scope.isinstance(pr.ListComprehension):
# is a list comprehension
yield scope, scope.get_defined_names(is_internal_call=True)

View File

@@ -88,7 +88,7 @@ class _RecursionNode(object):
if not other:
return None
is_list_comp = lambda x: isinstance(x, iterable.ListComprehensionFlow)
is_list_comp = lambda x: isinstance(x, pr.ListComprehension)
return self.script == other.script \
and self.position == other.position \
and not is_list_comp(self.stmt.parent) \