mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Move some code around.
This commit is contained in:
@@ -446,30 +446,30 @@ class Evaluator(object):
|
||||
return types
|
||||
|
||||
def goto_definitions(self, context, name):
|
||||
is_simple_name = name.parent.type not in ('power', 'trailer')
|
||||
if is_simple_name:
|
||||
def_ = name._get_definition()
|
||||
if def_ is not None:
|
||||
type_ = def_.type
|
||||
if type_ == 'classdef':
|
||||
return [er.ClassContext(self, name.parent, context)]
|
||||
elif type_ == 'funcdef':
|
||||
return [er.FunctionContext(self, context, name.parent)]
|
||||
def_ = name._get_definition()
|
||||
if def_ is not None:
|
||||
type_ = def_.type
|
||||
if type_ == 'classdef':
|
||||
return [er.ClassContext(self, name.parent, context)]
|
||||
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)
|
||||
if type_ == 'for_stmt':
|
||||
container_types = self.eval_element(context, def_.children[3])
|
||||
cn = ContextualizedNode(context, def_.children[3])
|
||||
for_types = iterable.py__iter__types(self, container_types, cn)
|
||||
c_node = ContextualizedName(context, name)
|
||||
return finder.check_tuple_assignments(self, c_node, for_types)
|
||||
if type_ in ('import_from', 'import_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)
|
||||
if type_ == 'for_stmt':
|
||||
container_types = self.eval_element(context, def_.children[3])
|
||||
cn = ContextualizedNode(context, def_.children[3])
|
||||
for_types = iterable.py__iter__types(self, container_types, cn)
|
||||
c_node = ContextualizedName(context, name)
|
||||
return finder.check_tuple_assignments(self, c_node, for_types)
|
||||
if type_ in ('import_from', 'import_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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user