AnAction updateAutoCloseAndCheckImpl() {
    final Application app = ApplicationManager.getApplication();
    if (app == null || app.isDisposed() || myAutoCloseActions == null) {
      return null;
    }

    for (AnAction action: myAutoCloseActions) {
      ProgressManager.checkCanceled();
      Presentation presentation = myFactory.getPresentation(action);
      presentation.setEnabledAndVisible(true);

      final @NotNull DataContext dataContext = DataManager.getInstance().getDataContext(Helpers.getCurrentFocusComponent());
      AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.TOUCHBAR_GENERAL, presentation,
                                              ActionManager.getInstance(), 0, false, true);
      event.setInjectedContext(action.isInInjectedContext());

      final boolean result;
      try {
        result = !ActionUtil.performDumbAwareUpdate(action, event, false);
      } catch (Throwable exc) {
        continue;
      }
      if (!result) {
        continue;
      }
      if (!presentation.isEnabledAndVisible()) {
        return action;
      }
    }

    // all presentations of autoclose actions are successfully updated, and they are enabled and visible
    return null;
  }
AnAction updateAutoCloseAndCheckImpl()