IntPair (@NotNull LineOffsets lineOffsets, int startIndex, int endIndex) { if (startIndex == endIndex) { int offset; if (startIndex < lineOffsets.getLineCount()) { offset = lineOffsets.getLineStart(startIndex); } else { offset = lineOffsets.getLineEnd(lineOffsets.getLineCount() - 1, true); } return new IntPair(offset, offset); } else { int offset1 = lineOffsets.getLineStart(startIndex); int offset2 = lineOffsets.getLineEnd(endIndex - 1, true); return new IntPair(offset1, offset2); } }