void (@NotNull ActionContext context, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiMethod method = getMethod(element); if (method == null) return; PsiClass recordClass = method.getContainingClass(); if (recordClass == null) return; PsiMethod prototype = generateCanonicalConstructor(method); PsiCodeBlock oldBody = Objects.requireNonNull(method.getBody()); PsiCodeBlock body = Objects.requireNonNull(prototype.getBody()); int offset = context.offset(); if (oldBody.getTextRange().contains(offset)) { offset += body.getTextRangeInParent().getStartOffset() - oldBody.getTextRangeInParent().getStartOffset(); } method.replace(prototype); updater.moveTo(offset); }