@Nullable
  @RequiresBackgroundThread
  private static ActionContext chooseContextForAction(@NotNull PsiFile hostFile,
                                                      @Nullable Editor hostEditor,
                                                      @NotNull ModCommandAction commandAction,
                                                      int fixOffset) {
    if (hostEditor == null) {
      return ActionContext.from(null, hostFile);
    }
    int offset = fixOffset >= 0 ? fixOffset : hostEditor.getCaretModel().getOffset();
    ActionContext hostContext = ActionContext.from(hostEditor, hostFile).withOffset(offset);
    PsiFile injectedFile = InjectedLanguageUtilBase.findInjectedPsiNoCommit(hostFile, offset);
    if (injectedFile != null) {
      ActionContext injectedContext = hostContext.mapToInjected(injectedFile);
      if (commandAction.getPresentation(injectedContext) != null) {
        return injectedContext;
      }
    }

    if (commandAction.getPresentation(hostContext) != null) {
      return hostContext.withOffset(offset);
    }
    return null;
  }
@Nullable
  @RequiresBackgroundThread
  private static ActionContext chooseContextForAction(@NotNull PsiFile hostFile,
                                                      @Nullable Editor hostEditor,
                                                      @NotNull ModCommandAction commandAction,
                                                      int fixOffset)