1
0
forked from VimPlug/jedi

Fix call signatures, use stubs if possible

This commit is contained in:
Dave Halter
2019-05-11 12:44:20 +02:00
parent 079783e3a1
commit 8b1d4a7824
3 changed files with 11 additions and 5 deletions

View File

@@ -373,6 +373,8 @@ class Script(object):
)
debug.speed('func_call followed')
# TODO here we use stubs instead of the actual contexts. We should use
# the signatures from stubs, but the actual contexts, probably?!
return [classes.CallSignature(self._evaluator, signature,
call_signature_details.bracket_leaf.start_pos,
call_signature_details.call_index,

View File

@@ -136,10 +136,13 @@ def get_stack_at_position(grammar, code_lines, module_node, pos):
)
def evaluate_goto_definition(evaluator, context, leaf):
def evaluate_goto_definition(evaluator, context, leaf, prefer_stubs=False):
if leaf.type == 'name':
# In case of a name we can just use goto_definition which does all the
# magic itself.
if prefer_stubs:
return evaluator.goto_stub_definitions(context, leaf)
else:
return evaluator.goto_definitions(context, leaf)
parent = leaf.parent
@@ -256,5 +259,6 @@ def cache_call_signatures(evaluator, context, bracket_leaf, code_lines, user_pos
yield evaluate_goto_definition(
evaluator,
context,
bracket_leaf.get_previous_leaf()
bracket_leaf.get_previous_leaf(),
prefer_stubs=True,
)

View File

@@ -263,11 +263,11 @@ class Evaluator(object):
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),
self.goto_stub_definitions(context, name),
prefer_stub_to_compiled=True
)
def _goto_definitions(self, context, name):
def goto_stub_definitions(self, context, name):
def_ = name.get_definition(import_name_always=True)
if def_ is not None:
type_ = def_.type