@Override
  protected void invoke(@NotNull ActionContext context, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) {
    PsiClass recordClass;
    PsiElement toReplace = startElement;
    if (startElement instanceof PsiJavaCodeReferenceElement ref && ref.textMatches("record")) {
      PsiMethod method = PsiTreeUtil.getParentOfType(startElement, PsiMethod.class);
      if (method == null) return;
      recordClass = tryMakeRecord(method);
      toReplace = method;
    } else {
      recordClass = ObjectUtils.tryCast(startElement, PsiClass.class);
    }
    if (recordClass == null || !recordClass.isRecord()) return;

    String recordClassText = generateText(recordClass);
    JavaDummyElement dummyElement = new JavaDummyElement(
      recordClassText, builder -> JavaParser.INSTANCE.getDeclarationParser().parse(builder, DeclarationParser.Context.CLASS),
      LanguageLevel.JDK_16);
    Project project = context.project();
    PsiFile file = startElement.getContainingFile();
    DummyHolder holder = DummyHolderFactory.createHolder(file.getManager(), dummyElement, recordClass);
    PsiClass converted = (PsiClass)Objects.requireNonNull(SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode()));
    postProcessAnnotations(recordClass, converted);
    PsiClass result = (PsiClass)toReplace.replace(converted);
    CodeStyleManager.getInstance(project).reformat(JavaCodeStyleManager.getInstance(project).shortenClassReferences(result));
  }
@Override
  protected void invoke(@NotNull ActionContext context, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater)