forked from VimPlug/jedi
Fix error statement stacks positions.
This commit is contained in:
@@ -50,10 +50,16 @@ def load_grammar(file='grammar3.4'):
|
|||||||
|
|
||||||
|
|
||||||
class ErrorStatement(object):
|
class ErrorStatement(object):
|
||||||
def __init__(self, stack, next_token, next_start_pos):
|
def __init__(self, stack, next_token, position_modifier, next_start_pos):
|
||||||
self.stack = stack
|
self.stack = stack
|
||||||
|
self._position_modifier = position_modifier
|
||||||
self.next_token = next_token
|
self.next_token = next_token
|
||||||
self.next_start_pos = next_start_pos
|
self._next_start_pos = next_start_pos
|
||||||
|
|
||||||
|
@property
|
||||||
|
def next_start_pos(self):
|
||||||
|
s = self._next_start_pos
|
||||||
|
return s[0] + self._position_modifier.line, s[1]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def first_pos(self):
|
def first_pos(self):
|
||||||
@@ -292,7 +298,7 @@ class Parser(object):
|
|||||||
if nodes and nodes[0] in ('def', 'class', 'lambda'):
|
if nodes and nodes[0] in ('def', 'class', 'lambda'):
|
||||||
self.scope_names_stack.pop()
|
self.scope_names_stack.pop()
|
||||||
if failed_stack:
|
if failed_stack:
|
||||||
err = ErrorStatement(failed_stack, value, start_pos)
|
err = ErrorStatement(failed_stack, value, self.position_modifier, start_pos)
|
||||||
self.error_statement_stacks.append(err)
|
self.error_statement_stacks.append(err)
|
||||||
|
|
||||||
self._last_failed_start_pos = start_pos
|
self._last_failed_start_pos = start_pos
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ class FastParser(use_metaclass(CachedFastParser)):
|
|||||||
return self._get_node(unicode(''), unicode(''), 0, [], False)
|
return self._get_node(unicode(''), unicode(''), 0, [], False)
|
||||||
|
|
||||||
added_newline = False
|
added_newline = False
|
||||||
if source[-1] != '\n':
|
if not source or source[-1] != '\n':
|
||||||
# To be compatible with Pythons grammar, we need a newline at the
|
# To be compatible with Pythons grammar, we need a newline at the
|
||||||
# end. The parser would handle it, but since the fast parser abuses
|
# end. The parser would handle it, but since the fast parser abuses
|
||||||
# the normal parser in various ways, we need to care for this
|
# the normal parser in various ways, we need to care for this
|
||||||
|
|||||||
Reference in New Issue
Block a user