forked from VimPlug/jedi
little cleanup, removed old unused code
This commit is contained in:
@@ -574,58 +574,51 @@ def follow_call_list(call_list, follow_array=False):
|
|||||||
loop = evaluate_list_comprehension(nested_lc, loop)
|
loop = evaluate_list_comprehension(nested_lc, loop)
|
||||||
return loop
|
return loop
|
||||||
|
|
||||||
if pr.Array.is_type(call_list, pr.Array.TUPLE, pr.Array.DICT):
|
result = []
|
||||||
raise NotImplementedError('TODO')
|
calls_iterator = iter(call_list)
|
||||||
# Tuples can stand just alone without any braces. These would be
|
for call in calls_iterator:
|
||||||
# recognized as separate calls, but actually are a tuple.
|
if pr.Array.is_type(call, pr.Array.NOARRAY):
|
||||||
result = follow_call(call_list)
|
r = list(itertools.chain.from_iterable(follow_statement(s)
|
||||||
else:
|
for s in call))
|
||||||
result = []
|
call_path = call.generate_call_path()
|
||||||
calls_iterator = iter(call_list)
|
next(call_path, None) # the first one has been used already
|
||||||
for call in calls_iterator:
|
result += follow_paths(call_path, r, call.parent,
|
||||||
if pr.Array.is_type(call, pr.Array.NOARRAY):
|
position=call.start_pos)
|
||||||
r = list(itertools.chain.from_iterable(follow_statement(s)
|
elif isinstance(call, pr.ListComprehension):
|
||||||
for s in call))
|
loop = evaluate_list_comprehension(call)
|
||||||
call_path = call.generate_call_path()
|
# Caveat: parents are being changed, but this doesn't matter,
|
||||||
next(call_path, None) # the first one has been used already
|
# because nothing else uses it.
|
||||||
result += follow_paths(call_path, r, call.parent,
|
call.stmt.parent = loop
|
||||||
position=call.start_pos)
|
result += follow_statement(call.stmt)
|
||||||
elif isinstance(call, pr.ListComprehension):
|
else:
|
||||||
loop = evaluate_list_comprehension(call)
|
if isinstance(call, pr.Lambda):
|
||||||
# Caveat: parents are being changed, but this doesn't matter,
|
result.append(er.Function(call))
|
||||||
# because nothing else uses it.
|
# With things like params, these can also be functions...
|
||||||
call.stmt.parent = loop
|
elif isinstance(call, (er.Function, er.Class, er.Instance,
|
||||||
result += follow_statement(call.stmt)
|
dynamic.ArrayInstance)):
|
||||||
else:
|
result.append(call)
|
||||||
if isinstance(call, pr.Lambda):
|
# The string tokens are just operations (+, -, etc.)
|
||||||
result.append(er.Function(call))
|
elif not isinstance(call, (str, unicode)):
|
||||||
# With things like params, these can also be functions...
|
if str(call.name) == 'if':
|
||||||
elif isinstance(call, (er.Function, er.Class, er.Instance,
|
# Ternary operators.
|
||||||
dynamic.ArrayInstance)):
|
while True:
|
||||||
# TODO this is just not very well readable -> fix, use pr.Base
|
try:
|
||||||
result.append(call)
|
call = next(calls_iterator)
|
||||||
# The string tokens are just operations (+, -, etc.)
|
except StopIteration:
|
||||||
elif not isinstance(call, (str, unicode)):
|
break
|
||||||
if str(call.name) == 'if':
|
try:
|
||||||
# Ternary operators.
|
if str(call.name) == 'else':
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
call = next(calls_iterator)
|
|
||||||
except StopIteration:
|
|
||||||
break
|
break
|
||||||
try:
|
except AttributeError:
|
||||||
if str(call.name) == 'else':
|
pass
|
||||||
break
|
continue
|
||||||
except AttributeError:
|
result += follow_call(call)
|
||||||
pass
|
elif call == '*':
|
||||||
continue
|
if [r for r in result if isinstance(r, er.Array)
|
||||||
result += follow_call(call)
|
or isinstance(r, er.Instance)
|
||||||
elif call == '*':
|
and str(r.name) == 'str']:
|
||||||
if [r for r in result if isinstance(r, er.Array)
|
# if it is an iterable, ignore * operations
|
||||||
or isinstance(r, er.Instance)
|
next(calls_iterator)
|
||||||
and str(r.name) == 'str']:
|
|
||||||
# if it is an iterable, ignore * operations
|
|
||||||
next(calls_iterator)
|
|
||||||
return set(result)
|
return set(result)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -216,17 +216,6 @@ class InstanceElement(use_metaclass(cache.CachedMetaClass)):
|
|||||||
return func
|
return func
|
||||||
|
|
||||||
def get_commands(self):
|
def get_commands(self):
|
||||||
"""
|
|
||||||
# TODO delete ?
|
|
||||||
# Copy and modify the array.
|
|
||||||
origin = self.var.get_commands()
|
|
||||||
# Delete parent, because it isn't used anymore.
|
|
||||||
new = helpers.fast_parent_copy(origin)
|
|
||||||
par = InstanceElement(self.instance, origin.parent_stmt,
|
|
||||||
self.is_class_var)
|
|
||||||
new.parent_stmt = par
|
|
||||||
return new
|
|
||||||
"""
|
|
||||||
# Copy and modify the array.
|
# Copy and modify the array.
|
||||||
return [InstanceElement(self.instance, command, self.is_class_var)
|
return [InstanceElement(self.instance, command, self.is_class_var)
|
||||||
for command in self.var.get_commands()]
|
for command in self.var.get_commands()]
|
||||||
@@ -502,8 +491,6 @@ class Execution(Executable):
|
|||||||
"""
|
"""
|
||||||
Create a param with the original scope (of varargs) as parent.
|
Create a param with the original scope (of varargs) as parent.
|
||||||
"""
|
"""
|
||||||
# TODO remove array and param and just put the values of the \
|
|
||||||
# statement into the values of the param - it's as simple as that.
|
|
||||||
if isinstance(self.var_args, pr.Array):
|
if isinstance(self.var_args, pr.Array):
|
||||||
parent = self.var_args.parent
|
parent = self.var_args.parent
|
||||||
start_pos = self.var_args.start_pos
|
start_pos = self.var_args.start_pos
|
||||||
@@ -658,10 +645,6 @@ class Execution(Executable):
|
|||||||
yield call, value_stmt
|
yield call, value_stmt
|
||||||
elif type(call) == pr.Call:
|
elif type(call) == pr.Call:
|
||||||
yield call.name, value_stmt
|
yield call.name, value_stmt
|
||||||
else:
|
|
||||||
# `pr`.[Call|Function|Class] lookup.
|
|
||||||
# TODO remove?
|
|
||||||
yield key_stmt[0].name, value_stmt
|
|
||||||
# Normal arguments (including key arguments).
|
# Normal arguments (including key arguments).
|
||||||
else:
|
else:
|
||||||
if stmt.assignment_details:
|
if stmt.assignment_details:
|
||||||
|
|||||||
@@ -480,7 +480,6 @@ class Flow(Scope):
|
|||||||
self.set_vars = set_vars
|
self.set_vars = set_vars
|
||||||
for s in self.set_vars:
|
for s in self.set_vars:
|
||||||
s.parent.parent = self.use_as_parent
|
s.parent.parent = self.use_as_parent
|
||||||
# TODO strange!!! don't know why this exist
|
|
||||||
s.parent = self.use_as_parent
|
s.parent = self.use_as_parent
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -1000,7 +999,6 @@ class Call(Simple):
|
|||||||
|
|
||||||
def generate_call_path(self):
|
def generate_call_path(self):
|
||||||
""" Helps to get the order in which statements are executed. """
|
""" Helps to get the order in which statements are executed. """
|
||||||
# TODO include previous nodes? As an option?
|
|
||||||
try:
|
try:
|
||||||
for name_part in self.name.names:
|
for name_part in self.name.names:
|
||||||
yield name_part
|
yield name_part
|
||||||
|
|||||||
Reference in New Issue
Block a user