Functions are not exceptions anymore in the name finder.

This commit is contained in:
Dave Halter
2015-01-08 14:14:01 +01:00
parent 0dc61292b9
commit 47fc3cbdfe
3 changed files with 5 additions and 10 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ class Evaluator(object):
f = finder.NameFinder(self, scope, name_str, position) f = finder.NameFinder(self, scope, name_str, position)
scopes = f.scopes(search_global) scopes = f.scopes(search_global)
if is_goto: if is_goto:
return f.filter_name(scopes, search_global) return f.filter_name(scopes)
return f.find(scopes, search_global) return f.find(scopes, search_global)
@memoize_default(default=[], evaluator_is_first_arg=True) @memoize_default(default=[], evaluator_is_first_arg=True)
+2 -8
View File
@@ -15,7 +15,6 @@ from itertools import chain
from jedi._compatibility import unicode, u from jedi._compatibility import unicode, u
from jedi.parser import tree as pr from jedi.parser import tree as pr
from jedi.parser import fast
from jedi import debug from jedi import debug
from jedi import common from jedi import common
from jedi import settings from jedi import settings
@@ -64,7 +63,7 @@ class NameFinder(object):
@debug.increase_indent @debug.increase_indent
def find(self, scopes, search_global=False): def find(self, scopes, search_global=False):
names = self.filter_name(scopes, search_global) names = self.filter_name(scopes)
types = self._names_to_types(names, search_global) types = self._names_to_types(names, search_global)
if not names and not types \ if not names and not types \
@@ -148,17 +147,12 @@ class NameFinder(object):
return [get_param(name_scope, n) for n in last_names] return [get_param(name_scope, n) for n in last_names]
return last_names return last_names
def filter_name(self, names_dicts, search_global=False): def filter_name(self, names_dicts):
""" """
Searches names that are defined in a scope (the different Searches names that are defined in a scope (the different
`names_dicts`), until a name fits. `names_dicts`), until a name fits.
""" """
names = [] names = []
self.maybe_descriptor = isinstance(self.scope, er.Class)
if not search_global and self.scope.isinstance(er.Function):
return [n for n in self.scope.get_magic_function_names()
if str(n) == str(self.name_str)]
for names_dict, position in names_dicts: for names_dict, position in names_dicts:
names = self.names_dict_lookup(names_dict, position) names = self.names_dict_lookup(names_dict, position)
if names: if names:
+2 -1
View File
@@ -572,7 +572,8 @@ class Function(use_metaclass(CachedMetaClass, Wrapper)):
if search_global: if search_global:
yield self.names_dict yield self.names_dict
else: else:
raise NotImplementedError for names_dict in compiled.magic_function_class.names_dicts(False):
yield names_dict
def get_magic_function_names(self): def get_magic_function_names(self):
return compiled.magic_function_class.get_defined_names() return compiled.magic_function_class.get_defined_names()