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):
|
||||
non_flow = self._definition.parent
|
||||
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)
|
||||
return Definition(self._evaluator, non_flow)
|
||||
|
||||
|
||||
@@ -220,13 +220,12 @@ class Evaluator(object):
|
||||
"""Follow a call is following a function, variable, string, etc."""
|
||||
path = call.generate_call_path()
|
||||
|
||||
# TODO use scope_parent
|
||||
# find the statement of the Scope
|
||||
s = call
|
||||
while not s.parent.is_scope():
|
||||
s = s.parent
|
||||
par = s.parent
|
||||
return self.eval_call_path(path, par, s.start_pos)
|
||||
scope = s.parent
|
||||
return self.eval_call_path(path, scope, s.start_pos)
|
||||
|
||||
def eval_call_path(self, path, scope, position):
|
||||
"""
|
||||
|
||||
@@ -140,11 +140,11 @@ class Base(object):
|
||||
scope = scope.parent
|
||||
return scope
|
||||
|
||||
def get_parent_scope(self, include_current=True):
|
||||
def get_parent_scope(self):
|
||||
"""
|
||||
Returns the underlying scope.
|
||||
"""
|
||||
scope = self if include_current else self.parent
|
||||
scope = self.parent
|
||||
while scope.parent is not None:
|
||||
if scope.is_scope():
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user