void (Module module, Consumer<MavenDomProjectModel> artifactIdReplacer) { if (!myProjectsManager.isMavenizedModule(module)) return; var mavenProject = myProjectsManager.findProject(module); if (null == mavenProject) return; var mavenModel = MavenDomUtil.getMavenDomProjectModel(myProject, mavenProject.getFile()); if (null == mavenModel) return; var psiFile = DomUtil.getFile(mavenModel); WriteCommandAction.writeCommandAction(myProject, psiFile).run(() -> { PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject); Document document = documentManager.getDocument(psiFile); if (document != null) { documentManager.commitDocument(document); } artifactIdReplacer.accept(mavenModel); if (document != null) { FileDocumentManager.getInstance().saveDocument(document); } }); }