AnnotationPlace (@NotNull String annotation, @NotNull PsiModifierListOwner modifierListOwner) { Project project = modifierListOwner.getProject(); final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project); if (BaseIntentionAction.canModify(modifierListOwner)) { PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(annotation, modifierListOwner.getResolveScope()); if (aClass != null) { if (AnnotationsHighlightUtil.getRetentionPolicy(aClass) == RetentionPolicy.RUNTIME) { return AnnotationPlace.IN_CODE; } if (!CommonClassNames.DEFAULT_PACKAGE.equals(StringUtil.getPackageName(annotation))) { PsiClass resolvedBySimpleName = JavaPsiFacade.getInstance(project).getResolveHelper() .resolveReferencedClass(StringUtil.getShortName(annotation), modifierListOwner); if (resolvedBySimpleName != null && resolvedBySimpleName.getManager().areElementsEquivalent(resolvedBySimpleName, aClass)) { // if class is already imported in current file return AnnotationPlace.IN_CODE; } } } } return annotationsManager.chooseAnnotationsPlaceNoUi(modifierListOwner); }