PY-75537 Implement PyAstStringLiteralExpression.getStringValue(), PyAstStringLiteralExpression.getStringValueTextRange() (PyFrontendElementTypesFacadeImpl.kt)

(cherry picked from commit 372f147a61e07c6cb21aaeb8a7d0f3d14d49417d)

GitOrigin-RevId: 9682c8df1f0acd21580e87d8381995960abeeb8a
This commit is contained in:
Petr
2024-10-15 18:52:21 +02:00
committed by intellij-monorepo-bot
parent 001266a5b7
commit 78c67850e3
3 changed files with 63 additions and 55 deletions

View File

@@ -63,35 +63,6 @@ public interface PyStringLiteralExpression extends PyAstStringLiteralExpression,
int valueOffsetToTextOffset(int valueOffset);
/**
* Returns unescaped fragments of string's value together with their respective text ranges <i>relative to the element's start offset</i>.
* For most escape sequences the decoded character is returned and the text range that spans the sequence itself.
* Other "literal" fragments of the string are returned as is so that {@code pair.getFirst().length() == pair.getSecond().getLength()}.
* <p>
* For example, for the next "glued" string literal:
* <p>
* <pre>{@code
* u"\u0066\x6F\157" '\bar' r'\baz'
* }</pre>
* <p>
* this method returns:
* <p>
* <code><pre>
* [
* ([2,8),"f"),
* ([8,12),"o"),
* ([12,16),"o"),
* ([16,16),""),
* ([19,21),"\b"),
* ([21,23),"ar"),
* ([27,29),"\\b"),
* ([29,31),"az"),
* ]
* </code></pre>
*/
@NotNull
List<Pair<TextRange, String>> getDecodedFragments();
/**
* @return true if this element has single string node and its type is {@link com.jetbrains.python.PyTokenTypes#DOCSTRING}
*/