mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-17 13:59:37 +08:00
Error recovery should not delete parts of simple_stmt.
This commit is contained in:
@@ -460,7 +460,7 @@ class _Importer(object):
|
|||||||
def follow_file_system(self):
|
def follow_file_system(self):
|
||||||
# Handle "magic" Flask extension imports:
|
# Handle "magic" Flask extension imports:
|
||||||
# ``flask.ext.foo`` is really ``flask_foo`` or ``flaskext.foo``.
|
# ``flask.ext.foo`` is really ``flask_foo`` or ``flaskext.foo``.
|
||||||
if len(self.import_path) > 2 and self.str_import_path()[:2] == ('flask', 'ext'):
|
if len(self.import_path) > 2 and self.str_import_path[:2] == ('flask', 'ext'):
|
||||||
orig_path = tuple(self.import_path)
|
orig_path = tuple(self.import_path)
|
||||||
part = orig_path[2]
|
part = orig_path[2]
|
||||||
pos = (part._line, part._column)
|
pos = (part._line, part._column)
|
||||||
@@ -633,7 +633,7 @@ class _Importer(object):
|
|||||||
if self.import_path:
|
if self.import_path:
|
||||||
for scope in self.follow(evaluator):
|
for scope in self.follow(evaluator):
|
||||||
# flask
|
# flask
|
||||||
if self.str_import_path() == ('flask', 'ext'):
|
if self.str_import_path == ('flask', 'ext'):
|
||||||
# List Flask extensions like ``flask_foo``
|
# List Flask extensions like ``flask_foo``
|
||||||
for mod in self._get_module_names():
|
for mod in self._get_module_names():
|
||||||
modname = str(mod)
|
modname = str(mod)
|
||||||
|
|||||||
@@ -222,9 +222,23 @@ class Parser(object):
|
|||||||
elif symbol == 'suite' and len(nodes) > 1:
|
elif symbol == 'suite' and len(nodes) > 1:
|
||||||
# suites without an indent in them get discarded.
|
# suites without an indent in them get discarded.
|
||||||
break
|
break
|
||||||
|
elif symbol == 'simple_stmt' and len(nodes) > 1:
|
||||||
|
# simple_stmt can just be turned into a Node, if there are
|
||||||
|
# enough statements. Ignore the rest after that.
|
||||||
|
break
|
||||||
return index, symbol, nodes
|
return index, symbol, nodes
|
||||||
|
|
||||||
index, symbol, nodes = current_suite(stack)
|
index, symbol, nodes = current_suite(stack)
|
||||||
|
if symbol == 'simple_stmt':
|
||||||
|
index -= 1
|
||||||
|
(_, _, (typ, suite_nodes)) = stack[index]
|
||||||
|
symbol = grammar.number2symbol[typ]
|
||||||
|
suite_nodes.append(pt.Node(symbol, list(nodes)))
|
||||||
|
# Remove
|
||||||
|
nodes[:] = []
|
||||||
|
nodes = suite_nodes
|
||||||
|
stack[index]
|
||||||
|
|
||||||
#print('err', tokenize.tok_name[typ], repr(value), start_pos, len(stack), index)
|
#print('err', tokenize.tok_name[typ], repr(value), start_pos, len(stack), index)
|
||||||
self._stack_removal(grammar, stack, index + 1, value, start_pos)
|
self._stack_removal(grammar, stack, index + 1, value, start_pos)
|
||||||
if value in ('import', 'from', 'class', 'def', 'try', 'while', 'return'):
|
if value in ('import', 'from', 'class', 'def', 'try', 'while', 'return'):
|
||||||
|
|||||||
Reference in New Issue
Block a user