forked from VimPlug/jedi
Try to get some more stub to definitions working and vice versa
This commit is contained in:
@@ -85,7 +85,8 @@ from jedi.evaluate.context.iterable import CompForContext
|
||||
from jedi.evaluate.syntax_tree import eval_trailer, eval_expr_stmt, \
|
||||
eval_node, check_tuple_assignments
|
||||
from jedi.evaluate.gradual.stub_context import with_stub_context_if_possible, \
|
||||
stub_to_actual_context_set, goto_with_stubs_if_possible, goto_non_stub
|
||||
stub_to_actual_context_set, goto_with_stubs_if_possible, goto_non_stub, \
|
||||
stubify
|
||||
|
||||
|
||||
def _execute(context, arguments):
|
||||
@@ -443,6 +444,7 @@ class Evaluator(object):
|
||||
cls = FunctionContext
|
||||
|
||||
func = cls.from_context(parent_context, scope_node)
|
||||
func = next(iter(stubify(func)))
|
||||
|
||||
if parent_was_class:
|
||||
func = BoundMethod(
|
||||
@@ -453,7 +455,10 @@ class Evaluator(object):
|
||||
return func.get_function_execution()
|
||||
return func
|
||||
elif scope_node.type == 'classdef':
|
||||
return ClassContext(self, parent_context, scope_node)
|
||||
return next(iter(stubify(
|
||||
parent_context,
|
||||
ClassContext(self, parent_context, scope_node)
|
||||
)))
|
||||
elif scope_node.type == 'comp_for':
|
||||
if node.start_pos >= scope_node.children[-1].start_pos:
|
||||
return parent_context
|
||||
|
||||
@@ -315,12 +315,23 @@ def stub_to_actual_context_set(stub_context):
|
||||
|
||||
stub_only_module = stub_context.get_root_context()
|
||||
assert isinstance(stub_only_module, StubOnlyModuleContext), stub_only_module
|
||||
non_stubs = stub_only_module.non_stub_context_set
|
||||
non_stubs = stub_only_module.get_stub_contexts()
|
||||
for name in qualified_names:
|
||||
non_stubs = non_stubs.py__getattribute__(name)
|
||||
return non_stubs
|
||||
|
||||
|
||||
def stubify(parent_context, context):
|
||||
if parent_context.is_stub():
|
||||
return ContextSet(
|
||||
c.stub_context
|
||||
for c in stub_to_actual_context_set(context)
|
||||
if c.stub_context is not None
|
||||
) or ContextSet([context])
|
||||
else:
|
||||
return with_stub_context_if_possible(context)
|
||||
|
||||
|
||||
class CompiledStubName(NameWrapper):
|
||||
def __init__(self, parent_context, compiled_name, stub_name):
|
||||
super(CompiledStubName, self).__init__(stub_name)
|
||||
|
||||
Reference in New Issue
Block a user