LineCol (@NotNull Document document, int offset) { // document might have been changed already if (offset <= document.getTextLength()) { int line = document.getLineNumber(offset); int col = offset - document.getLineStartOffset(line); if (col < 0) { return null; } return new LineCol(line, col); } return null; }