forked from VimPlug/jedi
move some things from Flow to ForFlow
This commit is contained in:
@@ -556,10 +556,8 @@ class Flow(Scope):
|
|||||||
:type inputs: list(Statement)
|
:type inputs: list(Statement)
|
||||||
:param start_pos: Position (line, column) of the Flow statement.
|
:param start_pos: Position (line, column) of the Flow statement.
|
||||||
:type start_pos: tuple(int, int)
|
:type start_pos: tuple(int, int)
|
||||||
:param set_vars: Local variables used in the for loop (only there).
|
|
||||||
:type set_vars: list
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, module, command, inputs, start_pos, set_vars=None):
|
def __init__(self, module, command, inputs, start_pos):
|
||||||
self.next = None
|
self.next = None
|
||||||
self.command = command
|
self.command = command
|
||||||
super(Flow, self).__init__(module, start_pos)
|
super(Flow, self).__init__(module, start_pos)
|
||||||
@@ -568,13 +566,7 @@ class Flow(Scope):
|
|||||||
self.inputs = inputs
|
self.inputs = inputs
|
||||||
for s in inputs:
|
for s in inputs:
|
||||||
s.parent = self.use_as_parent
|
s.parent = self.use_as_parent
|
||||||
if set_vars is None:
|
self.set_vars = []
|
||||||
self.set_vars = []
|
|
||||||
else:
|
|
||||||
self.set_vars = set_vars
|
|
||||||
for s in self.set_vars:
|
|
||||||
s.parent.parent = self.use_as_parent
|
|
||||||
s.parent = self.use_as_parent
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def parent(self):
|
def parent(self):
|
||||||
@@ -639,15 +631,18 @@ class ForFlow(Flow):
|
|||||||
"""
|
"""
|
||||||
Used for the for loop, because there are two statement parts.
|
Used for the for loop, because there are two statement parts.
|
||||||
"""
|
"""
|
||||||
def __init__(self, module, inputs, start_pos, set_stmt,
|
def __init__(self, module, inputs, start_pos, set_stmt, is_list_comp=False):
|
||||||
is_list_comp=False):
|
super(ForFlow, self).__init__(module, 'for', inputs, start_pos)
|
||||||
set_vars = [t for t in set_stmt.token_list if isinstance(t, Name)]
|
|
||||||
super(ForFlow, self).__init__(module, 'for', inputs, start_pos, set_vars)
|
|
||||||
|
|
||||||
self.set_stmt = set_stmt
|
self.set_stmt = set_stmt
|
||||||
set_stmt.parent = self.use_as_parent
|
set_stmt.parent = self.use_as_parent
|
||||||
self.is_list_comp = is_list_comp
|
self.is_list_comp = is_list_comp
|
||||||
|
|
||||||
|
self.set_vars = [t for t in set_stmt.token_list if isinstance(t, Name)]
|
||||||
|
for s in self.set_vars:
|
||||||
|
s.parent.parent = self.use_as_parent
|
||||||
|
s.parent = self.use_as_parent
|
||||||
|
|
||||||
def get_code(self, first_indent=False, indention=" " * 4):
|
def get_code(self, first_indent=False, indention=" " * 4):
|
||||||
vars = ",".join(x.get_code() for x in self.set_vars)
|
vars = ",".join(x.get_code() for x in self.set_vars)
|
||||||
stmts = []
|
stmts = []
|
||||||
|
|||||||
Reference in New Issue
Block a user