mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Make sure to find both stubs and non-stubs with usages
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from jedi.inference import imports
|
from jedi.inference import imports
|
||||||
from jedi.inference.filters import ParserTreeFilter
|
from jedi.inference.filters import ParserTreeFilter
|
||||||
|
from jedi.inference.gradual.conversion import convert_names
|
||||||
|
|
||||||
|
|
||||||
def _resolve_names(definition_names, avoid_names=()):
|
def _resolve_names(definition_names, avoid_names=()):
|
||||||
@@ -29,6 +30,14 @@ def _dictionarize(names):
|
|||||||
def _find_defining_names(module_context, tree_name):
|
def _find_defining_names(module_context, tree_name):
|
||||||
found_names = _find_names(module_context, tree_name)
|
found_names = _find_names(module_context, tree_name)
|
||||||
|
|
||||||
|
for name in list(found_names):
|
||||||
|
# Convert from/to stubs, because those might also be usages.
|
||||||
|
found_names |= set(convert_names(
|
||||||
|
[name],
|
||||||
|
only_stubs=not name.get_root_context().is_stub(),
|
||||||
|
prefer_stub_to_compiled=False
|
||||||
|
))
|
||||||
|
|
||||||
found_names |= set(_find_global_variables(found_names, tree_name.value))
|
found_names |= set(_find_global_variables(found_names, tree_name.value))
|
||||||
for name in list(found_names):
|
for name in list(found_names):
|
||||||
if name.api_type == 'param' or name.tree_name is None \
|
if name.api_type == 'param' or name.tree_name is None \
|
||||||
|
|||||||
@@ -349,3 +349,11 @@ class DefinitelyNotGlobal:
|
|||||||
def my_global(self):
|
def my_global(self):
|
||||||
def my_global(self):
|
def my_global(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# stubs
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
from stub_folder import with_stub
|
||||||
|
#< ('stub:stub_folder.with_stub', 5, 4), ('stub_folder.with_stub', 5, 4), (0, 10)
|
||||||
|
with_stub.stub_function
|
||||||
|
|||||||
@@ -265,7 +265,10 @@ class IntegrationTestCase(BaseTestCase):
|
|||||||
result = self.script(environment).find_references(self.line_nr, self.column)
|
result = self.script(environment).find_references(self.line_nr, self.column)
|
||||||
self.correct = self.correct.strip()
|
self.correct = self.correct.strip()
|
||||||
compare = sorted(
|
compare = sorted(
|
||||||
(re.sub(r'^test\.completion\.', '', r.module_name), r.line, r.column)
|
(('stub:' if r.is_stub() else '')
|
||||||
|
+ re.sub(r'^test\.completion\.', '', r.module_name),
|
||||||
|
r.line,
|
||||||
|
r.column)
|
||||||
for r in result
|
for r in result
|
||||||
)
|
)
|
||||||
wanted = []
|
wanted = []
|
||||||
|
|||||||
Reference in New Issue
Block a user