ModCommand (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiAnnotation annotation = myAnnotation.getElement(); if (annotation == null) return ModCommand.nop(); PsiModifierListOwner listOwner = myListOwner == null ? null : myListOwner.getElement(); String qualifiedName = annotation.getQualifiedName(); List<PsiAnnotation> physical = new ArrayList<>(); List<PsiModifierListOwner> externalOwners = new ArrayList<>(); registerAnnotation(annotation, listOwner, physical, externalOwners); if (myRemoveInheritors && qualifiedName != null && !IntentionPreviewUtils.isIntentionPreviewActive()) { if (listOwner instanceof PsiMethod method) { for (PsiMethod psiMethod : OverridingMethodsSearch.search(method)) { if (psiMethod.isPhysical() && !NullableStuffInspectionBase.shouldSkipOverriderAsGenerated(psiMethod)) { registerAnnotation(AnnotationUtil.findAnnotation(psiMethod, qualifiedName), psiMethod, physical, externalOwners); } } } else if (listOwner instanceof PsiParameter parameter) { PsiMethod method = ObjectUtils.tryCast(parameter.getDeclarationScope(), PsiMethod.class); if (method == null) return ModCommand.nop(); int index = method.getParameterList().getParameterIndex(parameter); if (index < 0) return ModCommand.nop(); for (PsiMethod psiMethod : OverridingMethodsSearch.search(method)) { if (psiMethod.isPhysical() && !NullableStuffInspectionBase.shouldSkipOverriderAsGenerated(psiMethod)) { PsiParameter subParameter = psiMethod.getParameterList().getParameter(index); if (subParameter != null) { registerAnnotation(AnnotationUtil.findAnnotation(subParameter, qualifiedName), subParameter, physical, externalOwners); } } } } } return ModCommand.psiUpdate(ActionContext.from(descriptor), updater -> { List<PsiAnnotation> annotations = ContainerUtil.map(physical, updater::getWritable); Set<PsiJavaFile> containingFiles = StreamEx.of(annotations).map(PsiAnnotation::getContainingFile).select(PsiJavaFile.class).toSet(); annotations.forEach(PsiAnnotation::delete); containingFiles.forEach(JavaCodeStyleManager.getInstance(project)::removeRedundantImports); }).andThen(deannotateExternal(project, qualifiedName, externalOwners)); }