public static void invalidateCachesAndRestart(@Nullable Project project) {
    ApplicationEx app = ApplicationManagerEx.getApplicationEx();
    boolean canRestart = app.isRestartCapable();

    var dialog = new InvalidateCachesDialog(project,
                                            canRestart,
                                            CachesInvalidator.EP_NAME.getExtensionList()
    );

    dialog.show();

    var invalidators = dialog.getSelectedInvalidators();
    if (dialog.isOK()) {
      invalidateCaches(invalidators::contains);
    }

    if (dialog.isOK() || dialog.isRestartOnly()) {
      app.restart(true);
    }
  }
public static void invalidateCachesAndRestart(@Nullable Project project)