mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
safe delete: remove @Override annotation when method is made private
This commit is contained in:
+6
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.refactoring.safeDelete.usageInfo;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -34,5 +36,9 @@ public class SafeDeletePrivatizeMethod extends SafeDeleteUsageInfo implements Sa
|
||||
|
||||
public void performRefactoring() throws IncorrectOperationException {
|
||||
PsiUtil.setModifierProperty(getMethod(), PsiModifier.PRIVATE, true);
|
||||
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(getMethod(), true, Override.class.getName());
|
||||
if (annotation != null) {
|
||||
annotation.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
interface Am {
|
||||
String getIc<caret>on();
|
||||
}
|
||||
|
||||
class AIIm implements Am {
|
||||
@Override
|
||||
public String getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AIIm().getIcon();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
interface Am {
|
||||
}
|
||||
|
||||
class AIIm implements Am {
|
||||
private String getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AIIm().getIcon();
|
||||
}
|
||||
}
|
||||
@@ -144,6 +144,10 @@ public class SafeDeleteTest extends MultiFileTestCase {
|
||||
doSingleFileTest();
|
||||
}
|
||||
|
||||
public void testStripOverride() throws Exception {
|
||||
doSingleFileTest();
|
||||
}
|
||||
|
||||
private void doTest(@NonNls final String qClassName) throws Exception {
|
||||
doTest(new PerformAction() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user