void (@NotNull PsiCodeBlock body, @NotNull ModPsiUpdater updater) { PsiElement l = PsiTreeUtil.skipWhitespacesForward(body.getLBrace()); PsiElement r = PsiTreeUtil.skipWhitespacesBackward(body.getRBrace()); if (l != null && r != null) { int start = l.getTextRange().getStartOffset(); int end = r.getTextRange().getEndOffset(); updater.moveTo(Math.max(start, end)); if (end < start) { updater.moveTo(end + 1); CodeStyleManager styleManager = CodeStyleManager.getInstance(body.getProject()); PsiFile containingFile = body.getContainingFile(); final String lineIndent = Objects.requireNonNullElse(styleManager.getLineIndent(containingFile, end), ""); PsiDocumentManager manager = PsiDocumentManager.getInstance(body.getProject()); Document document = body.getContainingFile().getViewProvider().getDocument(); manager.doPostponedOperationsAndUnblockDocument(document); document.insertString(updater.getCaretOffset(), lineIndent + "\n"); updater.moveTo(updater.getCaretOffset() + lineIndent.length()); } else { //correct position caret for groovy and java methods if (body.getParent() instanceof PsiMethod) { final PsiGenerationInfo<PsiMethod> info = OverrideImplementUtil.createGenerationInfo((PsiMethod)body.getParent()); info.positionCaret(updater, true); } } } }