mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Move trying to resolve stubs to a different place
This commit is contained in:
@@ -253,8 +253,6 @@ class Script(object):
|
|||||||
|
|
||||||
context = self._evaluator.create_context(self._get_module(), leaf)
|
context = self._evaluator.create_context(self._get_module(), leaf)
|
||||||
definitions = helpers.evaluate_goto_definition(self._evaluator, context, leaf)
|
definitions = helpers.evaluate_goto_definition(self._evaluator, context, leaf)
|
||||||
# We don't want stubs here we want the actual contexts, if possible.
|
|
||||||
definitions = try_stubs_to_actual_context_set(definitions, prefer_stub_to_compiled=True)
|
|
||||||
|
|
||||||
names = [s.name for s in definitions]
|
names = [s.name for s in definitions]
|
||||||
defs = [classes.Definition(self._evaluator, name) for name in names]
|
defs = [classes.Definition(self._evaluator, name) for name in names]
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ from jedi.evaluate.context.iterable import CompForContext
|
|||||||
from jedi.evaluate.syntax_tree import eval_trailer, eval_expr_stmt, \
|
from jedi.evaluate.syntax_tree import eval_trailer, eval_expr_stmt, \
|
||||||
eval_node, check_tuple_assignments
|
eval_node, check_tuple_assignments
|
||||||
from jedi.evaluate.gradual.conversion import try_stub_to_actual_names, \
|
from jedi.evaluate.gradual.conversion import try_stub_to_actual_names, \
|
||||||
stub_to_actual_context_set
|
try_stubs_to_actual_context_set
|
||||||
|
|
||||||
|
|
||||||
def _execute(context, arguments):
|
def _execute(context, arguments):
|
||||||
@@ -261,6 +261,13 @@ class Evaluator(object):
|
|||||||
return eval_node(context, element)
|
return eval_node(context, element)
|
||||||
|
|
||||||
def goto_definitions(self, context, name):
|
def goto_definitions(self, context, name):
|
||||||
|
# We don't want stubs here we want the actual contexts, if possible.
|
||||||
|
return try_stubs_to_actual_context_set(
|
||||||
|
self._goto_definitions(context, name),
|
||||||
|
prefer_stub_to_compiled=True
|
||||||
|
)
|
||||||
|
|
||||||
|
def _goto_definitions(self, context, name):
|
||||||
def_ = name.get_definition(import_name_always=True)
|
def_ = name.get_definition(import_name_always=True)
|
||||||
if def_ is not None:
|
if def_ is not None:
|
||||||
type_ = def_.type
|
type_ = def_.type
|
||||||
@@ -270,10 +277,7 @@ class Evaluator(object):
|
|||||||
c = ClassContext(self, context, name.parent)
|
c = ClassContext(self, context, name.parent)
|
||||||
else:
|
else:
|
||||||
c = FunctionContext.from_context(context, name.parent)
|
c = FunctionContext.from_context(context, name.parent)
|
||||||
if context.is_stub():
|
return ContextSet([c])
|
||||||
return stub_to_actual_context_set(c)
|
|
||||||
else:
|
|
||||||
return ContextSet([c])
|
|
||||||
|
|
||||||
if type_ == 'expr_stmt':
|
if type_ == 'expr_stmt':
|
||||||
is_simple_name = name.parent.type not in ('power', 'trailer')
|
is_simple_name = name.parent.type not in ('power', 'trailer')
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ from jedi.api.classes import Definition
|
|||||||
from jedi.api.completion import get_user_scope
|
from jedi.api.completion import get_user_scope
|
||||||
from jedi import parser_utils
|
from jedi import parser_utils
|
||||||
from jedi.api.environment import get_default_environment, get_system_environment
|
from jedi.api.environment import get_default_environment, get_system_environment
|
||||||
|
from jedi.evaluate.gradual.conversion import try_stubs_to_actual_context_set
|
||||||
|
|
||||||
|
|
||||||
TEST_COMPLETIONS = 0
|
TEST_COMPLETIONS = 0
|
||||||
@@ -230,7 +231,10 @@ class IntegrationTestCase(object):
|
|||||||
if user_context.api_type == 'function':
|
if user_context.api_type == 'function':
|
||||||
user_context = user_context.get_function_execution()
|
user_context = user_context.get_function_execution()
|
||||||
element.parent = user_context.tree_node
|
element.parent = user_context.tree_node
|
||||||
results = evaluator.eval_element(user_context, element)
|
results = try_stubs_to_actual_context_set(
|
||||||
|
evaluator.eval_element(user_context, element),
|
||||||
|
prefer_stub_to_compiled=True
|
||||||
|
)
|
||||||
if not results:
|
if not results:
|
||||||
raise Exception('Could not resolve %s on line %s'
|
raise Exception('Could not resolve %s on line %s'
|
||||||
% (match.string, self.line_nr - 1))
|
% (match.string, self.line_nr - 1))
|
||||||
|
|||||||
Reference in New Issue
Block a user