forked from VimPlug/jedi
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.filters import ParserTreeFilter
|
||||
from jedi.inference.gradual.conversion import convert_names
|
||||
|
||||
|
||||
def _resolve_names(definition_names, avoid_names=()):
|
||||
@@ -29,6 +30,14 @@ def _dictionarize(names):
|
||||
def _find_defining_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))
|
||||
for name in list(found_names):
|
||||
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):
|
||||
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)
|
||||
self.correct = self.correct.strip()
|
||||
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
|
||||
)
|
||||
wanted = []
|
||||
|
||||
Reference in New Issue
Block a user