From 40d2c412a52826403d38cff12ca1d34b1163e11d Mon Sep 17 00:00:00 2001 From: David Halter Date: Fri, 31 Aug 2012 01:23:12 +0200 Subject: [PATCH] instance variables are now working again, however, it's still a little bit strange --- evaluate.py | 16 +++++++++++----- parsing.py | 2 +- test/completion/ordering.py | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/evaluate.py b/evaluate.py index 6288873b..3900c29a 100644 --- a/evaluate.py +++ b/evaluate.py @@ -1005,14 +1005,15 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False): and scope.var == name.parent().parent(): name = InstanceElement(scope.instance, name) par = name.parent() + if par.isinstance(parsing.Flow): if par.command == 'for': result += handle_for_loops(par) else: debug.warning('Flow: Why are you here? %s' % par.command) - elif isinstance(par, parsing.Param) \ + elif par.isinstance(parsing.Param) \ and par.parent() is not None \ - and isinstance(par.parent().parent(), parsing.Class) \ + and par.parent().parent().isinstance(parsing.Class) \ and par.position_nr == 0: # This is where self gets added - this happens at another # place, if the var_args are clear. But sometimes the class is @@ -1024,14 +1025,14 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False): inst = Instance(Class(par.parent().parent())) inst.is_generated = True result.append(inst) - elif isinstance(par, parsing.Statement): + elif par.isinstance(parsing.Statement): def is_execution(arr): for a in arr: a = a[0] # rest is always empty with assignees - if isinstance(a, parsing.Array): + if a.isinstance(parsing.Array): if is_execution(a): return True - elif isinstance(a, parsing.Call): + elif a.isinstance(parsing.Call): if a.name == name and a.execution: return True return False @@ -1047,6 +1048,11 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False): details = par.assignment_details if details and details[0][0] != '=': no_break_scope = True + # TODO this makes self variables non-breakable. wanted? + r = [n for n in par.get_set_vars() + if len(n) > 1 and str(n.names[-1] == name)] + if isinstance(name, InstanceElement) and r: + no_break_scope = True result.append(par) else: result.append(par) diff --git a/parsing.py b/parsing.py index 7cc973df..fcd91715 100644 --- a/parsing.py +++ b/parsing.py @@ -798,7 +798,7 @@ class Param(Statement): return n[0] -class Call(object): +class Call(Base): """ `Call` contains a call, e.g. `foo.bar` and owns the executions of those calls, which are `Array`s. diff --git a/test/completion/ordering.py b/test/completion/ordering.py index 24694155..52c74281 100644 --- a/test/completion/ordering.py +++ b/test/completion/ordering.py @@ -88,14 +88,14 @@ class A(object): a = list() def __init__(self): self.b = "" + + def before(self): self.b = 3 # TODO should this be so? #? int() str() list() self.b - self.b = list - def before(self): self.a = 1 #? list() str() int() self.a