void (@NotNull Document document, int line, @NotNull CharSequence text) { if (line == getLineCount(document)) { document.insertString(document.getTextLength(), "\n" + text); } else { document.insertString(document.getLineStartOffset(line), text + "\n"); } }