for flows triggered an exception if goto_assignments was used on the keyword. found with the help of sith.py

This commit is contained in:
Dave Halter
2014-04-16 09:57:01 +02:00
parent a341791fda
commit 15fdecdb61
3 changed files with 15 additions and 5 deletions

View File

@@ -266,6 +266,9 @@ class Script(object):
stmt = r.module.statements[-1] stmt = r.module.statements[-1]
except IndexError: except IndexError:
raise NotFoundError() raise NotFoundError()
if isinstance(stmt, pr.Flow):
raise NotFoundError()
user_stmt = self._parser.user_stmt() user_stmt = self._parser.user_stmt()
if user_stmt is None: if user_stmt is None:
# Set the start_pos to a pseudo position, that doesn't exist but works # Set the start_pos to a pseudo position, that doesn't exist but works

View File

@@ -679,10 +679,12 @@ class ForFlow(Flow):
super(ForFlow, self).__init__(module, 'for', inputs, start_pos) super(ForFlow, self).__init__(module, 'for', inputs, start_pos)
self.set_stmt = set_stmt self.set_stmt = set_stmt
set_stmt.parent = self.use_as_parent
self.is_list_comp = is_list_comp self.is_list_comp = is_list_comp
if set_stmt is not None:
set_stmt.parent = self.use_as_parent
self.set_vars = set_stmt.get_defined_names() self.set_vars = set_stmt.get_defined_names()
for s in self.set_vars: for s in self.set_vars:
s.parent.parent = self.use_as_parent s.parent.parent = self.use_as_parent
s.parent = self.use_as_parent s.parent = self.use_as_parent

View File

@@ -94,3 +94,8 @@ def test_completion_on_complex_literals():
_check_number('4.0j.', 'complex') _check_number('4.0j.', 'complex')
# No dot no completion # No dot no completion
assert api.Script('4j').completions() == [] assert api.Script('4j').completions() == []
def test_goto_assignments_on_for():
with raises(api.NotFoundError):
api.Script('for').goto_assignments()