MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / renderTree

Function renderTree

src/tools/context-tree.ts:71–94  ·  view source on GitHub ↗
(node: TreeNode, indent: number = 0)

Source from the content-addressed store, hash-verified

69}
70
71function renderTree(node: TreeNode, indent: number = 0): string {
72 let result = "";
73 const pad = " ".repeat(indent);
74
75 if (indent === 0) {
76 result = `${node.name}/\n`;
77 } else if (node.isDirectory) {
78 result = `${pad}${node.name}/\n`;
79 } else {
80 result = `${pad}${node.name}`;
81 if (node.header) result += ` | ${node.header}`;
82 result += "\n";
83 if (node.symbols) {
84 for (const line of node.symbols.split("\n")) {
85 result += `${pad} ${line}\n`;
86 }
87 }
88 }
89
90 for (const child of node.children) {
91 result += renderTree(child, indent + 1);
92 }
93 return result;
94}
95
96function pruneSymbols(node: TreeNode): void {
97 node.symbols = undefined;

Callers 1

getContextTreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected