(node: TreeNode, prefix: string, isLast: boolean, depth: number)
| 4576 | const lines: string[] = [`**Project Structure (${files.length} files)**`, '']; |
| 4577 | |
| 4578 | const renderNode = (node: TreeNode, prefix: string, isLast: boolean, depth: number): void => { |
| 4579 | if (maxDepth !== undefined && depth > maxDepth) return; |
| 4580 | |
| 4581 | const connector = isLast ? '└── ' : '├── '; |
| 4582 | const childPrefix = isLast ? ' ' : '│ '; |
| 4583 | |
| 4584 | if (node.name) { |
| 4585 | let line = prefix + connector + node.name; |
| 4586 | if (node.file && includeMetadata) { |
| 4587 | line += ` (${node.file.language}, ${node.file.nodeCount} symbols)`; |
| 4588 | } |
| 4589 | lines.push(line); |
| 4590 | } |
| 4591 | |
| 4592 | const children = [...node.children.values()]; |
| 4593 | // Sort: directories first, then files, both alphabetically |
| 4594 | children.sort((a, b) => { |
| 4595 | const aIsDir = a.children.size > 0 && !a.file; |
| 4596 | const bIsDir = b.children.size > 0 && !b.file; |
| 4597 | if (aIsDir !== bIsDir) return aIsDir ? -1 : 1; |
| 4598 | return a.name.localeCompare(b.name); |
| 4599 | }); |
| 4600 | |
| 4601 | for (let i = 0; i < children.length; i++) { |
| 4602 | const child = children[i]!; |
| 4603 | const nextPrefix = node.name ? prefix + childPrefix : prefix; |
| 4604 | renderNode(child, nextPrefix, i === children.length - 1, depth + 1); |
| 4605 | } |
| 4606 | }; |
| 4607 | |
| 4608 | renderNode(root, '', true, 0); |
| 4609 |
nothing calls this directly
no test coverage detected