int (int line, @NotNull Range range) { if (range.start1 == line) return range.start2; if (range.end1 == line) return range.end2; if (range.end1 < line) return (line - range.end1) + range.end2; return Math.min(range.start2 + (line - range.start1), range.end2); }