forked from VimPlug/jedi
Care for nested imports in goto_assignments.
This commit is contained in:
@@ -326,7 +326,8 @@ class Evaluator(object):
|
|||||||
names = stmt.get_all_import_names()
|
names = stmt.get_all_import_names()
|
||||||
# Filter names that are after our Name
|
# Filter names that are after our Name
|
||||||
removed_names = len(names) - names.index(call_path[0]) - 1
|
removed_names = len(names) - names.index(call_path[0]) - 1
|
||||||
i = imports.ImportWrapper(self, stmt, kill_count=removed_names)
|
i = imports.ImportWrapper(self, stmt, kill_count=removed_names,
|
||||||
|
nested_resolve=True)
|
||||||
return i.follow(is_goto=True)
|
return i.follow(is_goto=True)
|
||||||
|
|
||||||
# Return the name defined in the call_path, if it's part of the
|
# Return the name defined in the call_path, if it's part of the
|
||||||
|
|||||||
@@ -278,3 +278,11 @@ class TestGotoAssignments(TestCase):
|
|||||||
n = nms[2].goto_assignments()[0]
|
n = nms[2].goto_assignments()[0]
|
||||||
assert n.name == 'path'
|
assert n.name == 'path'
|
||||||
assert n.type == 'import'
|
assert n.type == 'import'
|
||||||
|
|
||||||
|
nms = names('import os.path', references=True)
|
||||||
|
n = nms[0].goto_assignments()[0]
|
||||||
|
assert n.name == 'os'
|
||||||
|
assert n.type == 'module'
|
||||||
|
n = nms[1].goto_assignments()[0]
|
||||||
|
assert n.name == 'path'
|
||||||
|
assert n.type == 'import'
|
||||||
|
|||||||
Reference in New Issue
Block a user