Render one symbol: details + (optional) body/outline + its caller/callee trail.
(cg: CodeGraph, node: Node, includeCode: boolean)
| 8573 | |
| 8574 | /** Render one symbol: details + (optional) body/outline + its caller/callee trail. */ |
| 8575 | private async renderNodeSection(cg: CodeGraph, node: Node, includeCode: boolean): Promise<string> { |
| 8576 | // Disk-drift gate (issue #1474): the body below is CURRENT bytes sliced at |
| 8577 | // INDEXED line ranges. If the file changed since its last index sync, that |
| 8578 | // slice can be a DIFFERENT symbol's code served under this node's name — |
| 8579 | // confidently wrong, with no watcher banner to catch it on a `projectPath` |
| 8580 | // (cross-project) target. Never emit a slice from a drifted file. |
| 8581 | if (this.isFileStaleOnDisk(cg, node.filePath)) { |
| 8582 | return this.renderStaleNodeSection(cg, node, includeCode); |
| 8583 | } |
| 8584 | let code: string | null = null; |
| 8585 | let outline: string | null = null; |
| 8586 | if (includeCode) { |
| 8587 | // For container symbols (class/interface/struct/…), the full body is the |
| 8588 | // sum of every method body — a wall of source. Return a structural outline |
| 8589 | // (members + signatures + line numbers) instead; leaf symbols return their |
| 8590 | // full body. |
| 8591 | if (CONTAINER_NODE_KINDS.has(node.kind)) { |
| 8592 | outline = this.buildContainerOutline(cg, node); |
| 8593 | } |
| 8594 | if (!outline) { |
| 8595 | code = await cg.getCode(node.id); |
| 8596 | } |
| 8597 | } |
| 8598 | return this.formatNodeDetails(node, code, outline) + this.formatTrail(cg, node); |
| 8599 | } |
| 8600 | |
| 8601 | // Whole-file fallback caps for a drifted file (#1474): small enough to fit |
| 8602 | // codegraph_node's output cap (MAX_OUTPUT_LENGTH) with headroom for the |
no test coverage detected