private static void invokeIntention(@NotNull IntentionAction action, @Nullable Editor editor, @NotNull PsiFile file, int fixOffset) {
    IntentionFUSCollector.record(file.getProject(), action, file.getLanguage(), editor, fixOffset);
    PsiElement elementToMakeWritable = action.getElementToMakeWritable(file);
    if (elementToMakeWritable != null && !FileModificationService.getInstance().preparePsiElementsForWrite(elementToMakeWritable)) {
      return;
    }
    SmartPsiFileRange originalOffset = null;
    if (editor != null && fixOffset >= 0) {
      originalOffset = SmartPointerManager.getInstance(file.getProject())
        .createSmartPsiFileRangePointer(file, TextRange.from(editor.getCaretModel().getOffset(), 0));
      editor.getCaretModel().moveToOffset(fixOffset);
    }
    try {
      if (action.startInWriteAction()) {
        WriteAction.run(() -> action.invoke(file.getProject(), editor, file));
      }
      else {
        action.invoke(file.getProject(), editor, file);
      }
    }
    finally {
      if (originalOffset != null && originalOffset.getRange() != null && editor.getCaretModel().getOffset() == fixOffset &&
          TemplateManager.getInstance(file.getProject()).getActiveTemplate(editor) == null) {
        editor.getCaretModel().moveToOffset(originalOffset.getRange().getStartOffset());
      }
    }
  }
private static void invokeIntention(@NotNull IntentionAction action, @Nullable Editor editor, @NotNull PsiFile file, int fixOffset)