mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 13:45:01 +08:00
Fix diff parser: DEDENT as error leaves should also be ignored and reparsed
This commit is contained in:
@@ -617,7 +617,7 @@ class _NodesTree(object):
|
|||||||
# Endmarkers just distort all the checks below. Remove them.
|
# Endmarkers just distort all the checks below. Remove them.
|
||||||
break
|
break
|
||||||
|
|
||||||
if node.type == 'error_leaf' and node.token_type == 'ERROR_DEDENT':
|
if node.type == 'error_leaf' and node.token_type in ('DEDENT', 'ERROR_DEDENT'):
|
||||||
break
|
break
|
||||||
# TODO this check might take a bit of time for large files. We
|
# TODO this check might take a bit of time for large files. We
|
||||||
# might want to change this to do more intelligent guessing or
|
# might want to change this to do more intelligent guessing or
|
||||||
|
|||||||
@@ -1172,4 +1172,30 @@ def test_error_dedent_in_between(differ):
|
|||||||
''')
|
''')
|
||||||
differ.initialize(code1)
|
differ.initialize(code1)
|
||||||
differ.parse(code2, copies=1, parsers=1, expect_error_leaves=True)
|
differ.parse(code2, copies=1, parsers=1, expect_error_leaves=True)
|
||||||
differ.parse(code1, parsers=2, copies=1)
|
differ.parse(code1, copies=1, parsers=2)
|
||||||
|
|
||||||
|
|
||||||
|
def test_x(differ):
|
||||||
|
code1 = dedent('''\
|
||||||
|
class SocketIO:
|
||||||
|
x
|
||||||
|
def f():
|
||||||
|
""
|
||||||
|
copied
|
||||||
|
a
|
||||||
|
''')
|
||||||
|
code2 = dedent('''\
|
||||||
|
try:
|
||||||
|
de
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
d
|
||||||
|
def f():
|
||||||
|
""
|
||||||
|
copied
|
||||||
|
a
|
||||||
|
''')
|
||||||
|
differ.initialize(code1)
|
||||||
|
differ.parse(code2, copies=ANY, parsers=ANY, expect_error_leaves=True)
|
||||||
|
differ.parse(code1, copies=ANY, parsers=ANY)
|
||||||
|
|||||||
Reference in New Issue
Block a user