forked from VimPlug/jedi
Remove 'move' from the parser tree.
This commit is contained in:
@@ -30,6 +30,7 @@ from jedi.evaluate import compiled
|
||||
from jedi.evaluate.context import LazyTreeContext
|
||||
from jedi import debug
|
||||
from jedi import _compatibility
|
||||
from jedi import parser_utils
|
||||
import re
|
||||
|
||||
|
||||
@@ -72,7 +73,7 @@ def _fix_forward_reference(context, node):
|
||||
return node
|
||||
else:
|
||||
module = node.get_root_node()
|
||||
new_node.move(module.end_pos[0])
|
||||
parser_utils.move(new_node, module.end_pos[0])
|
||||
new_node.parent = context.tree_node
|
||||
return new_node
|
||||
else:
|
||||
|
||||
@@ -115,9 +115,6 @@ class Leaf(_NodeOrLeaf):
|
||||
return self.line - self.prefix.count('\n'), 0 # It's the first leaf.
|
||||
return previous_leaf.end_pos
|
||||
|
||||
def move(self, line_offset):
|
||||
self.line += line_offset
|
||||
|
||||
def get_first_leaf(self):
|
||||
return self
|
||||
|
||||
@@ -173,13 +170,6 @@ class BaseNode(_NodeOrLeaf):
|
||||
self.children = children
|
||||
self.parent = None
|
||||
|
||||
def move(self, line_offset):
|
||||
"""
|
||||
Move the Node's start_pos.
|
||||
"""
|
||||
for c in self.children:
|
||||
c.move(line_offset)
|
||||
|
||||
@property
|
||||
def start_pos(self):
|
||||
return self.children[0].start_pos
|
||||
|
||||
@@ -175,3 +175,17 @@ def get_doc_with_call_signature(scope_node):
|
||||
if call_signature is None:
|
||||
return doc
|
||||
return '%s\n\n%s' % (call_signature, doc)
|
||||
|
||||
|
||||
def move(node, line_offset):
|
||||
"""
|
||||
Move the `Node` start_pos.
|
||||
"""
|
||||
try:
|
||||
children = node.children
|
||||
except AttributeError:
|
||||
node.line += line_offset
|
||||
else:
|
||||
for c in children:
|
||||
move(c, line_offset)
|
||||
|
||||
|
||||
@@ -123,6 +123,7 @@ from jedi._compatibility import unicode, is_py3
|
||||
from jedi.parser.python import parse
|
||||
from jedi.api.classes import Definition
|
||||
from jedi.api.completion import get_user_scope
|
||||
from jedi import parser_utils
|
||||
|
||||
|
||||
TEST_COMPLETIONS = 0
|
||||
@@ -188,7 +189,7 @@ class IntegrationTestCase(object):
|
||||
for match in re.finditer('(?:[^ ]+)', correct):
|
||||
string = match.group(0)
|
||||
parser = parse(string, start_symbol='eval_input', error_recovery=False)
|
||||
parser.get_root_node().move(self.line_nr)
|
||||
parser_utils.move(parser.get_root_node(), self.line_nr)
|
||||
element = parser.get_root_node()
|
||||
module_context = script._get_module()
|
||||
# The context shouldn't matter for the test results.
|
||||
|
||||
Reference in New Issue
Block a user