void (@NotNull OuterLanguageRangePatcher patcher, @NotNull CharSequence originalSourceCode, @NotNull StringBuilder modifiedText) { if (myOuterAndRemoveRanges.isEmpty()) return; int shift = 0; ListIterator<TextRange> iterator = myOuterAndRemoveRanges.listIterator(); while (iterator.hasNext()) { TextRange outerElementRange = iterator.next(); if (outerElementRange instanceof RangeToRemove) { shift += outerElementRange.getLength(); } else { if (outerElementRange instanceof InsertionRange) { String dummyString = patcher.getTextForOuterLanguageInsertionRange( myTemplateDataElementType, outerElementRange.subSequence(originalSourceCode)); if (dummyString != null) { // Don't set RangeToRemove#myTextToRemove so it won't be applied to nested lazy parseables. // Nested lazy parseables may add dummy string themselves. iterator.add(new RangeToRemove(outerElementRange.getEndOffset(), outerElementRange.getEndOffset() + dummyString.length())); modifiedText.insert(outerElementRange.getStartOffset() + shift, dummyString); shift += dummyString.length(); } } shift -= outerElementRange.getLength(); } } }