void (@NotNull PlaceInfo info, @NotNull StringBuilder outChars) { int startOffset = outChars.length(); outChars.append(info.prefix); LiteralTextEscaper<? extends PsiLanguageInjectionHost> textEscaper = info.myEscaper; TextRange relevantRange = info.getRelevantRangeInsideHost(); if (relevantRange == null) { relevantRange = TextRange.from(textEscaper.getRelevantTextRange().getStartOffset(), 0); } else { int before = outChars.length(); boolean decodeSuccessful = textEscaper.decode(relevantRange, outChars); int after = outChars.length(); assert after >= before : "Escaper " + textEscaper + "("+textEscaper.getClass()+") must not mangle char buffer"; if (!decodeSuccessful) { // if there are invalid chars, adjust the range int charsDecodedSuccessfully = outChars.length() - before; int startOffsetInHost = textEscaper.getOffsetInHost(0, info.registeredRangeInsideHost); assert relevantRange.containsOffset(startOffsetInHost) : textEscaper.getClass() +" is inconsistent: its.getOffsetInHost(0) = "+startOffsetInHost+" while its relevantRange="+relevantRange; int endOffsetInHost = textEscaper.getOffsetInHost(charsDecodedSuccessfully, info.registeredRangeInsideHost); assert relevantRange.containsOffset(endOffsetInHost) : textEscaper.getClass() +" is inconsistent: its.getOffsetInHost(" + charsDecodedSuccessfully + ") = "+endOffsetInHost+" while its relevantRange="+relevantRange; ProperTextRange successfulHostRange = new ProperTextRange(startOffsetInHost, endOffsetInHost); relevantRange = relevantRange.intersection(successfulHostRange); } } outChars.append(info.suffix); int endOffset = outChars.length(); info.rangeInDecodedPSI = new ProperTextRange(startOffset, endOffset); info.rangeInHostElement = relevantRange; }