type annotations: skip type annotation in generated code if it also has normal applicable targets (IDEA-206570)

GitOrigin-RevId: 651526af474d80f2664229f8c000c790152b3f0d
This commit is contained in:
Anna Kozlova
2021-01-11 08:55:48 +01:00
committed by intellij-monorepo-bot
parent 7793b16164
commit d66d66d259
8 changed files with 79 additions and 40 deletions

View File

@@ -113,13 +113,12 @@ public abstract class NullableNotNullManager {
return null;
}
PsiModifierList modifierList = target.getModifierList();
// type annotations are part of target's type and should not to be copied explicitly to avoid duplication
if (!AnnotationTargetUtil.isTypeAnnotation(annotation)) {
PsiModifierList modifierList = target.getModifierList();
if (modifierList != null && !modifierList.hasAnnotation(qualifiedName)) {
return modifierList.addAnnotation(qualifiedName);
}
if (modifierList != null &&
!AnnotationTargetUtil.isStrictlyTypeUseAnnotation(modifierList, annotation) &&
!modifierList.hasAnnotation(qualifiedName)) {
return modifierList.addAnnotation(qualifiedName);
}
}