boolean (Editor editor, int caret) { final GroovyLexer lexer = new GroovyLexer(); lexer.start(editor.getDocument().getText()); while (lexer.getTokenEnd() < caret) { lexer.advance(); } final IElementType leftToken = lexer.getTokenType(); if (lexer.getTokenEnd() <= caret) lexer.advance(); final IElementType rightToken = lexer.getTokenType(); if (!(ALL_STRINGS.contains(leftToken))) { return false; } if (BEFORE_DOLLAR.contains(leftToken) && !AFTER_DOLLAR.contains(rightToken)) { return false; } if (EXPR_END.contains(leftToken) && !AFTER_EXPR_END.contains(rightToken)) { return false; } if (STRING_END.contains(leftToken) && !STRING_END.contains(rightToken)) { return false; } return true; }