void (@NotNull Document document, List<@NotNull Fragment> ranges, String newText) { for (Fragment range : ranges) { document.replaceString(range.offset(), range.offset() + range.oldLength(), newText.substring(range.offset(), range.offset() + range.newLength())); } }