1
0
forked from VimPlug/jedi

made ListComprehensions behave more llike typical 'pr' objects

This commit is contained in:
David Halter
2013-02-17 00:23:43 +04:30
parent 89a2cb15d0
commit 1366f5fa61
2 changed files with 15 additions and 5 deletions

View File

@@ -439,9 +439,8 @@ class Parser(object):
st = pr.Statement(self.module, src, [], [], [],
toks, first_pos, self.end_pos)
for s in [st, middle, in_clause]:
s.parent = self.scope
tok = pr.ListComprehension(st, middle, in_clause)
tok = pr.ListComprehension(st, middle, in_clause,
self.scope)
tok_list.append(tok)
if list_comp:
string = ''

View File

@@ -1166,12 +1166,23 @@ class Name(Simple):
return len(self.names)
class ListComprehension(object):
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 = parent
@property
def start_pos(self):
return self.stmt.start_pos
@property
def end_pos(self):
return self.stmt.end_pos
def __repr__(self):
return "<%s: %s>" % \