Render one symbol: details + (optional) body/outline + its caller/callee trail.
(cg: CodeGraph, node: Node, includeCode: boolean)
| 8885 | |
| 8886 | /** Render one symbol: details + (optional) body/outline + its caller/callee trail. */ |
| 8887 | private async renderNodeSection(cg: CodeGraph, node: Node, includeCode: boolean): Promise<string> { |
| 8888 | // Disk-drift gate (issue #1474): the body below is CURRENT bytes sliced at |
| 8889 | // INDEXED line ranges. If the file changed since its last index sync, that |
| 8890 | // slice can be a DIFFERENT symbol's code served under this node's name — |
| 8891 | // confidently wrong, with no watcher banner to catch it on a `projectPath` |
| 8892 | // (cross-project) target. Never emit a slice from a drifted file. |
| 8893 | if (this.isFileStaleOnDisk(cg, node.filePath)) { |
| 8894 | return this.renderStaleNodeSection(cg, node, includeCode); |
| 8895 | } |
| 8896 | let code: string | null = null; |
| 8897 | let outline: string | null = null; |
| 8898 | if (includeCode) { |
| 8899 | // For container symbols (class/interface/struct/…), the full body is the |
| 8900 | // sum of every method body — a wall of source. Return a structural outline |
| 8901 | // (members + signatures + line numbers) instead; leaf symbols return their |
| 8902 | // full body. |
| 8903 | if (CONTAINER_NODE_KINDS.has(node.kind)) { |
| 8904 | outline = this.buildContainerOutline(cg, node); |
| 8905 | } |
| 8906 | if (!outline) { |
| 8907 | code = await cg.getCode(node.id); |
| 8908 | } |
| 8909 | } |
| 8910 | return this.formatNodeDetails(node, code, outline) + this.formatTrail(cg, node); |
| 8911 | } |
| 8912 | |
| 8913 | // Whole-file fallback caps for a drifted file (#1474): small enough to fit |
| 8914 | // codegraph_node's output cap (MAX_OUTPUT_LENGTH) with headroom for the |
no test coverage detected