private static void runModCommands(@Nullable Editor editor,
                                     @NotNull PsiFile file,
                                     @Nls String actionName,
                                     @NotNull List<Pair<ModCommandAction, SmartPsiFileRange>> modCommands) {
    Project project = file.getProject();
    Document document = file.getFileDocument();
    PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
    final SequentialModalProgressTask progressTask =
      new SequentialModalProgressTask(project, actionName, true);
    progressTask.setMinIterationTime(200);
    SequentialTask task = new SequentialTask() {
      int fixNumber = 0;

      @Override
      public boolean isDone() {
        return fixNumber >= modCommands.size();
      }

      @Override
      public boolean iteration(@NotNull ProgressIndicator indicator) {
        indicator.setFraction(((double)fixNumber) / modCommands.size());
        return iteration();
      }

      @Override
      public boolean iteration() {
        Pair<ModCommandAction, SmartPsiFileRange> pair = modCommands.get(fixNumber++);
        Segment range = pair.getSecond().getRange();
        if (range != null) {
          ModCommandWithContext contextAndCommand =
            ModCommandService.getInstance().chooseFileAndPerform(file, editor, pair.first, range.getStartOffset());
          if (contextAndCommand == null) return true;
          contextAndCommand.executeInBatch();
          psiDocumentManager.doPostponedOperationsAndUnblockDocument(document);
          psiDocumentManager.commitDocument(document);
        }
        return fixNumber == modCommands.size();
      }
    };
    progressTask.setTask(task);
    ProgressManager.getInstance().run(progressTask);
  }
private static void runModCommands(@Nullable Editor editor,
                                     @NotNull PsiFile file,
                                     @Nls String actionName,
                                     @NotNull List<Pair<ModCommandAction, SmartPsiFileRange>> modCommands)