1
0
forked from VimPlug/jedi

Some progress in trying to make the deque work

This commit is contained in:
Dave Halter
2019-06-14 09:36:10 +02:00
parent 4564275eba
commit 3ed30409ea
5 changed files with 54 additions and 6 deletions
+12 -2
View File
@@ -9,11 +9,13 @@ from parso.python.parser import Parser
from parso.python import tree
from jedi._compatibility import u
from jedi.evaluate.base_context import NO_CONTEXTS
from jedi.evaluate.base_context import NO_CONTEXTS, ContextSet
from jedi.evaluate.syntax_tree import eval_atom
from jedi.evaluate.helpers import evaluate_call_of_leaf
from jedi.evaluate.compiled import get_string_context_set
from jedi.cache import call_signature_time_cache
from jedi.evaluate.gradual.conversion import convert_names
from jedi.evaluate.names import TreeNameDefinition
CompletionParts = namedtuple('CompletionParts', ['path', 'has_dot', 'name'])
@@ -141,15 +143,23 @@ def evaluate_goto_definition(evaluator, context, leaf):
if leaf.type == 'name':
# In case of a name we can just use goto_definition which does all the
# magic itself.
return evaluator.goto_definitions(context, leaf)
name = TreeNameDefinition(context, leaf)
if leaf.parent.type in ('trailer', 'error_node'):
return evaluator.goto_definitions(context, leaf)
return ContextSet.from_sets(
name.infer() for name in convert_names([name], prefer_stubs=True)
)
parent = leaf.parent
definitions = NO_CONTEXTS
if parent.type == 'atom':
# e.g. `(a + b)`
definitions = context.eval_node(leaf.parent)
elif parent.type == 'trailer':
# e.g. `a()`
definitions = evaluate_call_of_leaf(context, leaf)
elif isinstance(leaf, tree.Literal):
# e.g. `"foo"` or `1.0`
return eval_atom(context, leaf)
elif leaf.type in ('fstring_string', 'fstring_start', 'fstring_end'):
return get_string_context_set(evaluator)