ModCommand (@NotNull ActionContext context) { final PsiElement leaf = context.findLeaf(); final PsiFile file = context.file(); final Project project = context.project(); final PsiModifierListOwner owner = NonCodeAnnotationsLineMarkerProvider.getAnnotationOwner(leaf); assert owner != null; final PsiModifierList modifierList = owner.getModifierList(); assert modifierList != null; final Module module = ModuleUtilCore.findModuleForPsiElement(file); assert module != null; ModCommandAwareExternalAnnotationsManager externalAnnotationsManager = ObjectUtils.tryCast( ExternalAnnotationsManager.getInstance(project), ModCommandAwareExternalAnnotationsManager.class); PsiAnnotation[] annotations = getAnnotations(project, owner); return ModCommand.psiUpdate(modifierList, writableList -> { for (PsiAnnotation anno : annotations) { JavaCodeStyleManager.getInstance(project).shortenClassReferences(writableList.addAfter(anno, null)); } }).andThen(externalAnnotationsManager == null ? ModCommand.nop() : externalAnnotationsManager.deannotateModCommand(List.of(owner), ContainerUtil.map(annotations, PsiAnnotation::getQualifiedName))); }