TextRange (int startOffset, int endOffset, @NotNull Document document, @NotNull String prefix, @NotNull String suffix) { document.insertString(startOffset, prefix); document.insertString(endOffset + prefix.length(), suffix); return new TextRange(startOffset, endOffset + prefix.length() + suffix.length()); }