mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make static: ensure @Override is cleared from static method (IDEA-146872)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.refactoring.makeStatic;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.TestFrameworks;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -211,6 +212,10 @@ public class MakeMethodStaticProcessor extends MakeMethodOrClassStaticProcessor<
|
||||
}
|
||||
|
||||
private void makeStatic(PsiMethod member) {
|
||||
final PsiAnnotation overrideAnnotation = AnnotationUtil.findAnnotation(member, CommonClassNames.JAVA_LANG_OVERRIDE);
|
||||
if (overrideAnnotation != null) {
|
||||
overrideAnnotation.delete();
|
||||
}
|
||||
setupTypeParameterList(member);
|
||||
// Add static modifier
|
||||
final PsiModifierList modifierList = member.getModifierList();
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
interface A {
|
||||
void foo();
|
||||
}
|
||||
|
||||
class B implements A {
|
||||
@Override
|
||||
public void foo() {
|
||||
foo(this);
|
||||
}
|
||||
|
||||
public static void foo(B anObject) {}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
interface A {
|
||||
void foo();
|
||||
}
|
||||
|
||||
class B implements A {
|
||||
@Override
|
||||
public void f<caret>oo() {}
|
||||
}
|
||||
@@ -215,6 +215,10 @@ public class MakeMethodStaticTest extends LightRefactoringTestCase {
|
||||
doTest(true, true);
|
||||
}
|
||||
|
||||
public void testClearOverrideAnnotation() throws Exception {
|
||||
doTest(true, true);
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user