mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix dynamic arrays: They work in instances, now.
This commit is contained in:
@@ -513,7 +513,9 @@ def _check_array_additions(evaluator, compare_array, module, is_list):
|
|||||||
# Is an Instance with an
|
# Is an Instance with an
|
||||||
# Arguments([AlreadyEvaluated([ArrayInstance])]) inside
|
# Arguments([AlreadyEvaluated([ArrayInstance])]) inside
|
||||||
# Yeah... I know... It's complicated ;-)
|
# Yeah... I know... It's complicated ;-)
|
||||||
node = list(element.var_args.argument_node[0])[0].var_args
|
node = list(element.var_args.argument_node[0])[0].var_args.trailer
|
||||||
|
if isinstance(node, er.InstanceElement):
|
||||||
|
return node
|
||||||
return node.get_parent_until(er.FunctionExecution)
|
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 = \
|
||||||
@@ -543,11 +545,6 @@ def _check_array_additions(evaluator, compare_array, module, is_list):
|
|||||||
# improves Jedi's speed for array lookups, since we
|
# improves Jedi's speed for array lookups, since we
|
||||||
# don't have to check the whole source tree anymore.
|
# don't have to check the whole source tree anymore.
|
||||||
continue
|
continue
|
||||||
# InstanceElements are special, because they don't get copied,
|
|
||||||
# but have this wrapper around them.
|
|
||||||
if isinstance(comp_arr_parent, er.InstanceElement):
|
|
||||||
stmt = er.get_instance_el(comp_arr_parent.instance, stmt)
|
|
||||||
|
|
||||||
trailer = name.parent
|
trailer = name.parent
|
||||||
power = trailer.parent
|
power = trailer.parent
|
||||||
trailer_pos = power.children.index(trailer)
|
trailer_pos = power.children.index(trailer)
|
||||||
@@ -561,6 +558,11 @@ def _check_array_additions(evaluator, compare_array, module, is_list):
|
|||||||
or execution_trailer.children[1] == ')':
|
or execution_trailer.children[1] == ')':
|
||||||
continue
|
continue
|
||||||
power = helpers.call_of_name(name, cut_own_trailer=True)
|
power = helpers.call_of_name(name, cut_own_trailer=True)
|
||||||
|
# InstanceElements are special, because they don't get copied,
|
||||||
|
# but have this wrapper around them.
|
||||||
|
if isinstance(comp_arr_parent, er.InstanceElement):
|
||||||
|
power = er.get_instance_el(evaluator, comp_arr_parent.instance, power)
|
||||||
|
|
||||||
if evaluator.recursion_detector.push_stmt(power):
|
if evaluator.recursion_detector.push_stmt(power):
|
||||||
# Check for recursion. Possible by using 'extend' in
|
# Check for recursion. Possible by using 'extend' in
|
||||||
# combination with function calls.
|
# combination with function calls.
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class Arguments(pr.Base):
|
|||||||
"""
|
"""
|
||||||
self.argument_node = argument_node
|
self.argument_node = argument_node
|
||||||
self._evaluator = evaluator
|
self._evaluator = evaluator
|
||||||
self._trailer = trailer # Can be None, e.g. in a class definition.
|
self.trailer = trailer # Can be None, e.g. in a class definition.
|
||||||
|
|
||||||
def _split(self):
|
def _split(self):
|
||||||
if isinstance(self.argument_node, (tuple, list)):
|
if isinstance(self.argument_node, (tuple, list)):
|
||||||
@@ -44,7 +44,7 @@ class Arguments(pr.Base):
|
|||||||
yield 0, child
|
yield 0, child
|
||||||
|
|
||||||
def get_parent_until(self, *args, **kwargs):
|
def get_parent_until(self, *args, **kwargs):
|
||||||
return self._trailer.get_parent_until(*args, **kwargs)
|
return self.trailer.get_parent_until(*args, **kwargs)
|
||||||
|
|
||||||
def as_tuple(self):
|
def as_tuple(self):
|
||||||
for stars, argument in self._split():
|
for stars, argument in self._split():
|
||||||
@@ -126,7 +126,7 @@ class Arguments(pr.Base):
|
|||||||
|
|
||||||
def scope(self):
|
def scope(self):
|
||||||
# Returns the scope in which the arguments are used.
|
# Returns the scope in which the arguments are used.
|
||||||
return (self._trailer or self.argument_node).get_parent_until(pr.IsScope)
|
return (self.trailer or self.argument_node).get_parent_until(pr.IsScope)
|
||||||
|
|
||||||
def eval_args(self):
|
def eval_args(self):
|
||||||
# TODO this method doesn't work with named args and a lot of other
|
# TODO this method doesn't work with named args and a lot of other
|
||||||
|
|||||||
@@ -242,13 +242,20 @@ class C():
|
|||||||
a[0]
|
a[0]
|
||||||
return a
|
return a
|
||||||
|
|
||||||
def class_arr(self, el):
|
def literal_arr(self, el):
|
||||||
self.a = []
|
self.a = []
|
||||||
self.a.append(el)
|
self.a.append(el)
|
||||||
#? int()
|
#? int()
|
||||||
self.a[0]
|
self.a[0]
|
||||||
return self.a
|
return self.a
|
||||||
|
|
||||||
|
def list_arr(self, el):
|
||||||
|
self.b = list([])
|
||||||
|
self.b.append(el)
|
||||||
|
#? float()
|
||||||
|
self.b[0]
|
||||||
|
return self.b
|
||||||
|
|
||||||
#? int()
|
#? int()
|
||||||
C().blub(1)[0]
|
C().blub(1)[0]
|
||||||
#? float()
|
#? float()
|
||||||
@@ -257,7 +264,12 @@ C().blub2(1)[0]
|
|||||||
#? int()
|
#? int()
|
||||||
C().a[0]
|
C().a[0]
|
||||||
#? int()
|
#? int()
|
||||||
C().class_arr(1)[0]
|
C().literal_arr(1)[0]
|
||||||
|
|
||||||
|
#? float()
|
||||||
|
C().b[0]
|
||||||
|
#? float()
|
||||||
|
C().list_arr(1.0)[0]
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# array recursions
|
# array recursions
|
||||||
|
|||||||
Reference in New Issue
Block a user