1
0
forked from VimPlug/jedi

get_names_dict removed and use instead the names_dict attribute.

This commit is contained in:
Dave Halter
2014-10-23 01:06:50 +02:00
parent 3bbce49fd3
commit abb8d0e26c
2 changed files with 10 additions and 15 deletions

View File

@@ -165,10 +165,10 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
# because to follow them and their self variables is too # because to follow them and their self variables is too
# complicated. # complicated.
sub = self._get_method_execution(sub) sub = self._get_method_execution(sub)
print(sub.get_names_dict().values()) print(sub.names_dict.values())
for per_name_list in sub.get_names_dict().values(): for per_name_list in sub.names_dict.values():
for call in per_name_list: for call in per_name_list:
if unicode(call.name) == self_name \ if name.value == self_name \
and isinstance(call.next, pr.Call) \ and isinstance(call.next, pr.Call) \
and call.next.next is None: and call.next.next is None:
names.append(get_instance_el(self._evaluator, self, call.next.name)) names.append(get_instance_el(self._evaluator, self, call.next.name))
@@ -591,9 +591,10 @@ class FunctionExecution(Executed):
break break
return types return types
@property
@underscore_memoization @underscore_memoization
def get_names_dict(self): def names_dict(self):
return LazyDict(self.base.get_names_dict(), self._copy_list) return LazyDict(self.base.names_dict, self._copy_list)
@memoize_default(default=()) @memoize_default(default=())
def _get_params(self): def _get_params(self):

View File

@@ -408,15 +408,14 @@ class Scope(Simple, DocstringMixin):
:param start_pos: The position (line and column) of the scope. :param start_pos: The position (line and column) of the scope.
:type start_pos: tuple(int, int) :type start_pos: tuple(int, int)
""" """
__slots__ = ('imports', '_doc_token', 'asserts', __slots__ = ('imports', '_doc_token', 'asserts', 'names_dict',
'is_generator', '_names_dict') 'is_generator')
def __init__(self, children): def __init__(self, children):
super(Scope, self).__init__(children) super(Scope, self).__init__(children)
self.imports = [] self.imports = []
self._doc_token = None self._doc_token = None
self.asserts = [] self.asserts = []
self._names_dict = defaultdict(_return_empty_list)
self.is_generator = False self.is_generator = False
@property @property
@@ -450,13 +449,6 @@ class Scope(Simple, DocstringMixin):
def is_scope(self): def is_scope(self):
return True return True
def add_name_calls(self, name, calls):
"""Add a name to the names_dict."""
self._names_dict[name] += calls
def get_names_dict(self):
return self._names_dict
def add_scope(self, sub, decorators): def add_scope(self, sub, decorators):
sub.parent = self.use_as_parent sub.parent = self.use_as_parent
sub.decorators = decorators sub.decorators = decorators
@@ -661,6 +653,8 @@ class SubModule(Scope, Module):
class ClassOrFunc(Scope): class ClassOrFunc(Scope):
__slots__ = ()
@property @property
def name(self): def name(self):
return self.children[1] return self.children[1]