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
|
# goto_definition returns definitions of its statements if the
|
||||||
# cursor is on the assignee. By changing the start_pos of our
|
# cursor is on the assignee. By changing the start_pos of our
|
||||||
# "pseudo" statement, the Jedi evaluator can find the assignees.
|
# "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
|
eval_stmt.start_pos = user_stmt.end_pos
|
||||||
scopes = self._evaluator.eval_statement(eval_stmt)
|
scopes = self._evaluator.eval_statement(eval_stmt)
|
||||||
|
|
||||||
@@ -291,10 +293,7 @@ class Script(object):
|
|||||||
else:
|
else:
|
||||||
pos = user_stmt.start_pos
|
pos = user_stmt.start_pos
|
||||||
|
|
||||||
child = stmt
|
stmt.move(pos[0] - 1, pos[1])
|
||||||
while hasattr(child, 'children'):
|
|
||||||
child = child.children[0]
|
|
||||||
child.start_pos = pos
|
|
||||||
stmt.parent = self._parser.user_scope()
|
stmt.parent = self._parser.user_scope()
|
||||||
return stmt
|
return stmt
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class ModuleNotFound(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class ImportWrapper():
|
class ImportWrapper():
|
||||||
|
GlobalNamespace = 'TODO PLEASE DELETE ME'
|
||||||
def __init__(self, evaluator, name):
|
def __init__(self, evaluator, name):
|
||||||
self._evaluator = evaluator
|
self._evaluator = evaluator
|
||||||
self._name = name
|
self._name = name
|
||||||
|
|||||||
@@ -286,6 +286,17 @@ class Simple(Base):
|
|||||||
self.children = children
|
self.children = children
|
||||||
self.parent = None
|
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
|
@property
|
||||||
def start_pos(self):
|
def start_pos(self):
|
||||||
return self.children[0].start_pos
|
return self.children[0].start_pos
|
||||||
|
|||||||
Reference in New Issue
Block a user