MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / linesOf

Function linesOf

graph-ui/src/pseudocode/pseudocode-builder.ts:478–541  ·  view source on GitHub ↗

* 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[]>,
)

Source from the content-addressed store, hash-verified

476 * it.
477 */
478function 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,

Callers 1

buildPseudocodeFunction · 0.70

Calls 10

pseudocodeStepLineFunction · 0.90
pseudocodeRaiseLineFunction · 0.90
pseudocodeEnvLineFunction · 0.90
declarationRefOfFunction · 0.85
verbOfFunction · 0.85
stepRefOfFunction · 0.85
environmentReadsOfFunction · 0.85
refOfFunction · 0.70
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected