@Nullable public static String isAnnotationApplicable( @NotNull GrAnnotation annotation, final PsiElement parent) { PsiElement owner = parent.getParent(); final PsiElement ownerToUse = parent instanceof PsiModifierList ? owner : parent; String[] elementTypeFields = GrAnnotationImpl.getApplicableElementTypeFields(ownerToUse); if (elementTypeFields != null && !GrAnnotationImpl.isAnnotationApplicableTo(annotation, false, elementTypeFields)) { final String annotationTargetText = JavaErrorMessages.message("annotation.target." + elementTypeFields[0]); GrCodeReferenceElement ref = annotation.getClassReference(); return JavaErrorMessages.message( "annotation.not.applicable", ref.getText(), annotationTargetText); } return null; }