forked from VimPlug/jedi
Simplify get_parent_scope
This commit is contained in:
@@ -360,7 +360,7 @@ class BaseDefinition(object):
|
|||||||
if isinstance(self._definition, compiled.CompiledObject):
|
if isinstance(self._definition, compiled.CompiledObject):
|
||||||
non_flow = self._definition.parent
|
non_flow = self._definition.parent
|
||||||
else:
|
else:
|
||||||
scope = self._definition.get_parent_scope(include_current=False)
|
scope = self._definition.get_parent_scope()
|
||||||
non_flow = scope.get_parent_until(pr.Flow, reverse=True)
|
non_flow = scope.get_parent_until(pr.Flow, reverse=True)
|
||||||
return Definition(self._evaluator, non_flow)
|
return Definition(self._evaluator, non_flow)
|
||||||
|
|
||||||
|
|||||||
@@ -220,13 +220,12 @@ class Evaluator(object):
|
|||||||
"""Follow a call is following a function, variable, string, etc."""
|
"""Follow a call is following a function, variable, string, etc."""
|
||||||
path = call.generate_call_path()
|
path = call.generate_call_path()
|
||||||
|
|
||||||
# TODO use scope_parent
|
|
||||||
# find the statement of the Scope
|
# find the statement of the Scope
|
||||||
s = call
|
s = call
|
||||||
while not s.parent.is_scope():
|
while not s.parent.is_scope():
|
||||||
s = s.parent
|
s = s.parent
|
||||||
par = s.parent
|
scope = s.parent
|
||||||
return self.eval_call_path(path, par, s.start_pos)
|
return self.eval_call_path(path, scope, s.start_pos)
|
||||||
|
|
||||||
def eval_call_path(self, path, scope, position):
|
def eval_call_path(self, path, scope, position):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -140,11 +140,11 @@ class Base(object):
|
|||||||
scope = scope.parent
|
scope = scope.parent
|
||||||
return scope
|
return scope
|
||||||
|
|
||||||
def get_parent_scope(self, include_current=True):
|
def get_parent_scope(self):
|
||||||
"""
|
"""
|
||||||
Returns the underlying scope.
|
Returns the underlying scope.
|
||||||
"""
|
"""
|
||||||
scope = self if include_current else self.parent
|
scope = self.parent
|
||||||
while scope.parent is not None:
|
while scope.parent is not None:
|
||||||
if scope.is_scope():
|
if scope.is_scope():
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user