mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
Don't use stub_to_python_context_set anymore
This commit is contained in:
@@ -11,7 +11,7 @@ from jedi.evaluate import imports
|
|||||||
from jedi.api import keywords
|
from jedi.api import keywords
|
||||||
from jedi.evaluate.helpers import evaluate_call_of_leaf, parse_dotted_names
|
from jedi.evaluate.helpers import evaluate_call_of_leaf, parse_dotted_names
|
||||||
from jedi.evaluate.filters import get_global_filters
|
from jedi.evaluate.filters import get_global_filters
|
||||||
from jedi.evaluate.gradual.conversion import stub_to_python_context_set
|
from jedi.evaluate.gradual.conversion import convert_contexts
|
||||||
from jedi.parser_utils import get_statement_of_position
|
from jedi.parser_utils import get_statement_of_position
|
||||||
|
|
||||||
|
|
||||||
@@ -246,12 +246,9 @@ class Completion:
|
|||||||
origin_scope=user_context.tree_node):
|
origin_scope=user_context.tree_node):
|
||||||
completion_names += filter.values()
|
completion_names += filter.values()
|
||||||
|
|
||||||
for context in contexts:
|
python_contexts = convert_contexts(contexts)
|
||||||
if not context.is_stub():
|
for c in python_contexts:
|
||||||
continue
|
if c not in contexts:
|
||||||
|
|
||||||
actual_contexts = stub_to_python_context_set(context, ignore_compiled=True)
|
|
||||||
for c in actual_contexts:
|
|
||||||
for filter in c.get_filters(
|
for filter in c.get_filters(
|
||||||
search_global=False,
|
search_global=False,
|
||||||
origin_scope=user_context.tree_node):
|
origin_scope=user_context.tree_node):
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ from jedi.evaluate.filters import get_global_filters
|
|||||||
from jedi.evaluate.names import TreeNameDefinition
|
from jedi.evaluate.names import TreeNameDefinition
|
||||||
from jedi.evaluate.base_context import ContextSet, NO_CONTEXTS
|
from jedi.evaluate.base_context import ContextSet, NO_CONTEXTS
|
||||||
from jedi.parser_utils import is_scope, get_parent_scope
|
from jedi.parser_utils import is_scope, get_parent_scope
|
||||||
from jedi.evaluate.gradual.conversion import stub_to_python_context_set
|
from jedi.evaluate.gradual.conversion import convert_contexts
|
||||||
|
|
||||||
|
|
||||||
class NameFinder(object):
|
class NameFinder(object):
|
||||||
@@ -123,8 +123,7 @@ class NameFinder(object):
|
|||||||
yield f
|
yield f
|
||||||
# This covers the case where a stub files are incomplete.
|
# This covers the case where a stub files are incomplete.
|
||||||
if self._context.is_stub():
|
if self._context.is_stub():
|
||||||
contexts = stub_to_python_context_set(self._context, ignore_compiled=True)
|
for c in convert_contexts(ContextSet({self._context})):
|
||||||
for c in contexts:
|
|
||||||
for f in c.get_filters():
|
for f in c.get_filters():
|
||||||
yield f
|
yield f
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from jedi.evaluate.utils import to_list
|
|||||||
from jedi.evaluate.gradual.stub_context import StubModuleContext
|
from jedi.evaluate.gradual.stub_context import StubModuleContext
|
||||||
|
|
||||||
|
|
||||||
def stub_to_python_context_set(stub_context, ignore_compiled=False):
|
def _stub_to_python_context_set(stub_context, ignore_compiled=False):
|
||||||
stub_module = stub_context.get_root_context()
|
stub_module = stub_context.get_root_context()
|
||||||
if not stub_module.is_stub():
|
if not stub_module.is_stub():
|
||||||
return ContextSet([stub_context])
|
return ContextSet([stub_context])
|
||||||
@@ -146,7 +146,7 @@ def convert_contexts(contexts, only_stubs=False, prefer_stubs=False, ignore_comp
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return ContextSet.from_sets(
|
return ContextSet.from_sets(
|
||||||
stub_to_python_context_set(stub_context, ignore_compiled=ignore_compiled)
|
_stub_to_python_context_set(stub_context, ignore_compiled=ignore_compiled)
|
||||||
or ContextSet({stub_context})
|
or ContextSet({stub_context})
|
||||||
for stub_context in contexts
|
for stub_context in contexts
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -356,12 +356,9 @@ class Importer(object):
|
|||||||
names += context.sub_modules_dict().values()
|
names += context.sub_modules_dict().values()
|
||||||
|
|
||||||
if not only_modules:
|
if not only_modules:
|
||||||
from jedi.evaluate.gradual.conversion import stub_to_python_context_set
|
from jedi.evaluate.gradual.conversion import convert_contexts
|
||||||
both_contexts = ContextSet.from_sets(
|
|
||||||
stub_to_python_context_set(context, ignore_compiled=True)
|
both_contexts = contexts | convert_contexts(contexts)
|
||||||
for context in contexts
|
|
||||||
if context.is_stub()
|
|
||||||
) | contexts
|
|
||||||
for c in both_contexts:
|
for c in both_contexts:
|
||||||
for filter in c.get_filters(search_global=False):
|
for filter in c.get_filters(search_global=False):
|
||||||
names += filter.values()
|
names += filter.values()
|
||||||
|
|||||||
Reference in New Issue
Block a user