1
0
forked from VimPlug/jedi

start to get rid of the get_set_vars/get_defined_names distinction

This commit is contained in:
Dave Halter
2014-04-14 12:28:14 +02:00
parent 4c53a64ca0
commit 237af765b7
3 changed files with 7 additions and 14 deletions

View File

@@ -315,18 +315,9 @@ class Scope(Simple, IsScope, DocstringMixin):
... b.c = z
... '''))
>>> parser.module.get_defined_names()
[<Name: a@2,0>, <Name: b@3,0>]
Note that unlike :meth:`get_set_vars`, assignment to object
attribute does not change the result because it does not change
the defined names in this scope.
>>> parser.module.get_set_vars()
[<Name: a@2,0>, <Name: b@3,0>, <Name: b.c@4,0>]
"""
return [n for n in self.get_set_vars()
if isinstance(n, Import) or (len(n) == 1)]
return self.get_set_vars()
@Python3Method
def get_statement_for_position(self, pos, include_imports=False):
@@ -1433,10 +1424,11 @@ class Name(Simple):
def __init__(self, module, names, start_pos, end_pos, parent=None):
super(Name, self).__init__(module, start_pos, end_pos)
names = tuple(NamePart(n[0], self, n[1]) for n in names)
# Cache get_code, because it's used quite often for comparisons
# (seen by using the profiler).
self._get_code = ".".join(unicode(n) for n in names)
self._get_code = ".".join(n[0] for n in names)
names = tuple(NamePart(n[0], self, n[1]) for n in names)
self.names = names
if parent is not None:
self.parent = parent