1
0
forked from VimPlug/jedi

add property tests for renaming and removed some limitations of renaming, fixes davidhalter/jedi-vim#57

This commit is contained in:
David Halter
2012-12-27 00:03:02 +01:00
parent a7deb4766f
commit d1f23444b1
2 changed files with 32 additions and 16 deletions

View File

@@ -383,19 +383,6 @@ def related_names(definitions, search_name, mods):
if not definitions: if not definitions:
return set() 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) compare_definitions = compare_array(definitions)
mods |= set([d.get_parent_until() for d in definitions]) mods |= set([d.get_parent_until() for d in definitions])
names = [] names = []
@@ -423,8 +410,7 @@ def related_names(definitions, search_name, mods):
else: else:
calls = _scan_array(stmt.get_assignment_calls(), search_name) calls = _scan_array(stmt.get_assignment_calls(), search_name)
for d in stmt.assignment_details: 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: for call in calls:
names += check_call(call) names += check_call(call)
return names return names

View File

@@ -142,7 +142,7 @@ class Super(object):
def base_method(self): def base_method(self):
#< 13 (0,13), (20,13) #< 13 (0,13), (20,13)
self.base_var = 1 self.base_var = 1
#< 13 (0,13), (29,13) #< 13 (0,13), (24,13), (29,13)
self.instance_var = 1 self.instance_var = 1
#< 8 (0,8), #< 8 (0,8),
@@ -173,3 +173,33 @@ class TestClass(Super):
def just_a_method(self): def just_a_method(self):
#< (-5,13), (0,13), (-29,13) #< (-5,13), (0,13), (-29,13)
self.instance_var 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