1
0
forked from VimPlug/jedi

Better goto for imports, which helps usages.

This commit is contained in:
Dave Halter
2014-12-03 16:15:31 +01:00
parent 536c188192
commit 6bf154de5e
5 changed files with 27 additions and 16 deletions

View File

@@ -503,7 +503,7 @@ class Script(object):
import_name = user_stmt.get_defined_names()
# imports have only one name
np = import_name[0]
if not user_stmt.star and unicode(name_part) == unicode(np):
if not user_stmt.is_star_import() and unicode(name_part) == unicode(np):
definitions.append(np)
else:
# The Evaluator.goto function checks for definitions, but since we
@@ -549,12 +549,7 @@ class Script(object):
names = usages.usages(self._evaluator, definitions, module)
for d in set(definitions):
try:
name_part = d.names[-1]
except AttributeError:
names.append(classes.Definition(self._evaluator, d))
else:
names.append(classes.Definition(self._evaluator, name_part))
names.append(classes.Definition(self._evaluator, d))
finally:
settings.dynamic_flow_information = temp

View File

@@ -1,5 +1,4 @@
from jedi._compatibility import u, unicode
from jedi import common
from jedi.api import classes
from jedi.parser import tree as pr
from jedi.evaluate import imports
@@ -101,7 +100,6 @@ def usages_add_import_modules(evaluator, definitions):
for d in definitions:
imp_or_stmt = d.get_definition()
if isinstance(imp_or_stmt, pr.Import):
s = imports.ImportWrapper(evaluator, imp_or_stmt, nested_resolve=True)
with common.ignored(IndexError):
new.add(s.follow(is_goto=True)[0])
s = imports.ImportWrapper(evaluator, d)
new |= s.follow(is_goto=True)
return set(definitions) | new