mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
Get rid of create_init_executions
This commit is contained in:
@@ -185,6 +185,7 @@ def _check_name_for_execution(inference_state, context, compare_node, name, trai
|
|||||||
if arglist == ')':
|
if arglist == ')':
|
||||||
arglist = None
|
arglist = None
|
||||||
args = TreeArguments(inference_state, context, arglist, trailer)
|
args = TreeArguments(inference_state, context, arglist, trailer)
|
||||||
|
from jedi.inference.value.instance import BoundMethod, InstanceArguments
|
||||||
if value.tree_node.type == 'classdef':
|
if value.tree_node.type == 'classdef':
|
||||||
created_instance = instance.TreeInstance(
|
created_instance = instance.TreeInstance(
|
||||||
inference_state,
|
inference_state,
|
||||||
@@ -192,17 +193,18 @@ def _check_name_for_execution(inference_state, context, compare_node, name, trai
|
|||||||
value,
|
value,
|
||||||
args
|
args
|
||||||
)
|
)
|
||||||
for execution in created_instance.create_init_executions():
|
args = InstanceArguments(created_instance, args)
|
||||||
yield execution
|
yield args
|
||||||
else:
|
else:
|
||||||
yield value.as_context(args)
|
if isinstance(value, BoundMethod):
|
||||||
|
args = InstanceArguments(value.instance, args)
|
||||||
|
yield args
|
||||||
|
|
||||||
for value in inference_state.goto_definitions(context, name):
|
for value in inference_state.goto_definitions(context, name):
|
||||||
value_node = value.tree_node
|
value_node = value.tree_node
|
||||||
if compare_node == value_node:
|
if compare_node == value_node:
|
||||||
for func_execution in create_func_excs(value):
|
for arguments in create_func_excs(value):
|
||||||
# TODO private access
|
yield arguments
|
||||||
yield func_execution._arguments
|
|
||||||
elif isinstance(value.parent_context, BaseFunctionExecutionContext) \
|
elif isinstance(value.parent_context, BaseFunctionExecutionContext) \
|
||||||
and compare_node.type == 'funcdef':
|
and compare_node.type == 'funcdef':
|
||||||
# Here we're trying to find decorators by checking the first
|
# Here we're trying to find decorators by checking the first
|
||||||
@@ -216,7 +218,7 @@ def _check_name_for_execution(inference_state, context, compare_node, name, trai
|
|||||||
if nodes == [compare_node]:
|
if nodes == [compare_node]:
|
||||||
# Found a decorator.
|
# Found a decorator.
|
||||||
module_context = context.get_root_context()
|
module_context = context.get_root_context()
|
||||||
execution_context = next(create_func_excs(value))
|
execution_context = value.as_context(next(create_func_excs(value)))
|
||||||
potential_nodes = _get_potential_nodes(module_context, param_names[0].string_name)
|
potential_nodes = _get_potential_nodes(module_context, param_names[0].string_name)
|
||||||
for name, trailer in potential_nodes:
|
for name, trailer in potential_nodes:
|
||||||
if value_node.start_pos < name.start_pos < value_node.end_pos:
|
if value_node.start_pos < name.start_pos < value_node.end_pos:
|
||||||
|
|||||||
@@ -228,18 +228,6 @@ class AbstractInstanceValue(Value):
|
|||||||
def name(self):
|
def name(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def create_init_executions(self):
|
|
||||||
for name in self.get_function_slot_names(u'__init__'):
|
|
||||||
# TODO is this correct? I think we need to check for functions.
|
|
||||||
if isinstance(name, LazyInstanceClassName):
|
|
||||||
function = FunctionValue.from_context(
|
|
||||||
self.parent_context,
|
|
||||||
name.tree_name.parent
|
|
||||||
)
|
|
||||||
bound_method = BoundMethod(self, function)
|
|
||||||
|
|
||||||
yield bound_method.as_context(self.arguments)
|
|
||||||
|
|
||||||
@inference_state_method_cache()
|
@inference_state_method_cache()
|
||||||
def create_instance_context(self, class_context, node):
|
def create_instance_context(self, class_context, node):
|
||||||
if node.parent.type in ('funcdef', 'classdef'):
|
if node.parent.type in ('funcdef', 'classdef'):
|
||||||
|
|||||||
Reference in New Issue
Block a user