mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
push down: copy annotations when method is removed from super (IDEA-190923)
This commit is contained in:
@@ -589,6 +589,13 @@ public class GenerateMembersUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyAnnotations(@NotNull PsiModifierListOwner source, @NotNull PsiModifierListOwner target, String... skipAnnotations) {
|
||||
PsiModifierList targetModifierList = target.getModifierList();
|
||||
PsiModifierList sourceModifierList = source.getModifierList();
|
||||
if (targetModifierList == null || sourceModifierList == null) return;
|
||||
copyAnnotations(sourceModifierList, targetModifierList, skipAnnotations);
|
||||
}
|
||||
|
||||
//java bean getters/setters
|
||||
public static PsiMethod generateSimpleGetterPrototype(@NotNull PsiField field) {
|
||||
return generatePrototype(field, PropertyUtilBase.generateGetterPrototype(field));
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.refactoring.memberPushDown;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.ChangeContextUtil;
|
||||
import com.intellij.codeInsight.generation.GenerateMembersUtil;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.codeInsight.intention.impl.CreateClassDialog;
|
||||
import com.intellij.codeInsight.intention.impl.CreateSubclassAction;
|
||||
@@ -277,6 +278,12 @@ public class JavaPushDownDelegate extends PushDownDelegate<MemberInfo, PsiMember
|
||||
if (annotation != null && !leaveOverrideAnnotation(sourceClass, substitutor, method)) {
|
||||
annotation.delete();
|
||||
}
|
||||
PsiParameter[] sourceParameters = method.getParameterList().getParameters();
|
||||
PsiParameter[] targetParameters = methodBySignature.getParameterList().getParameters();
|
||||
for (int i = 0; i < sourceParameters.length; i++) {
|
||||
GenerateMembersUtil.copyAnnotations(sourceParameters[i], targetParameters[i]);
|
||||
}
|
||||
GenerateMembersUtil.copyAnnotations(method, methodBySignature);
|
||||
}
|
||||
final PsiDocComment oldDocComment = method.getDocComment();
|
||||
if (oldDocComment != null) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
@interface Ann {}
|
||||
interface I {
|
||||
void <caret>m(@Ann String s);
|
||||
}
|
||||
|
||||
class IImpl implements I {
|
||||
@Override
|
||||
public void m(String s) { }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
@interface Ann {}
|
||||
interface I {
|
||||
}
|
||||
|
||||
class IImpl implements I {
|
||||
public void m(@Ann String s) { }
|
||||
}
|
||||
@@ -81,6 +81,7 @@ public class PushDownTest extends LightRefactoringTestCase {
|
||||
public void testInterfaceStaticMethodToClass() { doTest(); }
|
||||
public void testThisSuperExpressions() {doTest();}
|
||||
public void testMethodsInheritedFromSuper() {doTest();}
|
||||
public void testCopyAnnotationsFromSuper() {doTest();}
|
||||
|
||||
public void testInterfaceMethodToClass() { doTest();}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user