List<TextRange> (@NotNull PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) { final List<TextRange> ranges = new ArrayList<>(); final PsiElement parent = e.getParent(); if (parent instanceof GrStringContent && parent.getParent() instanceof GrString) { TextRange range = getLineTextRange(parent, cursorOffset); ranges.add(range); } else if (parent instanceof GrString) { PsiElement firstChild = parent.getFirstChild(); PsiElement lastChild = parent.getLastChild(); if (firstChild.getNode().getElementType() == GroovyTokenTypes.mGSTRING_BEGIN) { firstChild = firstChild.getNextSibling(); } if (lastChild.getNode().getElementType() == GroovyTokenTypes.mGSTRING_END) { lastChild = lastChild.getPrevSibling(); } if (firstChild != null && lastChild != null) { TextRange range = new TextRange(firstChild.getTextOffset(), lastChild.getTextOffset() + lastChild.getTextLength()); ranges.add(range); } ranges.add(parent.getTextRange()); } else if (parent instanceof GrStringInjection) { if (e instanceof GrReferenceExpression) { List<TextRange> r = new ArrayList<>(2); SelectWordUtil.addWordSelection(editor.getSettings().isCamelWords(), editorText, cursorOffset, r); for (TextRange textRange : r) { if (editorText.charAt(textRange.getStartOffset()) == '$') { textRange = new TextRange(textRange.getStartOffset() + 1, textRange.getEndOffset()); } ranges.add(textRange); } } ranges.add(parent.getTextRange()); ranges.add(e.getTextRange()); } return ranges; }