void (@NotNull PyStringLiteralExpression element, @NotNull TokenConsumer consumer) { final Splitter splitter = PlainTextSplitter.getInstance(); for (PyStringElement stringElement : element.getStringElements()) { final List<TextRange> literalPartRanges; if (stringElement.isFormatted()) { literalPartRanges = ((PyFormattedStringElement)stringElement).getLiteralPartRanges(); } else { literalPartRanges = Collections.singletonList(stringElement.getContentRange()); } final PyStringLiteralDecoder decoder = new PyStringLiteralDecoder(stringElement); final boolean containsEscapes = stringElement.textContains('\\'); for (TextRange literalPartRange : literalPartRanges) { final List<TextRange> escapeAwareRanges; if (stringElement.isRaw() || !containsEscapes) { escapeAwareRanges = Collections.singletonList(literalPartRange); } else { escapeAwareRanges = ContainerUtil.map(decoder.decodeRange(literalPartRange), x -> x.getFirst()); } for (TextRange escapeAwareRange : escapeAwareRanges) { final String valueText = escapeAwareRange.substring(stringElement.getText()); consumer.consumeToken(stringElement, valueText, false, escapeAwareRange.getStartOffset(), TextRange.allOf(valueText), splitter); } } } }