functions don't return values anymore, if they are not executed

This commit is contained in:
David Halter
2012-04-22 17:01:15 +02:00
parent 4543b14cd4
commit a5531f2a81
3 changed files with 43 additions and 35 deletions

View File

@@ -324,7 +324,7 @@ def follow_statement(stmt, scope=None):
parsing.Class, Instance)
call_list = stmt.get_assignment_calls()
debug.dbg('calls', call_list, call_list.values)
return follow_call_list(scope, call_list)
return set(follow_call_list(scope, call_list))
def follow_call_list(scope, call_list):
@@ -382,15 +382,14 @@ def follow_paths(path, results):
return results_new
def follow_path(path, input):
def follow_path(path, scope):
"""
Takes a generator and tries to complete the path.
"""
# current is either an Array or a Scope
current = next(path)
debug.dbg('follow', current, input)
debug.dbg('follow', current, scope)
def filter_result(scope):
result = []
if isinstance(current, parsing.Array):
# this must be an execution, either () or []
@@ -409,13 +408,13 @@ def follow_path(path, input):
debug.warning('strange function call with {}', current, scope)
else:
if isinstance(scope, parsing.Function):
# TODO this is never reached, just remove it?
# TODO check default function methods and return them
result = []
else:
# TODO check magic class methods and return them also
result = strip_imports(get_scopes_for_name(scope, current))
return result
return follow_paths(path, filter_result(input))
return follow_paths(path, result)
def follow_import(_import):
@@ -456,4 +455,4 @@ def remove_star_imports(scope):
modules += new
# filter duplicate modules
return list(set(modules))
return set(modules)

View File

@@ -188,6 +188,9 @@ def complete(source, row, column, source_path):
stmt = r.top.statements[0]
except IndexError:
completions = evaluate.get_names_for_scope(scope)
#for c in completions:
# if isinstance(, parsing.Function):
# print c.parent
else:
stmt.parent = scope
scopes = evaluate.follow_statement(stmt, scope=scope)
@@ -195,16 +198,17 @@ def complete(source, row, column, source_path):
completions = []
debug.dbg('possible scopes', scopes)
for s in scopes:
# TODO is this reall the right way, just ignore the functions?
if not isinstance(s, parsing.Function):
completions += s.get_defined_names()
completions = list(set(completions))
needs_dot = not dot and path
completions = [Completion(c, needs_dot, len(like)) for c in completions
completions = [c for c in completions
if c.names[-1].lower().startswith(like.lower())]
_clear_caches()
return completions
needs_dot = not dot and path
return [Completion(c, needs_dot, len(like)) for c in set(completions)]
def set_debug_function(func_cb):

View File

@@ -6,6 +6,11 @@ def array(first_param):
#? []
array.first_param
#? []
array.first_param.
func = array
#? []
func.first_param
#? ['append']
array().append