From d1f23444b1f6d3b5500f3df731b1fdcc7050ccaa Mon Sep 17 00:00:00 2001 From: David Halter Date: Thu, 27 Dec 2012 00:03:02 +0100 Subject: [PATCH] add property tests for renaming and removed some limitations of renaming, fixes davidhalter/jedi-vim#57 --- jedi/dynamic.py | 16 +--------------- test/completion/renaming.py | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/jedi/dynamic.py b/jedi/dynamic.py index 78d74bb7..b7cae313 100644 --- a/jedi/dynamic.py +++ b/jedi/dynamic.py @@ -383,19 +383,6 @@ def related_names(definitions, search_name, mods): if not definitions: return set() - def is_definition(arr): - try: - for a in arr: - assert len(a) == 1 - a = a[0] - if a.isinstance(parsing.Array): - assert is_definition(a) - elif a.isinstance(parsing.Call): - assert a.execution is None - return True - except AssertionError: - return False - compare_definitions = compare_array(definitions) mods |= set([d.get_parent_until() for d in definitions]) names = [] @@ -423,8 +410,7 @@ def related_names(definitions, search_name, mods): else: calls = _scan_array(stmt.get_assignment_calls(), search_name) for d in stmt.assignment_details: - if not is_definition(d[1]): - calls += _scan_array(d[1], search_name) + calls += _scan_array(d[1], search_name) for call in calls: names += check_call(call) return names diff --git a/test/completion/renaming.py b/test/completion/renaming.py index d792e3a2..850d8d1b 100644 --- a/test/completion/renaming.py +++ b/test/completion/renaming.py @@ -142,7 +142,7 @@ class Super(object): def base_method(self): #< 13 (0,13), (20,13) self.base_var = 1 - #< 13 (0,13), (29,13) + #< 13 (0,13), (24,13), (29,13) self.instance_var = 1 #< 8 (0,8), @@ -173,3 +173,33 @@ class TestClass(Super): def just_a_method(self): #< (-5,13), (0,13), (-29,13) self.instance_var + + +# ----------------- +# properties +# ----------------- +class TestProperty: + + @property + #< 10 (0,8), (5,13) + def prop(self): + return 1 + + def a(self): + #< 13 (-5,8), (0,13) + self.prop + + @property + #< 13 (0,8), (4,5) + def rw_prop(self): + return self._rw_prop + + #< 8 (-4,8), (0,5) + @rw_prop.setter + #< 8 (0,8), (5,13) + def rw_prop(self, value): + self._rw_prop = value + + def b(self): + #< 13 (-5,8), (0,13) + self.rw_prop