* One symbol's lines: its steps, then what it can raise, then what it reads. * * The order is the reader's, not the graph's. Steps come first because they are * the body of the thing; the raised types and the environment reads are * conditions around it, and putting either above the steps would
(
ir: SemanticIR,
key: string,
counter: { next: number },
insights: ReadonlyMap<string, StepInsight[]>,
)
| 476 | * it. |
| 477 | */ |
| 478 | function linesOf( |
| 479 | ir: SemanticIR, |
| 480 | key: string, |
| 481 | counter: { next: number }, |
| 482 | insights: ReadonlyMap<string, StepInsight[]>, |
| 483 | ): PseudocodeLine[] { |
| 484 | const declaration = declarationRefOf(ir); |
| 485 | const lines: PseudocodeLine[] = []; |
| 486 | |
| 487 | for (const call of ir.steps.value) { |
| 488 | const order = counter.next++; |
| 489 | const behind = insights.get(call.targetQualifiedName ?? '') ?? []; |
| 490 | lines.push({ |
| 491 | kind: 'step', |
| 492 | order, |
| 493 | group: key, |
| 494 | text: pseudocodeStepLine(order, verbOf(call), call.targetName), |
| 495 | sourceRef: stepRefOf(ir, call) ?? declaration, |
| 496 | targetName: call.targetName, |
| 497 | targetFile: call.targetFile, |
| 498 | targetLine: call.targetLine, |
| 499 | // The declaration of the callee, which is where following the step |
| 500 | // takes a reader. `targetLine` is used and never `line`: the call |
| 501 | // site's number means nothing inside the callee's file. |
| 502 | targetRef: refOf(call.targetFile, call.targetLine), |
| 503 | ...(behind.length > 0 ? { behind } : {}), |
| 504 | }); |
| 505 | } |
| 506 | |
| 507 | for (const raised of ir.throws.value) { |
| 508 | const order = counter.next++; |
| 509 | lines.push({ |
| 510 | kind: 'raise', |
| 511 | order, |
| 512 | group: key, |
| 513 | text: pseudocodeRaiseLine(order, raised.type), |
| 514 | sourceRef: refOf(raised.file, raised.line) ?? declaration, |
| 515 | targetName: raised.type, |
| 516 | targetFile: raised.file, |
| 517 | targetLine: raised.line, |
| 518 | // The same place the text of the line opens. A raise is not a |
| 519 | // journey from here to somewhere else: the site the index recorded |
| 520 | // is the thing the line is about. |
| 521 | targetRef: refOf(raised.file, raised.line), |
| 522 | }); |
| 523 | } |
| 524 | |
| 525 | for (const read of environmentReadsOf(ir)) { |
| 526 | const order = counter.next++; |
| 527 | lines.push({ |
| 528 | kind: 'env', |
| 529 | order, |
| 530 | group: key, |
| 531 | text: pseudocodeEnvLine(order, read.name), |
| 532 | sourceRef: refOf(read.file, read.line) ?? declaration, |
| 533 | targetName: read.name, |
| 534 | targetFile: read.file, |
| 535 | targetLine: read.line, |
no test coverage detected