public int toOffset(@NotNull Document document) {
    if (line >= document.getLineCount()) return document.getTextLength();
    return Math.min(document.getLineStartOffset(line) + column, document.getLineEndOffset(line));
  }
public int toOffset(@NotNull Document document)