diff --git a/evaluate.py b/evaluate.py index c2d8951e..6a48a9d3 100644 --- a/evaluate.py +++ b/evaluate.py @@ -829,6 +829,7 @@ def get_names_for_scope(scope, position=None, star_search=True, the whole thing would probably start a little recursive madness. """ start_scope = scope + in_scope = scope while scope: # `parsing.Class` is used, because the parent is never `Class`. # Ignore the Flows, because the classes and functions care for that. @@ -840,10 +841,14 @@ def get_names_for_scope(scope, position=None, star_search=True, try: yield scope, get_defined_names_for_position(scope, position, - start_scope) + in_scope) except StopIteration: raise MultiLevelStopIteration('StopIteration raised somewhere') scope = scope.parent + # This is used, because subscopes (Flow scopes) would distort the + # results. + if isinstance(scope, (Function, parsing.Function, Execution)): + in_scope = scope # Add star imports. if star_search: diff --git a/test/completion/classes.py b/test/completion/classes.py index 8347793b..b3f580f1 100644 --- a/test/completion/classes.py +++ b/test/completion/classes.py @@ -1,3 +1,24 @@ +def find_class(): + """ This scope is special, because its in front of TestClass """ + #? ['ret'] + TestClass.ret + if 1: + #? ['ret'] + TestClass.ret + +class FindClass(): + #? [] + TestClass.ret + if a: + #? [] + TestClass.ret + + def find_class(self): + #? ['ret'] + TestClass.ret + if 1: + #? ['ret'] + TestClass.ret # set variables, which should not be included, because they don't belong to the # class