forked from VimPlug/jedi
A move function for Nodes.
This commit is contained in:
@@ -264,7 +264,9 @@ class Script(object):
|
||||
# goto_definition returns definitions of its statements if the
|
||||
# cursor is on the assignee. By changing the start_pos of our
|
||||
# "pseudo" statement, the Jedi evaluator can find the assignees.
|
||||
if user_stmt is not None:
|
||||
|
||||
# TODO remove?
|
||||
if False and user_stmt is not None:
|
||||
eval_stmt.start_pos = user_stmt.end_pos
|
||||
scopes = self._evaluator.eval_statement(eval_stmt)
|
||||
|
||||
@@ -291,10 +293,7 @@ class Script(object):
|
||||
else:
|
||||
pos = user_stmt.start_pos
|
||||
|
||||
child = stmt
|
||||
while hasattr(child, 'children'):
|
||||
child = child.children[0]
|
||||
child.start_pos = pos
|
||||
stmt.move(pos[0] - 1, pos[1])
|
||||
stmt.parent = self._parser.user_scope()
|
||||
return stmt
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ class ModuleNotFound(Exception):
|
||||
|
||||
|
||||
class ImportWrapper():
|
||||
GlobalNamespace = 'TODO PLEASE DELETE ME'
|
||||
def __init__(self, evaluator, name):
|
||||
self._evaluator = evaluator
|
||||
self._name = name
|
||||
|
||||
@@ -286,6 +286,17 @@ class Simple(Base):
|
||||
self.children = children
|
||||
self.parent = None
|
||||
|
||||
def move(self, line_offset, column_offset):
|
||||
"""
|
||||
Move the Node's start_pos.
|
||||
"""
|
||||
for c in self.children:
|
||||
if isinstance(c, _Leaf):
|
||||
c.start_pos = (c.start_pos[0] + line_offset,
|
||||
c.start_pos[1] + column_offset)
|
||||
else:
|
||||
c.move(line_offset, column_offset)
|
||||
|
||||
@property
|
||||
def start_pos(self):
|
||||
return self.children[0].start_pos
|
||||
|
||||
Reference in New Issue
Block a user