boolean (@NotNull Editor editor, @NotNull ASTNode astNode, boolean isModified) { ASTNode parent = astNode.getTreeParent(); if (!(BasicJavaAstTreeUtil.is(parent, BASIC_CODE_BLOCK))) { return false; } if (CONTROL_FLOW_ELEMENT_TYPES.contains(astNode.getElementType())) { return false; } boolean leaveCodeBlock = isControlFlowBreak(astNode); if (!leaveCodeBlock) { return false; } final int offset = parent.getTextRange().getEndOffset(); // Check if there is empty line after the code block. Just move caret there in the case of the positive answer. final CharSequence text = editor.getDocument().getCharsSequence(); if (offset < text.length() - 1) { final int i = CharArrayUtil.shiftForward(text, offset + 1, " \t"); if (i < text.length() && text.charAt(i) == '\n') { editor.getCaretModel().moveToOffset(offset + 1); EditorActionManager actionManager = EditorActionManager.getInstance(); EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_MOVE_LINE_END); final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent()); actionHandler.execute(editor, editor.getCaretModel().getCurrentCaret(), dataContext); return true; } } editor.getCaretModel().moveToOffset(offset); return false; }