private static @NotNull Runnable applyRunnable(final @NotNull Project project, final @NotNull Computable<UsageInfo[]> computable) {
    return () -> {
      final LocalHistoryAction action = LocalHistory.getInstance().startAction(
        JavaBundle.message("action.description.infer.nullity.annotations"));
      try {
        ReadAction.run(() -> {
          final UsageInfo[] infos = computable.compute();
          if (infos.length > 0) {
            var command = new Runnable() {
              private int myCount;

              @Override
              public void run() {
                final Set<VirtualFile> files =
                  StreamEx.of(infos).map(UsageInfo::getElement).nonNull()
                    .map(PsiElement::getContainingFile).nonNull()
                    .map(PsiFile::getVirtualFile).nonNull()
                    .toCollection(LinkedHashSet::new);
                if (!FileModificationService.getInstance().prepareVirtualFilesForWrite(project, files)) return;

                final SequentialModalProgressTask progressTask = new SequentialModalProgressTask(project, JavaBundle
                  .message("action.title.infer.nullity.annotations"));
                progressTask.setMinIterationTime(200);
                AnnotateTask task = new AnnotateTask(project, progressTask, infos);
                progressTask.setTask(task);
                ProgressManager.getInstance().run(progressTask);
                myCount = task.getAddedCount();
              }
            };
            CommandProcessor.getInstance()
              .executeCommand(project, command, JavaBundle.message("action.title.infer.nullity.annotations"), null);
            if (command.myCount == 0) {
              NullityInferrer.nothingFoundMessage(project);
            } else {
              NOTIFICATION_GROUP.createNotification(JavaBundle.message("notification.content.added.annotations", command.myCount),
                                                    NotificationType.INFORMATION)
                .notify(project);
            }
          }
          else {
            NullityInferrer.nothingFoundMessage(project);
          }
        });
      }
      finally {
        action.finish();
      }
    };
  }
private static @NotNull Runnable applyRunnable(final @NotNull Project project, final @NotNull Computable<UsageInfo[]> computable)