TextRange (@NotNull PsiElement literal) { if (literal instanceof PyTupleExpression) { return TextRange.create(0, literal.getTextLength()); } final String replacedText = literal.getText(); final PsiElement firstChild = literal.getFirstChild(); final int contentStartOffset; if (PyTokenTypes.OPEN_BRACES.contains(firstChild.getNode().getElementType())) { contentStartOffset = firstChild.getTextLength(); } else { contentStartOffset = 0; } final PsiElement lastChild = literal.getLastChild(); final int contentEndOffset; if (PyTokenTypes.CLOSE_BRACES.contains(lastChild.getNode().getElementType())) { contentEndOffset = replacedText.length() - lastChild.getTextLength(); } else { contentEndOffset = replacedText.length(); } return TextRange.create(contentStartOffset, contentEndOffset); }