1
0
forked from VimPlug/jedi

Add a temporary api._names, to make it possible to annotate a full script with types.

This commit is contained in:
Dave Halter
2014-09-01 18:10:40 +02:00
parent bbf1070ad9
commit be9e77d7d3
3 changed files with 26 additions and 1 deletions

View File

@@ -309,6 +309,19 @@ class BaseDefinition(object):
return '.'.join(path if path[0] else path[1:])
def goto_assignments(self):
if not isinstance(self._definition, pr.NamePart):
raise TypeError('Definition is not a NamePart.')
if self.type not in ('statement', 'import'):
# Functions, classes and modules are already fixed definitions, we
# cannot follow them anymore.
return [self]
stmt_or_imp = self._definition.parent.parent
names, _ = self._evaluator.goto(stmt_or_imp, [self._definition])
return [Definition(self._evaluator, n) for n in names]
@memoize_default()
def _follow_statements_imports(self):
"""