public static boolean chooseActionAndInvoke(@NotNull PsiFile hostFile,
                                              @Nullable Editor hostEditor,
                                              @NotNull IntentionAction action,
                                              @NotNull @NlsContexts.Command String commandName,
                                              int fixOffset) {
    Project project = hostFile.getProject();
    ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getFixesStats().registerInvocation();

    try (AccessToken ignore = SlowOperations.startSection(SlowOperations.ACTION_PERFORM)) {
      PsiDocumentManager.getInstance(project).commitAllDocuments();
      ModCommandAction commandAction = action.asModCommandAction();
      if (commandAction != null) {
        invokeCommandAction(hostFile, hostEditor, commandName, commandAction, fixOffset);
      }
      else {
        Pair<PsiFile, Editor> pair = chooseFileForAction(hostFile, hostEditor, action);
        if (pair == null) return false;
        CommandProcessor.getInstance().executeCommand(project, () ->
          invokeIntention(action, pair.second, pair.first, fixOffset), commandName, null);
        checkPsiTextConsistency(hostFile);
      }
    }
    return true;
  }
public static boolean chooseActionAndInvoke(@NotNull PsiFile hostFile,
                                              @Nullable Editor hostEditor,
                                              @NotNull IntentionAction action,
                                              @NotNull @NlsContexts.Command String commandName,
                                              int fixOffset)