void (@NotNull Project project, PsiFile file, PsiModifierListOwner owner) { if (!FileModificationService.getInstance().preparePsiElementForWrite(owner)) return; final Module module = ModuleUtilCore.findModuleForPsiElement(file); assert module != null; // Inferred annotations are non-physical, so we can pass them between actions List<PsiAnnotation> annotations = getAnnotationsToAdd(owner); if (needToAddDependency(file, annotations)) { SmartPsiElementPointer<PsiModifierListOwner> ownerPointer = SmartPointerManager.createPointer(owner); InferNullityAnnotationsAction.addAnnotationsDependency(project, Collections.singleton(module), AnnotationUtil.NOT_NULL, getFamilyName()) .onSuccess(__ -> ApplicationManager.getApplication() .invokeLater(() -> doStartWriteAction(project, file, ownerPointer.getElement(), annotations), ModalityState.nonModal(), module.getDisposed())); return; } doStartWriteAction(project, file, owner, annotations); }