forked from VimPlug/jedi
Finally fix the last remaining fast parser issue.
This commit is contained in:
+9
-5
@@ -124,8 +124,12 @@ class ParserNode(object):
|
|||||||
try:
|
try:
|
||||||
# With fast_parser we have either 1 subscope or only statements.
|
# With fast_parser we have either 1 subscope or only statements.
|
||||||
self._content_scope = parser.module.subscopes[0]
|
self._content_scope = parser.module.subscopes[0]
|
||||||
|
# A parsed node's content will be in the first indent, because
|
||||||
|
# everything that's parsed is within this subscope.
|
||||||
|
self._is_class_or_def = True
|
||||||
except IndexError:
|
except IndexError:
|
||||||
self._content_scope = parser.module
|
self._content_scope = parser.module
|
||||||
|
self._is_class_or_def = False
|
||||||
else:
|
else:
|
||||||
self._rewrite_last_newline()
|
self._rewrite_last_newline()
|
||||||
|
|
||||||
@@ -197,10 +201,11 @@ class ParserNode(object):
|
|||||||
Adding a node means adding a node that was either just parsed or one
|
Adding a node means adding a node that was either just parsed or one
|
||||||
that can be reused.
|
that can be reused.
|
||||||
"""
|
"""
|
||||||
print(indent, self._indent)
|
# Content that is not a subscope can never be part of the current node,
|
||||||
#if indent > 0:
|
# because it's basically a sister node, that sits next to it and not
|
||||||
#import pdb;pdb.set_trace()
|
# within it.
|
||||||
if self._indent >= indent and not self.is_root_node():
|
if (self._indent >= indent or not self._is_class_or_def) and \
|
||||||
|
not self.is_root_node():
|
||||||
self.close()
|
self.close()
|
||||||
return self.parent.add_node(node, line_offset, indent)
|
return self.parent.add_node(node, line_offset, indent)
|
||||||
|
|
||||||
@@ -526,7 +531,6 @@ class FastTokenizer(object):
|
|||||||
# open parentheses ignored them.
|
# open parentheses ignored them.
|
||||||
previous_type = NEWLINE
|
previous_type = NEWLINE
|
||||||
|
|
||||||
print('x', typ, repr(value), self.previous)
|
|
||||||
# Parentheses ignore the indentation rules. The other three stand for
|
# Parentheses ignore the indentation rules. The other three stand for
|
||||||
# new lines.
|
# new lines.
|
||||||
if previous_type in (NEWLINE, INDENT, DEDENT) \
|
if previous_type in (NEWLINE, INDENT, DEDENT) \
|
||||||
|
|||||||
@@ -430,8 +430,7 @@ def test_additional_indent():
|
|||||||
pass
|
pass
|
||||||
''')
|
''')
|
||||||
|
|
||||||
x = check_fp(source, 2)
|
check_fp(source, 2)
|
||||||
import pdb; pdb.set_trace()
|
|
||||||
|
|
||||||
|
|
||||||
def test_incomplete_function():
|
def test_incomplete_function():
|
||||||
|
|||||||
Reference in New Issue
Block a user