(payload: WireFileCodePayload)
| 304 | * the real line, so any displacement is visible rather than silent. |
| 305 | */ |
| 306 | export function buildFileCallRows(payload: WireFileCodePayload): FileCallRow[] { |
| 307 | const rows: FileCallRow[] = payload.calls.items.map((call) => ({ |
| 308 | key: `${call.ownerId}>${call.relation.node.id}`, |
| 309 | ownerId: call.ownerId, |
| 310 | call, |
| 311 | anchor: call.relation.lines[0] ?? null, |
| 312 | lines: call.relation.lines, |
| 313 | words: relationWords(call.relation), |
| 314 | via: synthesizedBy(call.relation), |
| 315 | top: 0, |
| 316 | })); |
| 317 | |
| 318 | // The server already sorts by first call line; sorting again keeps this |
| 319 | // function correct on its own, which is what the tests exercise. |
| 320 | rows.sort( |
| 321 | (a, b) => |
| 322 | (a.anchor ?? Number.MAX_SAFE_INTEGER) - (b.anchor ?? Number.MAX_SAFE_INTEGER) || |
| 323 | a.call.ownerLine - b.call.ownerLine || |
| 324 | a.call.relation.node.name.localeCompare(b.call.relation.node.name) |
| 325 | ); |
| 326 | |
| 327 | let y = CODE_TOP_PAD; |
| 328 | for (const row of rows) { |
| 329 | const wanted = row.anchor === null ? y : lineCentre(row.anchor) - ROW_HEIGHT / 2; |
| 330 | y = Math.max(wanted, y); |
| 331 | row.top = y; |
| 332 | y += ROW_HEIGHT + ROW_GAP; |
| 333 | } |
| 334 | return rows; |
| 335 | } |
| 336 | |
| 337 | /** The rows whose boxes intersect a pixel range. Rows are sorted by `top`. */ |
| 338 | export function rowsInRange( |
no test coverage detected