mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-20 06:48:27 +08:00
first dynamic array work
This commit is contained in:
@@ -267,6 +267,8 @@ def _check_array_additions(compare_array, module, is_list):
|
|||||||
stmt = element._array.parent
|
stmt = element._array.parent
|
||||||
else:
|
else:
|
||||||
# must be instance
|
# must be instance
|
||||||
|
if isinstance(element.var_args, list):
|
||||||
|
return None # TODO check if this is ok
|
||||||
stmt = element.var_args.parent
|
stmt = element.var_args.parent
|
||||||
if isinstance(stmt, er.InstanceElement):
|
if isinstance(stmt, er.InstanceElement):
|
||||||
stop_classes = list(stop_classes) + [er.Function]
|
stop_classes = list(stop_classes) + [er.Function]
|
||||||
@@ -278,6 +280,9 @@ def _check_array_additions(compare_array, module, is_list):
|
|||||||
search_names = ['append', 'extend', 'insert'] if is_list else \
|
search_names = ['append', 'extend', 'insert'] if is_list else \
|
||||||
['add', 'update']
|
['add', 'update']
|
||||||
comp_arr_parent = get_execution_parent(compare_array, er.Execution)
|
comp_arr_parent = get_execution_parent(compare_array, er.Execution)
|
||||||
|
if comp_arr_parent is None:
|
||||||
|
return [] # TODO check if this is ok
|
||||||
|
|
||||||
possible_stmts = []
|
possible_stmts = []
|
||||||
res = []
|
res = []
|
||||||
for n in search_names:
|
for n in search_names:
|
||||||
@@ -334,23 +339,24 @@ class ArrayInstance(pr.Base):
|
|||||||
lists/sets are too complicated too handle that.
|
lists/sets are too complicated too handle that.
|
||||||
"""
|
"""
|
||||||
items = []
|
items = []
|
||||||
for array in evaluate.follow_call_list(self.var_args):
|
for stmt in self.var_args:
|
||||||
if isinstance(array, er.Instance) and len(array.var_args):
|
for typ in evaluate.follow_statement(stmt):
|
||||||
temp = array.var_args[0][0]
|
if isinstance(typ, er.Instance) and len(typ.var_args):
|
||||||
if isinstance(temp, ArrayInstance):
|
array = typ.var_args[0][0]
|
||||||
# prevent recursions
|
if isinstance(array, ArrayInstance):
|
||||||
# TODO compare Modules
|
# prevent recursions
|
||||||
if self.var_args.start_pos != temp.var_args.start_pos:
|
# TODO compare Modules
|
||||||
items += temp.iter_content()
|
if self.var_args.start_pos != array.var_args.start_pos:
|
||||||
else:
|
items += array.iter_content()
|
||||||
debug.warning('ArrayInstance recursion', self.var_args)
|
else:
|
||||||
continue
|
debug.warning('ArrayInstance recursion', self.var_args)
|
||||||
items += evaluate.get_iterator_types([array])
|
continue
|
||||||
|
items += evaluate.get_iterator_types([typ])
|
||||||
|
|
||||||
if self.var_args.parent_stmt is None:
|
if self.var_args.parent is None:
|
||||||
return [] # generated var_args should not be checked for arrays
|
return [] # generated var_args should not be checked for arrays
|
||||||
|
|
||||||
module = self.var_args.parent_stmt.get_parent_until()
|
module = self.var_args.get_parent_until()
|
||||||
is_list = str(self.instance.name) == 'list'
|
is_list = str(self.instance.name) == 'list'
|
||||||
items += _check_array_additions(self.instance, module, is_list)
|
items += _check_array_additions(self.instance, module, is_list)
|
||||||
return items
|
return items
|
||||||
|
|||||||
@@ -34,8 +34,10 @@ class RecursionDecorator(object):
|
|||||||
|
|
||||||
def push_stmt(self, stmt):
|
def push_stmt(self, stmt):
|
||||||
self.current = RecursionNode(stmt, self.current)
|
self.current = RecursionNode(stmt, self.current)
|
||||||
if self._check_recursion():
|
check = self._check_recursion()
|
||||||
debug.warning('catched recursion', stmt, stmt.start_pos)
|
if check:
|
||||||
|
debug.warning('catched stmt recursion: %s against %s @%s'
|
||||||
|
% (stmt, stmt.start_pos, check.stmt))
|
||||||
self.pop_stmt()
|
self.pop_stmt()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@@ -51,7 +53,7 @@ class RecursionDecorator(object):
|
|||||||
while True:
|
while True:
|
||||||
test = test.parent
|
test = test.parent
|
||||||
if self.current == test:
|
if self.current == test:
|
||||||
return True
|
return test
|
||||||
if not test:
|
if not test:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user