Result (@NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffset, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, EditorActionHandler originalHandler) { Document document = editor.getDocument(); Project project = file.getProject(); CaretModel caretModel = editor.getCaretModel(); if (!(file instanceof GroovyFileBase)) { return Result.Continue; } int docLength = document.getTextLength(); if (docLength == 0) { return Result.Continue; } final int caret = caretModel.getOffset(); final EditorHighlighter highlighter = editor.getHighlighter(); if (caret >= 1 && caret < docLength && CodeInsightSettings.getInstance().SMART_INDENT_ON_ENTER) { HighlighterIterator iterator = highlighter.createIterator(caret); iterator.retreat(); while (!iterator.atEnd() && TokenType.WHITE_SPACE == iterator.getTokenType()) { iterator.retreat(); } boolean afterArrow = !iterator.atEnd() && iterator.getTokenType() == GroovyTokenTypes.mCLOSABLE_BLOCK_OP; if (afterArrow) { originalHandler.execute(editor, editor.getCaretModel().getCurrentCaret(), dataContext); PsiDocumentManager.getInstance(project).commitDocument(document); CodeStyleManager.getInstance(project).adjustLineIndent(file, caretModel.getOffset()); } iterator = highlighter.createIterator(caretModel.getOffset()); while (!iterator.atEnd() && TokenType.WHITE_SPACE == iterator.getTokenType()) { iterator.advance(); } if (!iterator.atEnd() && GroovyTokenTypes.mRCURLY == iterator.getTokenType()) { PsiDocumentManager.getInstance(project).commitDocument(document); final PsiElement element = file.findElementAt(iterator.getStart()); if (element != null && element.getNode().getElementType() == GroovyTokenTypes.mRCURLY && element.getParent() instanceof GrClosableBlock && afterArrow) { return Result.DefaultForceIndent; } } if (afterArrow) { return Result.Stop; } if (editor.isInsertMode() && !HandlerUtils.isReadOnly(editor) && !editor.getSelectionModel().hasSelection() && handleFlyingGeese(editor, caret, dataContext, originalHandler, file)) { return Result.DefaultForceIndent; } } if (handleEnter(editor, dataContext, originalHandler)) return Result.Stop; return Result.Continue; }