From abb8d0e26c18a7965da89f0d99bde581e4256c2f Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 23 Oct 2014 01:06:50 +0200 Subject: [PATCH] get_names_dict removed and use instead the names_dict attribute. --- jedi/evaluate/representation.py | 11 ++++++----- jedi/parser/representation.py | 14 ++++---------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index 183de9ca..0eb5be6d 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -165,10 +165,10 @@ class Instance(use_metaclass(CachedMetaClass, Executed)): # because to follow them and their self variables is too # complicated. sub = self._get_method_execution(sub) - print(sub.get_names_dict().values()) - for per_name_list in sub.get_names_dict().values(): + print(sub.names_dict.values()) + for per_name_list in sub.names_dict.values(): for call in per_name_list: - if unicode(call.name) == self_name \ + if name.value == self_name \ and isinstance(call.next, pr.Call) \ and call.next.next is None: names.append(get_instance_el(self._evaluator, self, call.next.name)) @@ -591,9 +591,10 @@ class FunctionExecution(Executed): break return types + @property @underscore_memoization - def get_names_dict(self): - return LazyDict(self.base.get_names_dict(), self._copy_list) + def names_dict(self): + return LazyDict(self.base.names_dict, self._copy_list) @memoize_default(default=()) def _get_params(self): diff --git a/jedi/parser/representation.py b/jedi/parser/representation.py index ac849b2b..8e33b154 100644 --- a/jedi/parser/representation.py +++ b/jedi/parser/representation.py @@ -408,15 +408,14 @@ class Scope(Simple, DocstringMixin): :param start_pos: The position (line and column) of the scope. :type start_pos: tuple(int, int) """ - __slots__ = ('imports', '_doc_token', 'asserts', - 'is_generator', '_names_dict') + __slots__ = ('imports', '_doc_token', 'asserts', 'names_dict', + 'is_generator') def __init__(self, children): super(Scope, self).__init__(children) self.imports = [] self._doc_token = None self.asserts = [] - self._names_dict = defaultdict(_return_empty_list) self.is_generator = False @property @@ -450,13 +449,6 @@ class Scope(Simple, DocstringMixin): def is_scope(self): 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): sub.parent = self.use_as_parent sub.decorators = decorators @@ -661,6 +653,8 @@ class SubModule(Scope, Module): class ClassOrFunc(Scope): + __slots__ = () + @property def name(self): return self.children[1]