forked from VimPlug/jedi
add a Flow.previous attribute to be able to access the if flow from an else clause.
This commit is contained in:
@@ -538,9 +538,9 @@ class Parser(object):
|
||||
|
||||
f = pr.Flow(self.module, command, inputs, first_pos)
|
||||
if command in extended_flow:
|
||||
# the last statement has to be another part of
|
||||
# the flow statement, because a dedent releases the
|
||||
# main scope, so just take the last statement.
|
||||
# The last statement has to be another part of the flow
|
||||
# statement, because a dedent releases the main scope, so
|
||||
# just take the last statement.
|
||||
try:
|
||||
s = self._scope.statements[-1].set_next(f)
|
||||
except (AttributeError, IndexError):
|
||||
@@ -565,8 +565,9 @@ class Parser(object):
|
||||
if stmt is not None:
|
||||
stmt.parent = use_as_parent_scope
|
||||
try:
|
||||
func.statements.append(pr.KeywordStatement(tok_str, s,
|
||||
use_as_parent_scope, stmt))
|
||||
kw_stmt = pr.KeywordStatement(tok_str, s,
|
||||
use_as_parent_scope, stmt)
|
||||
self._scope.statements.append(kw_stmt)
|
||||
func.returns.append(stmt)
|
||||
# start_pos is the one of the return statement
|
||||
stmt.start_pos = s
|
||||
|
||||
@@ -637,10 +637,11 @@ class Flow(Scope):
|
||||
:param start_pos: Position (line, column) of the Flow statement.
|
||||
:type start_pos: tuple(int, int)
|
||||
"""
|
||||
__slots__ = ('next', 'command', '_parent', 'inputs', 'set_vars')
|
||||
__slots__ = ('next', 'previous', 'command', '_parent', 'inputs', 'set_vars')
|
||||
|
||||
def __init__(self, module, command, inputs, start_pos):
|
||||
self.next = None
|
||||
self.previous = None
|
||||
self.command = command
|
||||
super(Flow, self).__init__(module, start_pos)
|
||||
self._parent = None
|
||||
@@ -706,6 +707,7 @@ class Flow(Scope):
|
||||
else:
|
||||
self.next = next
|
||||
self.next.parent = self.parent
|
||||
self.next.previous = self
|
||||
return next
|
||||
|
||||
def scope_names_generator(self, position=None):
|
||||
|
||||
Reference in New Issue
Block a user