mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
Goto_definitions bug fix -> imports stuff.
This commit is contained in:
@@ -268,8 +268,11 @@ class Script(object):
|
||||
return []
|
||||
|
||||
if isinstance(user_stmt, pr.Import):
|
||||
scopes = [helpers.get_on_import_stmt(self._evaluator, self._user_context,
|
||||
user_stmt, is_completion)[0]]
|
||||
i, _ = helpers.get_on_import_stmt(self._evaluator, self._user_context,
|
||||
user_stmt, is_completion)
|
||||
if i is None:
|
||||
return []
|
||||
scopes = [i]
|
||||
else:
|
||||
# just parse one statement, take it and evaluate it
|
||||
eval_stmt = self._get_under_cursor_stmt(goto_path)
|
||||
|
||||
@@ -28,7 +28,7 @@ def get_on_import_stmt(evaluator, user_context, user_stmt, is_like_search=False)
|
||||
"""
|
||||
name = user_stmt.name_for_position(user_context.position)
|
||||
if name is None:
|
||||
raise NotImplementedError
|
||||
return None, None
|
||||
|
||||
i = imports.ImportWrapper(evaluator, name)
|
||||
return i, name
|
||||
|
||||
@@ -108,6 +108,10 @@ def test_goto_assignments_on_non_name():
|
||||
assert api.Script('True').goto_assignments() == []
|
||||
|
||||
|
||||
def test_goto_definitions_on_non_name():
|
||||
assert api.Script('import x', column=0).goto_definitions() == []
|
||||
|
||||
|
||||
def test_goto_definition_not_multiple():
|
||||
"""
|
||||
There should be only one Definition result if it leads back to the same
|
||||
|
||||
Reference in New Issue
Block a user