forked from VimPlug/jedi
Fix call signatures, use stubs if possible
This commit is contained in:
@@ -373,6 +373,8 @@ class Script(object):
|
|||||||
)
|
)
|
||||||
debug.speed('func_call followed')
|
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,
|
return [classes.CallSignature(self._evaluator, signature,
|
||||||
call_signature_details.bracket_leaf.start_pos,
|
call_signature_details.bracket_leaf.start_pos,
|
||||||
call_signature_details.call_index,
|
call_signature_details.call_index,
|
||||||
|
|||||||
@@ -136,11 +136,14 @@ 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':
|
if leaf.type == 'name':
|
||||||
# In case of a name we can just use goto_definition which does all the
|
# In case of a name we can just use goto_definition which does all the
|
||||||
# magic itself.
|
# magic itself.
|
||||||
return evaluator.goto_definitions(context, leaf)
|
if prefer_stubs:
|
||||||
|
return evaluator.goto_stub_definitions(context, leaf)
|
||||||
|
else:
|
||||||
|
return evaluator.goto_definitions(context, leaf)
|
||||||
|
|
||||||
parent = leaf.parent
|
parent = leaf.parent
|
||||||
if parent.type == 'atom':
|
if parent.type == 'atom':
|
||||||
@@ -256,5 +259,6 @@ def cache_call_signatures(evaluator, context, bracket_leaf, code_lines, user_pos
|
|||||||
yield evaluate_goto_definition(
|
yield evaluate_goto_definition(
|
||||||
evaluator,
|
evaluator,
|
||||||
context,
|
context,
|
||||||
bracket_leaf.get_previous_leaf()
|
bracket_leaf.get_previous_leaf(),
|
||||||
|
prefer_stubs=True,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -263,11 +263,11 @@ class Evaluator(object):
|
|||||||
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.
|
# We don't want stubs here we want the actual contexts, if possible.
|
||||||
return try_stubs_to_actual_context_set(
|
return try_stubs_to_actual_context_set(
|
||||||
self._goto_definitions(context, name),
|
self.goto_stub_definitions(context, name),
|
||||||
prefer_stub_to_compiled=True
|
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)
|
def_ = name.get_definition(import_name_always=True)
|
||||||
if def_ is not None:
|
if def_ is not None:
|
||||||
type_ = def_.type
|
type_ = def_.type
|
||||||
|
|||||||
Reference in New Issue
Block a user