forked from VimPlug/jedi
cleanup NameFinder.scopes, fully use scope_names_generator.
This commit is contained in:
+1
-12
@@ -66,18 +66,7 @@ class NameFinder(object):
|
|||||||
if search_global:
|
if search_global:
|
||||||
return get_names_of_scope(self._evaluator, self.scope, self.position)
|
return get_names_of_scope(self._evaluator, self.scope, self.position)
|
||||||
else:
|
else:
|
||||||
try:
|
return self.scope.scope_names_generator(self.position)
|
||||||
gen = self.scope.scope_names_generator
|
|
||||||
except AttributeError:
|
|
||||||
if isinstance(self.scope, er.Class):
|
|
||||||
# Classes don't have a positional limitation of their
|
|
||||||
# state. It's the whole class.
|
|
||||||
names = self.scope.get_defined_names()
|
|
||||||
else:
|
|
||||||
names = _get_defined_names_for_position(self.scope, self.position)
|
|
||||||
return iter([(self.scope, names)])
|
|
||||||
else:
|
|
||||||
return gen(self.position)
|
|
||||||
|
|
||||||
def filter_name(self, scope_names_generator):
|
def filter_name(self, scope_names_generator):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -705,6 +705,10 @@ class Flow(Scope):
|
|||||||
self.next.parent = self.parent
|
self.next.parent = self.parent
|
||||||
return next
|
return next
|
||||||
|
|
||||||
|
def scope_names_generator(self, position=None):
|
||||||
|
# For `with` and `for`.
|
||||||
|
yield self, filter_after_position(self.get_defined_names(), position)
|
||||||
|
|
||||||
|
|
||||||
class ForFlow(Flow):
|
class ForFlow(Flow):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user