mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
Don't delete ErrorNode names. They are part of the parser now.
Fixes #594 and possibly also #590 and #579.
This commit is contained in:
@@ -350,21 +350,6 @@ class ParserWithRecovery(Parser):
|
|||||||
stack[-1][2][1].append(error_leaf)
|
stack[-1][2][1].append(error_leaf)
|
||||||
|
|
||||||
def _stack_removal(self, grammar, stack, arcs, start_index, value, start_pos):
|
def _stack_removal(self, grammar, stack, arcs, start_index, value, start_pos):
|
||||||
def clear_names(children):
|
|
||||||
for c in children:
|
|
||||||
try:
|
|
||||||
clear_names(c.children)
|
|
||||||
except AttributeError:
|
|
||||||
if isinstance(c, pt.Name):
|
|
||||||
try:
|
|
||||||
self._scope_names_stack[-1][c.value].remove(c)
|
|
||||||
self._used_names[c.value].remove(c)
|
|
||||||
except ValueError:
|
|
||||||
pass # This may happen with CompFor.
|
|
||||||
|
|
||||||
for dfa, state, node in stack[start_index:]:
|
|
||||||
clear_names(children=node[1])
|
|
||||||
|
|
||||||
failed_stack = []
|
failed_stack = []
|
||||||
found = False
|
found = False
|
||||||
all_nodes = []
|
all_nodes = []
|
||||||
|
|||||||
@@ -180,12 +180,12 @@ invalid = .call
|
|||||||
invalid
|
invalid
|
||||||
|
|
||||||
invalid = call?.call
|
invalid = call?.call
|
||||||
#?
|
#? str()
|
||||||
invalid
|
invalid
|
||||||
|
|
||||||
# comma
|
# comma
|
||||||
invalid = ,call
|
invalid = ,call
|
||||||
#?
|
#? str()
|
||||||
invalid
|
invalid
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ Renaming tests. This means search for usages.
|
|||||||
I always leave a little bit of space to add room for additions, because the
|
I always leave a little bit of space to add room for additions, because the
|
||||||
results always contain position informations.
|
results always contain position informations.
|
||||||
"""
|
"""
|
||||||
#< 4 (0,4), (3,0), (5,0), (17,0)
|
#< 4 (0,4), (3,0), (5,0), (17,0), (12,4), (14,5), (15,0)
|
||||||
def abc(): pass
|
def abc(): pass
|
||||||
|
|
||||||
#< 0 (-3,4), (0,0), (2,0), (14,0)
|
#< 0 (-3,4), (0,0), (2,0), (14,0), (9,4), (11,5), (12,0)
|
||||||
abc.d.a.bsaasd.abc.d
|
abc.d.a.bsaasd.abc.d
|
||||||
|
|
||||||
abc
|
abc
|
||||||
@@ -20,7 +20,7 @@ if 1:
|
|||||||
else:
|
else:
|
||||||
(abc) =
|
(abc) =
|
||||||
abc =
|
abc =
|
||||||
#< (-17,4), (-14,0), (-12,0), (0,0)
|
#< (-17,4), (-14,0), (-12,0), (0,0), (-2,0), (-3,5), (-5,4)
|
||||||
abc
|
abc
|
||||||
|
|
||||||
abc = 5
|
abc = 5
|
||||||
|
|||||||
@@ -213,3 +213,8 @@ def test_backslash_dos_style():
|
|||||||
grammar = load_grammar()
|
grammar = load_grammar()
|
||||||
m = ParserWithRecovery(grammar, u('\\\r\n')).module
|
m = ParserWithRecovery(grammar, u('\\\r\n')).module
|
||||||
assert m
|
assert m
|
||||||
|
|
||||||
|
|
||||||
|
def test_started_lambda_stmt():
|
||||||
|
p = ParserWithRecovery(load_grammar(), 'lambda a, b: a i')
|
||||||
|
assert p.get_parsed_node().children[0].type == 'error_node'
|
||||||
|
|||||||
Reference in New Issue
Block a user