1
0
forked from VimPlug/jedi

little cleanup, removed old unused code

This commit is contained in:
David Halter
2013-02-21 20:57:05 +04:30
parent 2b174ecf2c
commit 0084b9f04d
3 changed files with 44 additions and 70 deletions

View File

@@ -574,58 +574,51 @@ def follow_call_list(call_list, follow_array=False):
loop = evaluate_list_comprehension(nested_lc, loop)
return loop
if pr.Array.is_type(call_list, pr.Array.TUPLE, pr.Array.DICT):
raise NotImplementedError('TODO')
# Tuples can stand just alone without any braces. These would be
# recognized as separate calls, but actually are a tuple.
result = follow_call(call_list)
else:
result = []
calls_iterator = iter(call_list)
for call in calls_iterator:
if pr.Array.is_type(call, pr.Array.NOARRAY):
r = list(itertools.chain.from_iterable(follow_statement(s)
for s in call))
call_path = call.generate_call_path()
next(call_path, None) # the first one has been used already
result += follow_paths(call_path, r, call.parent,
position=call.start_pos)
elif isinstance(call, pr.ListComprehension):
loop = evaluate_list_comprehension(call)
# Caveat: parents are being changed, but this doesn't matter,
# because nothing else uses it.
call.stmt.parent = loop
result += follow_statement(call.stmt)
else:
if isinstance(call, pr.Lambda):
result.append(er.Function(call))
# With things like params, these can also be functions...
elif isinstance(call, (er.Function, er.Class, er.Instance,
dynamic.ArrayInstance)):
# TODO this is just not very well readable -> fix, use pr.Base
result.append(call)
# The string tokens are just operations (+, -, etc.)
elif not isinstance(call, (str, unicode)):
if str(call.name) == 'if':
# Ternary operators.
while True:
try:
call = next(calls_iterator)
except StopIteration:
result = []
calls_iterator = iter(call_list)
for call in calls_iterator:
if pr.Array.is_type(call, pr.Array.NOARRAY):
r = list(itertools.chain.from_iterable(follow_statement(s)
for s in call))
call_path = call.generate_call_path()
next(call_path, None) # the first one has been used already
result += follow_paths(call_path, r, call.parent,
position=call.start_pos)
elif isinstance(call, pr.ListComprehension):
loop = evaluate_list_comprehension(call)
# Caveat: parents are being changed, but this doesn't matter,
# because nothing else uses it.
call.stmt.parent = loop
result += follow_statement(call.stmt)
else:
if isinstance(call, pr.Lambda):
result.append(er.Function(call))
# With things like params, these can also be functions...
elif isinstance(call, (er.Function, er.Class, er.Instance,
dynamic.ArrayInstance)):
result.append(call)
# The string tokens are just operations (+, -, etc.)
elif not isinstance(call, (str, unicode)):
if str(call.name) == 'if':
# Ternary operators.
while True:
try:
call = next(calls_iterator)
except StopIteration:
break
try:
if str(call.name) == 'else':
break
try:
if str(call.name) == 'else':
break
except AttributeError:
pass
continue
result += follow_call(call)
elif call == '*':
if [r for r in result if isinstance(r, er.Array)
or isinstance(r, er.Instance)
and str(r.name) == 'str']:
# if it is an iterable, ignore * operations
next(calls_iterator)
except AttributeError:
pass
continue
result += follow_call(call)
elif call == '*':
if [r for r in result if isinstance(r, er.Array)
or isinstance(r, er.Instance)
and str(r.name) == 'str']:
# if it is an iterable, ignore * operations
next(calls_iterator)
return set(result)

View File

@@ -216,17 +216,6 @@ class InstanceElement(use_metaclass(cache.CachedMetaClass)):
return func
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.
return [InstanceElement(self.instance, command, self.is_class_var)
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.
"""
# 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):
parent = self.var_args.parent
start_pos = self.var_args.start_pos
@@ -658,10 +645,6 @@ class Execution(Executable):
yield call, value_stmt
elif type(call) == pr.Call:
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).
else:
if stmt.assignment_details:

View File

@@ -480,7 +480,6 @@ class Flow(Scope):
self.set_vars = set_vars
for s in self.set_vars:
s.parent.parent = self.use_as_parent
# TODO strange!!! don't know why this exist
s.parent = self.use_as_parent
@property
@@ -1000,7 +999,6 @@ class Call(Simple):
def generate_call_path(self):
""" Helps to get the order in which statements are executed. """
# TODO include previous nodes? As an option?
try:
for name_part in self.name.names:
yield name_part