change signature: remove @Override if only overrider was changed (IDEA-154669)

This commit is contained in:
Anna.Kozlova
2016-04-13 21:11:02 +02:00
parent 6f2e582af7
commit 2a9a2e6568
6 changed files with 42 additions and 0 deletions
@@ -770,6 +770,13 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
final PsiClassType[] newExceptions = getPrimaryChangedExceptionInfo(changeInfo);
fixPrimaryThrowsLists(method, newExceptions);
}
if (baseMethod == null && method.findSuperMethods().length == 0) {
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, true, Override.class.getName());
if (annotation != null) {
annotation.delete();
}
}
}
private static int processMethodParams(JavaChangeInfo changeInfo,
@@ -0,0 +1,7 @@
class A {
public void <caret>foo(int i) {}
}
class Test extends A {
@Override
public void foo(int i) {}
}
@@ -0,0 +1,7 @@
class A {
public void <caret>foo() {}
}
class Test extends A {
@Override
public void foo() {}
}
@@ -0,0 +1,7 @@
class A {
public void foo(int i) {}
}
class Test extends A {
@Override
public void <caret>foo(int i) {}
}
@@ -0,0 +1,6 @@
class A {
public void foo(int i) {}
}
class Test extends A {
public void <caret>foo() {}
}
@@ -376,6 +376,14 @@ public class ChangeSignatureTest extends ChangeSignatureBaseTest {
doTest(null, null, "Exception", new SimpleParameterGen(), new SimpleExceptionsGen(), false);
}
public void testRemoveOverride() {
doTest(null, null, null, new ParameterInfoImpl[0], new ThrownExceptionInfo[0], false);
}
public void testPreserveOverride() {
doTest(null, null, null, new ParameterInfoImpl[0], new ThrownExceptionInfo[0], false);
}
public void testVisibilityOfOverriddenMethod() {
doTest(PsiModifier.PACKAGE_LOCAL, "foo", "void", new ParameterInfoImpl[0], new ThrownExceptionInfo[0], false);
}