mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
pull up: delete @Override annotation if it is inappropriate in new hierarchy (IDEA-97598)
This commit is contained in:
@@ -219,7 +219,7 @@ public class PullUpHelper extends BaseRefactoringProcessor{
|
||||
if (info.getMember() instanceof PsiMethod) {
|
||||
PsiMethod method = (PsiMethod)info.getMember();
|
||||
PsiMethod methodCopy = (PsiMethod)method.copy();
|
||||
if (method.findDeepestSuperMethods().length == 0) {
|
||||
if (method.findSuperMethods(myTargetSuperClass).length == 0) {
|
||||
deleteOverrideAnnotationIfFound(methodCopy);
|
||||
}
|
||||
final boolean isOriginalMethodAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT) || method.hasModifierProperty(PsiModifier.DEFAULT);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
abstract class Bazz {
|
||||
public abstract void foo();
|
||||
}
|
||||
|
||||
abstract class Foo extends Bazz {}
|
||||
|
||||
class Bar extends Foo {
|
||||
@Override
|
||||
public void f<caret>oo() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
abstract class Bazz {
|
||||
public abstract void foo();
|
||||
}
|
||||
|
||||
abstract class Foo extends Bazz {
|
||||
@Override
|
||||
public void foo() {
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
}
|
||||
|
||||
@@ -138,6 +138,10 @@ public class PullUpTest extends LightRefactoringTestCase {
|
||||
doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class));
|
||||
}
|
||||
|
||||
public void testPreserveOverride() {
|
||||
doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class));
|
||||
}
|
||||
|
||||
private void doTest(RefactoringTestUtil.MemberDescriptor... membersToFind) {
|
||||
doTest(true, membersToFind);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user