public static boolean isAtLineEnd(int offset, @NotNull Document document) {
    return offset >= 0 && offset <= document.getTextLength() && offset == document.getLineEndOffset(document.getLineNumber(offset));
  }
public static boolean isAtLineEnd(int offset, @NotNull Document document)