mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-25 17:58:35 +08:00
Fix some stuff list.append stuff combined with functions executions.
This commit is contained in:
+15
-14
@@ -505,23 +505,22 @@ def _check_array_additions(evaluator, compare_array, module, is_list):
|
|||||||
|
|
||||||
from jedi.evaluate import representation as er, param
|
from jedi.evaluate import representation as er, param
|
||||||
|
|
||||||
def get_execution_parent(element, *stop_classes):
|
def get_execution_parent(element):
|
||||||
""" Used to get an Instance/FunctionExecution parent """
|
""" Used to get an Instance/FunctionExecution parent """
|
||||||
if isinstance(element, Array):
|
if isinstance(element, Array):
|
||||||
# TODO remove!
|
node = element.atom
|
||||||
stmt = element._array.parent
|
|
||||||
else:
|
else:
|
||||||
# is an Instance with an ArrayInstance inside
|
# Is an Instance with an
|
||||||
stmt = element.var_args[0].var_args.parent
|
# Arguments([AlreadyEvaluated([ArrayInstance])]) inside
|
||||||
if isinstance(stmt, er.InstanceElement):
|
# Yeah... I know... It's complicated ;-)
|
||||||
stop_classes = list(stop_classes) + [er.Function]
|
node = list(element.var_args.argument_node[0])[0].var_args
|
||||||
return stmt.get_parent_until(stop_classes)
|
return node.get_parent_until(er.FunctionExecution)
|
||||||
|
|
||||||
temp_param_add, settings.dynamic_params_for_other_modules = \
|
temp_param_add, settings.dynamic_params_for_other_modules = \
|
||||||
settings.dynamic_params_for_other_modules, False
|
settings.dynamic_params_for_other_modules, False
|
||||||
|
|
||||||
search_names = ['append', 'extend', 'insert'] if is_list else ['add', 'update']
|
search_names = ['append', 'extend', 'insert'] if is_list else ['add', 'update']
|
||||||
#comp_arr_parent = get_execution_parent(compare_array, er.FunctionExecution)
|
comp_arr_parent = get_execution_parent(compare_array)
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
for add_name in search_names:
|
for add_name in search_names:
|
||||||
@@ -535,17 +534,19 @@ def _check_array_additions(evaluator, compare_array, module, is_list):
|
|||||||
# can search for the same statement, that is in the module
|
# can search for the same statement, that is in the module
|
||||||
# dict. Executions are somewhat special in jedi, since they
|
# dict. Executions are somewhat special in jedi, since they
|
||||||
# literally copy the contents of a function.
|
# literally copy the contents of a function.
|
||||||
"""
|
|
||||||
if isinstance(comp_arr_parent, er.FunctionExecution):
|
if isinstance(comp_arr_parent, er.FunctionExecution):
|
||||||
stmt = comp_arr_parent. \
|
if comp_arr_parent.start_pos < name.start_pos < comp_arr_parent.end_pos:
|
||||||
get_statement_for_position(stmt.start_pos)
|
name = comp_arr_parent.name_for_position(name.start_pos)
|
||||||
if stmt is None:
|
else:
|
||||||
|
# Don't check definitions that are not defined in the
|
||||||
|
# same function. This is not "proper" anyway. It also
|
||||||
|
# improves Jedi's speed for array lookups, since we
|
||||||
|
# don't have to check the whole source tree anymore.
|
||||||
continue
|
continue
|
||||||
# InstanceElements are special, because they don't get copied,
|
# InstanceElements are special, because they don't get copied,
|
||||||
# but have this wrapper around them.
|
# but have this wrapper around them.
|
||||||
if isinstance(comp_arr_parent, er.InstanceElement):
|
if isinstance(comp_arr_parent, er.InstanceElement):
|
||||||
stmt = er.get_instance_el(comp_arr_parent.instance, stmt)
|
stmt = er.get_instance_el(comp_arr_parent.instance, stmt)
|
||||||
"""
|
|
||||||
|
|
||||||
trailer = name.parent
|
trailer = name.parent
|
||||||
power = trailer.parent
|
power = trailer.parent
|
||||||
|
|||||||
@@ -654,6 +654,9 @@ class FunctionExecution(Executed):
|
|||||||
def param_by_name(self, name):
|
def param_by_name(self, name):
|
||||||
return [n for n in self._get_params() if str(n) == name][0]
|
return [n for n in self._get_params() if str(n) == name][0]
|
||||||
|
|
||||||
|
def name_for_position(self, position):
|
||||||
|
return pr.Function.name_for_position(self, position)
|
||||||
|
|
||||||
def get_defined_names(self):
|
def get_defined_names(self):
|
||||||
"""
|
"""
|
||||||
Call the default method with the own instance (self implements all
|
Call the default method with the own instance (self implements all
|
||||||
|
|||||||
Reference in New Issue
Block a user