mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
Move some code around.
This commit is contained in:
@@ -446,30 +446,30 @@ class Evaluator(object):
|
|||||||
return types
|
return types
|
||||||
|
|
||||||
def goto_definitions(self, context, name):
|
def goto_definitions(self, context, name):
|
||||||
is_simple_name = name.parent.type not in ('power', 'trailer')
|
def_ = name._get_definition()
|
||||||
if is_simple_name:
|
if def_ is not None:
|
||||||
def_ = name._get_definition()
|
type_ = def_.type
|
||||||
if def_ is not None:
|
if type_ == 'classdef':
|
||||||
type_ = def_.type
|
return [er.ClassContext(self, name.parent, context)]
|
||||||
if type_ == 'classdef':
|
elif type_ == 'funcdef':
|
||||||
return [er.ClassContext(self, name.parent, context)]
|
return [er.FunctionContext(self, context, name.parent)]
|
||||||
elif type_ == 'funcdef':
|
|
||||||
return [er.FunctionContext(self, context, name.parent)]
|
|
||||||
|
|
||||||
if type_ == 'expr_stmt':
|
if type_ == 'expr_stmt':
|
||||||
|
is_simple_name = name.parent.type not in ('power', 'trailer')
|
||||||
|
if is_simple_name:
|
||||||
return self.eval_statement(context, def_, name)
|
return self.eval_statement(context, def_, name)
|
||||||
if type_ == 'for_stmt':
|
if type_ == 'for_stmt':
|
||||||
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'):
|
if type_ in ('import_from', 'import_name'):
|
||||||
return imports.infer_import(context, name)
|
return imports.infer_import(context, name)
|
||||||
else:
|
else:
|
||||||
imp = tree.search_ancestor(name, 'import_from', 'import_name')
|
imp = tree.search_ancestor(name, 'import_from', 'import_name')
|
||||||
if imp is not None:
|
if imp is not None:
|
||||||
return imports.infer_import(context, name)
|
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