String (@NotNull GrAnnotation annotation, @Nullable PsiAnnotationOwner owner) { if (!(owner instanceof PsiElement)) return null; PsiElement ownerToUse = owner instanceof PsiModifierList ? ((PsiElement)owner).getParent() : (PsiElement)owner; PsiAnnotation.TargetType[] elementTypeFields = GrAnnotationImpl.getApplicableElementTypeFields(ownerToUse); if (elementTypeFields.length != 0 && !GrAnnotationImpl.isAnnotationApplicableTo(annotation, elementTypeFields)) { String annotationTargetText = JavaAnalysisBundle.message("annotation.target." + elementTypeFields[0]); GrCodeReferenceElement ref = annotation.getClassReference(); return JavaErrorBundle.message("annotation.not.applicable", ref.getText(), annotationTargetText); } return null; }