boolean (@NotNull ProjectEx project, @Nullable Module module, String newName) { if (shouldRenameProject(project, module, newName)) { project.setProjectName(newName); project.save(); } if (module != null && !newName.equals(module.getName())) { final ModifiableModuleModel modifiableModel = ModuleManager.getInstance(project).getModifiableModel(); try { modifiableModel.renameModule(module, newName); } catch (ModuleWithNameAlreadyExists moduleWithNameAlreadyExists) { Messages.showErrorDialog(project, IdeBundle.message("error.module.already.exists", newName), IdeBundle.message("title.rename.module")); return false; } final Ref<Boolean> success = Ref.create(Boolean.TRUE); CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> modifiableModel.commit()), IdeBundle.message("command.renaming.module", module.getName()), null); return success.get().booleanValue(); } return true; }