From ec3d956aa1e179a2ca51bca3d930366d3b414d65 Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Fri, 21 Sep 2018 19:20:00 +0200 Subject: [PATCH] allow override implementation handlers to customize result https://github.com/JetBrains/intellij-community/pull/824 --- .../OverrideImplementsAnnotationsHandler.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementsAnnotationsHandler.java b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementsAnnotationsHandler.java index 64babe619cd3..3cd230e141a1 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementsAnnotationsHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementsAnnotationsHandler.java @@ -56,14 +56,17 @@ public interface OverrideImplementsAnnotationsHandler { int flags = CHECK_EXTERNAL | CHECK_TYPE; if (AnnotationUtil.isAnnotated(source, annotation, flags) && !AnnotationUtil.isAnnotated(target, annotation, flags)) { - PsiModifierList modifierList = target.getModifierList(); - assert modifierList != null : target; - PsiAnnotation srcAnnotation = AnnotationUtil.findAnnotation(source, annotation); - PsiNameValuePair[] valuePairs = srcAnnotation != null ? srcAnnotation.getParameterList().getAttributes() - : PsiNameValuePair.EMPTY_ARRAY; - AddAnnotationPsiFix.addPhysicalAnnotation(annotation, valuePairs, modifierList); + each.transferToTarget(annotation, source, target); } } } } + + default void transferToTarget(String annotation, PsiModifierListOwner source, PsiModifierListOwner target) { + PsiModifierList modifierList = target.getModifierList(); + assert modifierList != null : target; + PsiAnnotation srcAnnotation = AnnotationUtil.findAnnotation(source, annotation); + PsiNameValuePair[] valuePairs = srcAnnotation != null ? srcAnnotation.getParameterList().getAttributes() : PsiNameValuePair.EMPTY_ARRAY; + AddAnnotationPsiFix.addPhysicalAnnotation(annotation, valuePairs, modifierList); + } } \ No newline at end of file