mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Don't goto while building found_names for the current file
But goto for all non_matching_reference_maps items later
This commit is contained in:
@@ -166,6 +166,8 @@ class AbstractTreeName(AbstractNameDefinition):
|
|||||||
node_type = par.type
|
node_type = par.type
|
||||||
if node_type == 'argument' and par.children[1] == '=' and par.children[0] == name:
|
if node_type == 'argument' and par.children[1] == '=' and par.children[0] == name:
|
||||||
# Named param goto.
|
# Named param goto.
|
||||||
|
if not all_scopes:
|
||||||
|
return [self]
|
||||||
trailer = par.parent
|
trailer = par.parent
|
||||||
if trailer.type == 'arglist':
|
if trailer.type == 'arglist':
|
||||||
trailer = trailer.parent
|
trailer = trailer.parent
|
||||||
@@ -200,6 +202,8 @@ class AbstractTreeName(AbstractNameDefinition):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if node_type == 'trailer' and par.children[0] == '.':
|
if node_type == 'trailer' and par.children[0] == '.':
|
||||||
|
if not all_scopes:
|
||||||
|
return [self]
|
||||||
values = infer_call_of_leaf(context, name, cut_own_trailer=True)
|
values = infer_call_of_leaf(context, name, cut_own_trailer=True)
|
||||||
return values.goto(name, name_context=context)
|
return values.goto(name, name_context=context)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -144,6 +144,11 @@ def find_references(module_context, tree_name, all_scopes=True):
|
|||||||
search_name,
|
search_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
gotos = set()
|
||||||
|
if not all_scopes:
|
||||||
|
for name in found_names_dct.values():
|
||||||
|
gotos |= set(name.goto())
|
||||||
|
|
||||||
non_matching_reference_maps = {}
|
non_matching_reference_maps = {}
|
||||||
for module_context in potential_modules:
|
for module_context in potential_modules:
|
||||||
for name_leaf in module_context.tree_node.get_used_names().get(search_name, []):
|
for name_leaf in module_context.tree_node.get_used_names().get(search_name, []):
|
||||||
@@ -162,6 +167,18 @@ def find_references(module_context, tree_name, all_scopes=True):
|
|||||||
else:
|
else:
|
||||||
for name in new:
|
for name in new:
|
||||||
non_matching_reference_maps.setdefault(name, []).append(new)
|
non_matching_reference_maps.setdefault(name, []).append(new)
|
||||||
|
|
||||||
|
if not all_scopes:
|
||||||
|
def in_gotos(g):
|
||||||
|
for g_ in gotos:
|
||||||
|
if g.start_pos == g_.start_pos and g.get_root_context() == g_.get_root_context():
|
||||||
|
return True
|
||||||
|
|
||||||
|
for dct_list in non_matching_reference_maps.values():
|
||||||
|
for dct in dct_list:
|
||||||
|
for k, v in dct.items():
|
||||||
|
if any(in_gotos(g) for g in v.goto()):
|
||||||
|
found_names_dct[k] = v
|
||||||
return found_names_dct.values()
|
return found_names_dct.values()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user