1
0
forked from VimPlug/jedi

By trying to get rid of search_name in usages, we had to fix an issue with imports:

If used like 'follow(is_goto)', it could return a ModuleWrapper instead of a Name, which is what we actually want.
This commit is contained in:
Dave Halter
2014-09-03 19:30:00 +02:00
parent 59578966cf
commit 18204c4c19
5 changed files with 25 additions and 13 deletions

View File

@@ -502,17 +502,24 @@ class Script(object):
try:
user_stmt = self._parser.user_stmt()
definitions, search_name = self._goto(add_import_name=True)
if not definitions:
# Without a definition for a name we cannot find references.
return []
# Once Script._goto works correct, we can probably remove this
# branch.
if isinstance(user_stmt, pr.Statement):
c = user_stmt.expression_list()[0]
if not isinstance(c, unicode) and self._pos < c.start_pos:
# the search_name might be before `=`
# The lookup might be before `=`
definitions = [v for v in user_stmt.get_defined_names()
if unicode(v.names[-1]) == search_name]
if unicode(v.names[-1]) ==
list(definitions)[0].get_code()]
if not isinstance(user_stmt, pr.Import):
# import case is looked at with add_import_name option
definitions = usages.usages_add_import_modules(self._evaluator,
definitions,
search_name)
definitions)
module = set([d.get_parent_until() for d in definitions])
module.add(self._parser.module())