safe delete: fixed delete from the top of the hierarchy

This commit is contained in:
anna
2011-03-11 15:47:34 +01:00
parent d1b5fd26f8
commit 0d2ea7efa4
8 changed files with 36 additions and 1 deletions
@@ -111,7 +111,11 @@ public class JavaSafeDeleteProcessor implements SafeDeleteProcessorDelegate {
final Set<PsiParameter> parametersToDelete = new HashSet<PsiParameter>();
parametersToDelete.add((PsiParameter) element);
final int parameterIndex = method.getParameterList().getParameterIndex((PsiParameter) element);
for (PsiMethod superMethod : method.findDeepestSuperMethods()) {
final List<PsiMethod> superMethods = new ArrayList<PsiMethod>(Arrays.asList(method.findDeepestSuperMethods()));
if (superMethods.isEmpty()) {
superMethods.add(method);
}
for (PsiMethod superMethod : superMethods) {
parametersToDelete.add(superMethod.getParameterList().getParameters()[parameterIndex]);
OverridingMethodsSearch.search(superMethod).forEach(new Processor<PsiMethod>() {
public boolean process(PsiMethod overrider) {
@@ -0,0 +1,5 @@
public class C1 implements I {
public void f(int a1) {
}
}
@@ -0,0 +1,3 @@
public interface I {
void f(int a1);
}
@@ -0,0 +1,5 @@
public class C2 extends C1 {
public void f(int a1) {
super.f(a1 );
}
}
@@ -0,0 +1,5 @@
public class C1 implements I {
public void f(int a1, int a2) {
}
}
@@ -0,0 +1,3 @@
public interface I {
void f(int a1, int a<caret>2);
}
@@ -0,0 +1,5 @@
public class C2 extends C1 {
public void f(int a1, int a2) {
super.f(a1, a2);
}
}
@@ -62,6 +62,11 @@ public class SafeDeleteTest extends MultiFileTestCase {
doTest("C2");
}
public void testTopParameterInHierarchy() throws Exception {
myDoCompare = false;
doTest("I");
}
public void testExtendsList() throws Exception {
myDoCompare = false;
doTest("B");