public static int getLineStartSafeOffset(@NotNull Document document, int line) {
    return line == document.getLineCount() ? document.getTextLength() : document.getLineStartOffset(line);
  }
public static int getLineStartSafeOffset(@NotNull Document document, int line)