private static void commitAndRunInSmartMode(Runnable runnable, Project project) {
    while (true) {
      DumbService dumbService = DumbService.getInstance(project);
      dumbService.waitForSmartMode();
      boolean passed = PsiDocumentManager.getInstance(project).commitAndRunReadAction(() -> {
        if (dumbService.isDumb()) return false;
        runnable.run();
        return true;
      });
      if (passed) {
        break;
      }
    }
  }
private static void commitAndRunInSmartMode(Runnable runnable, Project project)