forked from VimPlug/jedi
Fix an issue in the parse call.
This commit is contained in:
@@ -100,6 +100,7 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
|
||||
kwargs = dict(start_symbol=start_symbol)
|
||||
parser = Parser
|
||||
# TODO add recovery
|
||||
p = None
|
||||
if diff_cache:
|
||||
try:
|
||||
parser_cache_item = utils.parser_cache[path]
|
||||
@@ -111,12 +112,16 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
|
||||
new_node = DiffParser(p).update(lines)
|
||||
p._parsed = new_node
|
||||
utils.save_parser(grammar, path, p, pickling=False)
|
||||
if added_newline:
|
||||
p.source = code[:-1]
|
||||
_remove_last_newline(new_node)
|
||||
return new_node
|
||||
p = parser(grammar, code, start_parsing=False, **kwargs)
|
||||
module = p.parse(tokens=tokens)
|
||||
new_node = p.parse(tokens=tokens)
|
||||
if added_newline:
|
||||
_remove_last_newline(module)
|
||||
p.source = code[:-1]
|
||||
_remove_last_newline(new_node)
|
||||
|
||||
if use_cache or diff_cache:
|
||||
utils.save_parser(grammar, path, p)
|
||||
return module
|
||||
return new_node
|
||||
|
||||
@@ -206,10 +206,6 @@ class DiffParser(object):
|
||||
debug.speed('diff parser calculated')
|
||||
debug.dbg('diff: line_lengths old: %s, new: %s' % (len(lines_old), line_length))
|
||||
|
||||
if len(opcodes) == 1 and opcodes[0][0] == 'equal':
|
||||
self._copy_count = 1
|
||||
return self._module
|
||||
|
||||
for operation, i1, i2, j1, j2 in opcodes:
|
||||
debug.dbg('diff %s old[%s:%s] new[%s:%s]',
|
||||
operation, i1 + 1, i2, j1 + 1, j2)
|
||||
|
||||
Reference in New Issue
Block a user