void (@NotNull Document document, @NotNull DocumentChangeTransaction documentChangeTransaction) { DocumentEx ex = (DocumentEx) document; ex.suppressGuardedExceptions(); try { boolean isReadOnly = !document.isWritable(); ex.setReadOnly(false); for (Map.Entry<TextRange, CharSequence> entry : documentChangeTransaction.myAffectedFragments.descendingMap().entrySet()) { ex.replaceString(entry.getKey().getStartOffset(), entry.getKey().getEndOffset(), entry.getValue()); } ex.setReadOnly(isReadOnly); } finally { ex.unSuppressGuardedExceptions(); } }