forked from VimPlug/jedi
Almost the last switch to _get_definition.
This commit is contained in:
@@ -31,7 +31,7 @@ from jedi.evaluate import Evaluator
|
|||||||
from jedi.evaluate import representation as er
|
from jedi.evaluate import representation as er
|
||||||
from jedi.evaluate import imports
|
from jedi.evaluate import imports
|
||||||
from jedi.evaluate.param import try_iter_content
|
from jedi.evaluate.param import try_iter_content
|
||||||
from jedi.evaluate.helpers import get_module_names
|
from jedi.evaluate.helpers import get_module_names, evaluate_call_of_leaf
|
||||||
from jedi.evaluate.sys_path import get_venv_path
|
from jedi.evaluate.sys_path import get_venv_path
|
||||||
from jedi.evaluate.iterable import unpack_tuple_to_dict
|
from jedi.evaluate.iterable import unpack_tuple_to_dict
|
||||||
from jedi.evaluate.filters import TreeNameDefinition
|
from jedi.evaluate.filters import TreeNameDefinition
|
||||||
@@ -355,7 +355,11 @@ class Script(object):
|
|||||||
# Iterate tuples.
|
# Iterate tuples.
|
||||||
unpack_tuple_to_dict(context, types, testlist)
|
unpack_tuple_to_dict(context, types, testlist)
|
||||||
else:
|
else:
|
||||||
try_iter_content(self._evaluator.goto_definitions(context, node))
|
if node.type == 'name':
|
||||||
|
defs = self._evaluator.goto_definitions(context, node)
|
||||||
|
else:
|
||||||
|
defs = evaluate_call_of_leaf(context, node)
|
||||||
|
try_iter_content(defs)
|
||||||
self._evaluator.reset_recursion_limitations()
|
self._evaluator.reset_recursion_limitations()
|
||||||
|
|
||||||
ana = [a for a in self._evaluator.analysis if self.path == a.path]
|
ana = [a for a in self._evaluator.analysis if self.path == a.path]
|
||||||
|
|||||||
+21
-16
@@ -446,25 +446,30 @@ class Evaluator(object):
|
|||||||
return types
|
return types
|
||||||
|
|
||||||
def goto_definitions(self, context, name):
|
def goto_definitions(self, context, name):
|
||||||
def_ = name.get_definition()
|
|
||||||
is_simple_name = name.parent.type not in ('power', 'trailer')
|
is_simple_name = name.parent.type not in ('power', 'trailer')
|
||||||
if is_simple_name:
|
if is_simple_name:
|
||||||
if name.parent.type == 'classdef' and name.parent.name == name:
|
def_ = name._get_definition()
|
||||||
return [er.ClassContext(self, name.parent, context)]
|
if def_ is not None:
|
||||||
elif name.parent.type == 'funcdef' and name.parent.name == name:
|
type_ = def_.type
|
||||||
return [er.FunctionContext(self, context, name.parent)]
|
if type_ == 'classdef':
|
||||||
|
return [er.ClassContext(self, name.parent, context)]
|
||||||
|
elif type_ == 'funcdef':
|
||||||
|
return [er.FunctionContext(self, context, name.parent)]
|
||||||
|
|
||||||
if def_.type == 'expr_stmt' and name in def_.get_defined_names():
|
if type_ == 'expr_stmt':
|
||||||
return self.eval_statement(context, def_, name)
|
return self.eval_statement(context, def_, name)
|
||||||
elif def_.type == 'for_stmt' and \
|
if type_ == 'for_stmt':
|
||||||
name.start_pos < def_.children[1].end_pos:
|
container_types = self.eval_element(context, def_.children[3])
|
||||||
container_types = self.eval_element(context, def_.children[3])
|
cn = ContextualizedNode(context, def_.children[3])
|
||||||
cn = ContextualizedNode(context, def_.children[3])
|
for_types = iterable.py__iter__types(self, container_types, cn)
|
||||||
for_types = iterable.py__iter__types(self, container_types, cn)
|
c_node = ContextualizedName(context, name)
|
||||||
c_node = ContextualizedName(context, name)
|
return finder.check_tuple_assignments(self, c_node, for_types)
|
||||||
return finder.check_tuple_assignments(self, c_node, for_types)
|
if type_ in ('import_from', 'import_name'):
|
||||||
elif def_.type in ('import_from', 'import_name'):
|
return imports.infer_import(context, name)
|
||||||
return imports.infer_import(context, name)
|
else:
|
||||||
|
imp = tree.search_ancestor(name, 'import_from', 'import_name')
|
||||||
|
if imp is not None:
|
||||||
|
return imports.infer_import(context, name)
|
||||||
|
|
||||||
return helpers.evaluate_call_of_leaf(context, name)
|
return helpers.evaluate_call_of_leaf(context, name)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user