private static void cancelAndRestartDaemonLater(@NotNull ProgressIndicator progress, @NotNull Project project) throws ProcessCanceledException {
    RESTART_REQUESTS.incrementAndGet();
    progress.cancel();
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      RESTART_REQUESTS.decrementAndGet();
      if (!project.isDisposed()) {
        DaemonCodeAnalyzer.getInstance(project).restart();
      }
    }
    else {
      int delay = RESTART_DAEMON_RANDOM.nextInt(100);
      EdtExecutorService.getScheduledExecutorInstance().schedule(() -> {
        RESTART_REQUESTS.decrementAndGet();
        if (!project.isDisposed()) {
          DaemonCodeAnalyzer.getInstance(project).restart();
        }
      }, delay, TimeUnit.MILLISECONDS);
    }
    throw new ProcessCanceledException();
  }
private static void cancelAndRestartDaemonLater(@NotNull ProgressIndicator progress, @NotNull Project project)