boolean (@NotNull Editor editor, @Nullable ASTNode astNode) { ASTNode block = getControlStatementBlock(editor.getCaretModel().getOffset(), astNode); PsiElement psiBlock = BasicJavaAstTreeUtil.toPsi(block); if (processExistingBlankLine(editor, psiBlock, astNode)) { return true; } if (block == null) { return false; } EditorActionHandler enterHandler = getEnterHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE); ASTNode firstElement = BasicJavaAstTreeUtil.getFirstBodyElement(block); if (firstElement == null) { firstElement = BasicJavaAstTreeUtil.getRBrace(block); // Plain enter processor inserts enter after the end of line, hence, we don't want to use it here because the line ends with // the empty braces block. So, we get the following in case of default handler usage: // Before: // if (condition[caret]) {} // After: // if (condition) {} // [caret] enterHandler = getEnterHandler(IdeActions.ACTION_EDITOR_ENTER); } editor.getCaretModel().moveToOffset(firstElement != null ? firstElement.getTextRange().getStartOffset() : block.getTextRange().getEndOffset()); enterHandler.execute(editor, editor.getCaretModel().getCurrentCaret(), EditorUtil.getEditorDataContext(editor)); return true; }