List<TextRange> (@NotNull PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) { final PyStringLiteralExpression literal = PsiTreeUtil.getParentOfType(e, PyStringLiteralExpression.class); if (literal != null) { List<TextRange> ranges = literal.getStringValueTextRanges(); List<ASTNode> nodes = literal.getStringNodes(); for (int i = 0; i < ranges.size(); i++) { TextRange stringRange = ranges.get(i); TextRange offsetRange = stringRange.shiftRight(literal.getTextRange().getStartOffset()); if (offsetRange.contains(cursorOffset) && offsetRange.getLength() > 1) { List<TextRange> result = new ArrayList<>(); SelectWordUtil.addWordHonoringEscapeSequences(editorText, nodes.get(i).getTextRange(), cursorOffset, new PyStringLiteralLexer(nodes.get(i).getElementType()), result); result.add(offsetRange); return result; } } } return Collections.emptyList(); }