forked from VimPlug/jedi
also fixed nested list comprehensions
This commit is contained in:
@@ -568,7 +568,7 @@ def follow_call_list(call_list, follow_array=False):
|
||||
# create a for loop, which does the same as list comprehensions
|
||||
loop = pr.ForFlow(module, [input], lc.stmt.start_pos, lc.middle, True)
|
||||
|
||||
loop.parent = lc.parent if parent is None else parent
|
||||
loop.parent = parent or lc.get_parent_until(pr.IsScope)
|
||||
|
||||
if isinstance(nested_lc, pr.ListComprehension):
|
||||
loop = evaluate_list_comprehension(nested_lc, loop)
|
||||
|
||||
@@ -435,7 +435,8 @@ class Parser(object):
|
||||
st = pr.Statement(self.module, src, [], [], [],
|
||||
toks, first_pos, self.end_pos)
|
||||
|
||||
tok = pr.ListComprehension(st, middle, in_clause)
|
||||
tok = pr.ListComprehension(st, middle, in_clause,
|
||||
self.scope)
|
||||
tok_list.append(tok)
|
||||
if list_comp:
|
||||
string = ''
|
||||
|
||||
@@ -93,8 +93,9 @@ class Simple(Base):
|
||||
|
||||
def __repr__(self):
|
||||
code = self.get_code().replace('\n', ' ')
|
||||
# TODO (this todo doesn't belong here) positions are not added right.
|
||||
return "<%s: %s@%s,%s>" % \
|
||||
(type(self).__name__, code, self.start_pos[0], self.start_pos[0])
|
||||
(type(self).__name__, code, self.start_pos[0], self.start_pos[1])
|
||||
|
||||
|
||||
class IsScope(Base):
|
||||
@@ -1174,13 +1175,13 @@ class Name(Simple):
|
||||
|
||||
class ListComprehension(Base):
|
||||
""" Helper class for list comprehensions """
|
||||
def __init__(self, stmt, middle, input):
|
||||
def __init__(self, stmt, middle, input, parent):
|
||||
self.stmt = stmt
|
||||
self.middle = middle
|
||||
self.input = input
|
||||
for s in [stmt, middle, input]:
|
||||
s.parent = self
|
||||
self.parent = None
|
||||
self.parent = parent
|
||||
|
||||
def get_parent_until(self, *args, **kwargs):
|
||||
return Simple.get_parent_until(self, *args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user