public static void modifyModuleStatements(@NotNull Map<PsiJavaModule, List<ModifyModuleStatementUsageInfo>> moduleStatementsByDescriptor) {
    if (moduleStatementsByDescriptor.isEmpty()) return;
    MultiMap<PsiJavaModule, ModifyModuleStatementUsageInfo> lastDeletionUsageInfos = new MultiMap<>();
    for (var entry : moduleStatementsByDescriptor.entrySet()) {
      PsiJavaModule moduleDescriptor = entry.getKey();
      for (ModifyModuleStatementUsageInfo modifyStatementInfo : entry.getValue()) {
        if (modifyStatementInfo.getModuleStatement() == null) continue;
        if (modifyStatementInfo.isAddition()) {
          PsiUtil.addModuleStatement(moduleDescriptor, modifyStatementInfo.getModuleStatement());
        }
        else if (modifyStatementInfo.isLastDeletion()) {
          lastDeletionUsageInfos.putValue(moduleDescriptor, modifyStatementInfo);
        }
        else if (modifyStatementInfo.isDeletion()) {
          deleteModuleStatements(moduleDescriptor, Set.of(modifyStatementInfo.getModuleStatement().getText()));
        }
      }
    }
    if (lastDeletionUsageInfos.isEmpty()) return;
    PsiJavaModule firstModule = lastDeletionUsageInfos.keySet().iterator().next();
    Project project = firstModule.getProject();
    String projectPath = project.getBasePath();
    if (projectPath == null) return;
    MultiMap<String, String> packageStatementsByModulePath = MultiMap.createSet();
    for (var entry : lastDeletionUsageInfos.entrySet()) {
      for (ModifyModuleStatementUsageInfo usageInfo : entry.getValue()) {
        PsiPackageAccessibilityStatement packageStatement = usageInfo.getModuleStatement();
        if (packageStatement == null) continue;
        VirtualFile moduleFile = entry.getKey().getContainingFile().getVirtualFile();
        if (moduleFile != null) {
          packageStatementsByModulePath.putValue(moduleFile.getPath(), packageStatement.getText());
        }
      }
    }
    NotificationGroupManager.getInstance()
      .getNotificationGroup("Remove redundant exports/opens")
      .createNotification(
        JavaRefactoringBundle.message("move.classes.or.packages.unused.exports.notification.title", lastDeletionUsageInfos.size()),
        createNotificationContent(projectPath, lastDeletionUsageInfos.keySet()),
        NotificationType.INFORMATION)
      .setListener((notification, event) -> {
        PsiJavaModule moduleDescriptor = findModuleByPath(project, event.getDescription());
        if (moduleDescriptor != null) {
          moduleDescriptor.navigate(true);
        }
      })
      .addAction(new NotificationAction(JavaRefactoringBundle.message("move.classes.or.packages.unused.exports.action.name")) {
        @Override
        public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
          WriteCommandAction.writeCommandAction(project)
            .withName(JavaRefactoringBundle.message("move.classes.or.packages.unused.exports.command.name"))
            .withUndoConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION)
            .withGlobalUndo()
            .run(() -> {
              for (var entry : packageStatementsByModulePath.entrySet()) {
                PsiJavaModule moduleDescriptor = findModuleByPath(project, entry.getKey());
                if (moduleDescriptor != null) {
                  deleteModuleStatements(moduleDescriptor, (Set<String>)entry.getValue());
                }
              }
            });
          notification.expire();
        }
      })
      .notify(project);
  }
public static void modifyModuleStatements(@NotNull Map<PsiJavaModule, List<ModifyModuleStatementUsageInfo>> moduleStatementsByDescriptor)