List<TextRange> (@NotNull PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) { TextRange stringRange = e.getTextRange(); PsiElement firstChild = e.getFirstChild().getNextSibling(); if (firstChild instanceof PsiErrorElement) { return Collections.emptyList(); } int startShift = 1; if (firstChild instanceof PsiWhiteSpace) startShift += firstChild.getTextLength(); PsiElement lastChild = e.getLastChild().getPrevSibling(); int endShift = 1; if (lastChild instanceof PsiWhiteSpace && lastChild != firstChild) endShift += lastChild.getTextLength(); final TextRange offsetRange = new TextRange(stringRange.getStartOffset() + startShift, stringRange.getEndOffset() - endShift); if (offsetRange.contains(cursorOffset) && offsetRange.getLength() > 1) { return Collections.singletonList(offsetRange); } return Collections.emptyList(); }