mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-22 07:18:27 +08:00
Fix a few issues caused by the refactoring.
This commit is contained in:
@@ -113,11 +113,17 @@ class ErrorStatement(object):
|
||||
of the stack at which time its parents don't yet exist..
|
||||
"""
|
||||
start_pos = self.start_pos
|
||||
for c in root_node.children:
|
||||
if c.start_pos < start_pos <= c.end_pos:
|
||||
return self.set_parent(c)
|
||||
try:
|
||||
children = root_node.children
|
||||
except AttributeError:
|
||||
self.parent = root_node
|
||||
else:
|
||||
for c in children:
|
||||
if c.start_pos < start_pos <= c.end_pos:
|
||||
self.set_parent(c)
|
||||
return
|
||||
|
||||
self.parent = root_node
|
||||
self.parent = root_node
|
||||
|
||||
|
||||
class ErrorToken(tree.LeafWithNewLines):
|
||||
@@ -288,6 +294,10 @@ class Parser(object):
|
||||
return pt.Number(self.position_modifier, value, start_pos, prefix)
|
||||
elif type in (NEWLINE, ENDMARKER):
|
||||
return pt.Whitespace(self.position_modifier, value, start_pos, prefix)
|
||||
elif type == INDENT:
|
||||
return pt.Indent(self.position_modifier, value, start_pos, prefix)
|
||||
elif type == DEDENT:
|
||||
return pt.Dedent(self.position_modifier, value, start_pos, prefix)
|
||||
else:
|
||||
return pt.Operator(self.position_modifier, value, start_pos, prefix)
|
||||
|
||||
|
||||
@@ -121,7 +121,8 @@ class PgenParser(object):
|
||||
break
|
||||
else:
|
||||
# We never broke out -- EOF is too soon -- Unfinished statement.
|
||||
self.error_recovery(self.grammar, self.stack, type_, value,
|
||||
# TODO the arcs argument [] is not correctly defined.
|
||||
self.error_recovery(self.grammar, self.stack, [], type_, value,
|
||||
start_pos, prefix, self.addtoken)
|
||||
# Add the ENDMARKER again.
|
||||
if not self.addtoken(type_, value, prefix, start_pos):
|
||||
|
||||
@@ -433,6 +433,16 @@ class String(Literal):
|
||||
__slots__ = ()
|
||||
|
||||
|
||||
class Indent(Leaf):
|
||||
type = 'indent'
|
||||
__slots__ = ()
|
||||
|
||||
|
||||
class Dedent(Leaf):
|
||||
type = 'indent'
|
||||
__slots__ = ()
|
||||
|
||||
|
||||
class Operator(Leaf):
|
||||
type = 'operator'
|
||||
__slots__ = ()
|
||||
|
||||
Reference in New Issue
Block a user