(offset: number)
| 97 | } |
| 98 | |
| 99 | lineAndColumnOf(offset: number): [line: number, column: number] { |
| 100 | this.lineStarts ??= computeLineStarts(this.source) |
| 101 | let low = 0 |
| 102 | let high = this.lineStarts.length - 1 |
| 103 | while (low < high) { |
| 104 | const mid = (low + high + 1) >> 1 |
| 105 | if (this.lineStarts[mid] <= offset) low = mid |
| 106 | else high = mid - 1 |
| 107 | } |
| 108 | const column = offset - this.lineStarts[low] |
| 109 | // the last segment starting at or before the column, sorted by column |
| 110 | let mapped: SourceMapSegment | undefined |
| 111 | for (const segment of this.mappings?.[low] ?? []) { |
| 112 | if (segment[0] > column) break |
| 113 | if (segment.length > 1) mapped = segment |
| 114 | } |
| 115 | return mapped ? |
| 116 | [mapped[2]! + 1, mapped[3]! + column - mapped[0] + 1] |
| 117 | : [low + 1, column + 1] |
| 118 | } |
| 119 | |
| 120 | positionOf(span: Span): string { |
| 121 | const [line, column] = this.lineAndColumnOf(span.start) |
no test coverage detected