private static int getLineNumberAfter(Document document, TextRange textRange) {
    return Math.min(document.getLineNumber(textRange.getEndOffset()) + 1, document.getLineCount());
  }
private static int getLineNumberAfter(Document document, TextRange textRange)