Render one symbol: details + (optional) body/outline + its caller/callee trail.
(cg: CodeGraph, node: Node, includeCode: boolean)
| 8848 | |
| 8849 | /** Render one symbol: details + (optional) body/outline + its caller/callee trail. */ |
| 8850 | private async renderNodeSection(cg: CodeGraph, node: Node, includeCode: boolean): Promise<string> { |
| 8851 | // Disk-drift gate (issue #1474): the body below is CURRENT bytes sliced at |
| 8852 | // INDEXED line ranges. If the file changed since its last index sync, that |
| 8853 | // slice can be a DIFFERENT symbol's code served under this node's name — |
| 8854 | // confidently wrong, with no watcher banner to catch it on a `projectPath` |
| 8855 | // (cross-project) target. Never emit a slice from a drifted file. |
| 8856 | if (this.isFileStaleOnDisk(cg, node.filePath)) { |
| 8857 | return this.renderStaleNodeSection(cg, node, includeCode); |
| 8858 | } |
| 8859 | let code: string | null = null; |
| 8860 | let outline: string | null = null; |
| 8861 | if (includeCode) { |
| 8862 | // For container symbols (class/interface/struct/…), the full body is the |
| 8863 | // sum of every method body — a wall of source. Return a structural outline |
| 8864 | // (members + signatures + line numbers) instead; leaf symbols return their |
| 8865 | // full body. |
| 8866 | if (CONTAINER_NODE_KINDS.has(node.kind)) { |
| 8867 | outline = this.buildContainerOutline(cg, node); |
| 8868 | } |
| 8869 | if (!outline) { |
| 8870 | code = await cg.getCode(node.id); |
| 8871 | } |
| 8872 | } |
| 8873 | return this.formatNodeDetails(node, code, outline) + this.formatTrail(cg, node); |
| 8874 | } |
| 8875 | |
| 8876 | // Whole-file fallback caps for a drifted file (#1474): small enough to fit |
| 8877 | // codegraph_node's output cap (MAX_OUTPUT_LENGTH) with headroom for the |
no test coverage detected