(node: TreeNode, prefix: string, isLast: boolean, depth: number)
| 9331 | const lines: string[] = [`**Project Structure (${files.length} files)**`, '']; |
| 9332 | |
| 9333 | const renderNode = (node: TreeNode, prefix: string, isLast: boolean, depth: number): void => { |
| 9334 | if (maxDepth !== undefined && depth > maxDepth) return; |
| 9335 | |
| 9336 | const connector = isLast ? '└── ' : '├── '; |
| 9337 | const childPrefix = isLast ? ' ' : '│ '; |
| 9338 | |
| 9339 | if (node.name) { |
| 9340 | let line = prefix + connector + node.name; |
| 9341 | if (node.file && includeMetadata) { |
| 9342 | line += ` (${node.file.language}, ${node.file.nodeCount} symbols)`; |
| 9343 | } |
| 9344 | lines.push(line); |
| 9345 | } |
| 9346 | |
| 9347 | const children = [...node.children.values()]; |
| 9348 | // Sort: directories first, then files, both alphabetically |
| 9349 | children.sort((a, b) => { |
| 9350 | const aIsDir = a.children.size > 0 && !a.file; |
| 9351 | const bIsDir = b.children.size > 0 && !b.file; |
| 9352 | if (aIsDir !== bIsDir) return aIsDir ? -1 : 1; |
| 9353 | return a.name.localeCompare(b.name); |
| 9354 | }); |
| 9355 | |
| 9356 | for (let i = 0; i < children.length; i++) { |
| 9357 | const child = children[i]!; |
| 9358 | const nextPrefix = node.name ? prefix + childPrefix : prefix; |
| 9359 | renderNode(child, nextPrefix, i === children.length - 1, depth + 1); |
| 9360 | } |
| 9361 | }; |
| 9362 | |
| 9363 | renderNode(root, '', true, 0); |
| 9364 |
nothing calls this directly
no test coverage detected