mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
Make separate methods for goto_import and infer_import
This commit is contained in:
@@ -308,7 +308,7 @@ class InferenceState(object):
|
||||
elif type_ == 'param':
|
||||
return [ParamName(context, name)]
|
||||
elif type_ in ('import_from', 'import_name'):
|
||||
module_names = imports.infer_import(context, name, is_goto=True)
|
||||
module_names = imports.goto_import(context, name)
|
||||
return module_names
|
||||
else:
|
||||
return [TreeNameDefinition(context, name)]
|
||||
|
||||
@@ -57,7 +57,16 @@ class ModuleCache(object):
|
||||
# This memoization is needed, because otherwise we will infinitely loop on
|
||||
# certain imports.
|
||||
@inference_state_method_cache(default=NO_VALUES)
|
||||
def infer_import(context, tree_name, is_goto=False):
|
||||
def infer_import(context, tree_name):
|
||||
return _infer_import(context, tree_name, is_goto=False)
|
||||
|
||||
|
||||
@inference_state_method_cache(default=[])
|
||||
def goto_import(context, tree_name):
|
||||
return _infer_import(context, tree_name, is_goto=True)
|
||||
|
||||
|
||||
def _infer_import(context, tree_name, is_goto=False):
|
||||
module_context = context.get_root_context()
|
||||
import_node = search_ancestor(tree_name, 'import_name', 'import_from')
|
||||
import_path = import_node.get_path_for_name(tree_name)
|
||||
|
||||
Reference in New Issue
Block a user