Result (char c, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (c != '{' || !HandlerUtils.canBeInvoked(editor, project)) { return Result.CONTINUE; } if (!(file instanceof GroovyFile)) return Result.CONTINUE; int caret = editor.getCaretModel().getOffset(); final EditorHighlighter highlighter = editor.getHighlighter(); if (caret < 1) return Result.CONTINUE; HighlighterIterator iterator = highlighter.createIterator(caret - 1); if (iterator.getTokenType() != GroovyTokenTypes.mLCURLY) return Result.CONTINUE; iterator.retreat(); if (iterator.atEnd() || iterator.getTokenType() != GroovyTokenTypes.mDOLLAR) return Result.CONTINUE; iterator.advance(); if (iterator.atEnd()) return Result.CONTINUE; iterator.advance(); if (iterator.getTokenType() != GroovyTokenTypes.mGSTRING_BEGIN) return Result.CONTINUE; editor.getDocument().insertString(caret, "}"); return Result.STOP; }