MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / renderNodeSection

Method renderNodeSection

src/mcp/tools.ts:8428–8452  ·  view source on GitHub ↗

Render one symbol: details + (optional) body/outline + its caller/callee trail.

(cg: CodeGraph, node: Node, includeCode: boolean)

Source from the content-addressed store, hash-verified

8426
8427 /** Render one symbol: details + (optional) body/outline + its caller/callee trail. */
8428 private async renderNodeSection(cg: CodeGraph, node: Node, includeCode: boolean): Promise<string> {
8429 // Disk-drift gate (issue #1474): the body below is CURRENT bytes sliced at
8430 // INDEXED line ranges. If the file changed since its last index sync, that
8431 // slice can be a DIFFERENT symbol's code served under this node's name —
8432 // confidently wrong, with no watcher banner to catch it on a `projectPath`
8433 // (cross-project) target. Never emit a slice from a drifted file.
8434 if (this.isFileStaleOnDisk(cg, node.filePath)) {
8435 return this.renderStaleNodeSection(cg, node, includeCode);
8436 }
8437 let code: string | null = null;
8438 let outline: string | null = null;
8439 if (includeCode) {
8440 // For container symbols (class/interface/struct/…), the full body is the
8441 // sum of every method body — a wall of source. Return a structural outline
8442 // (members + signatures + line numbers) instead; leaf symbols return their
8443 // full body.
8444 if (CONTAINER_NODE_KINDS.has(node.kind)) {
8445 outline = this.buildContainerOutline(cg, node);
8446 }
8447 if (!outline) {
8448 code = await cg.getCode(node.id);
8449 }
8450 }
8451 return this.formatNodeDetails(node, code, outline) + this.formatTrail(cg, node);
8452 }
8453
8454 // Whole-file fallback caps for a drifted file (#1474): small enough to fit
8455 // codegraph_node's output cap (MAX_OUTPUT_LENGTH) with headroom for the

Callers 1

handleNodeMethod · 0.95

Calls 7

isFileStaleOnDiskMethod · 0.95
buildContainerOutlineMethod · 0.95
formatNodeDetailsMethod · 0.95
formatTrailMethod · 0.95
hasMethod · 0.80
getCodeMethod · 0.45

Tested by

no test coverage detected