(node: TreeNode, prefix: string, isLast: boolean, depth: number)
| 8909 | const lines: string[] = [`**Project Structure (${files.length} files)**`, '']; |
| 8910 | |
| 8911 | const renderNode = (node: TreeNode, prefix: string, isLast: boolean, depth: number): void => { |
| 8912 | if (maxDepth !== undefined && depth > maxDepth) return; |
| 8913 | |
| 8914 | const connector = isLast ? '└── ' : '├── '; |
| 8915 | const childPrefix = isLast ? ' ' : '│ '; |
| 8916 | |
| 8917 | if (node.name) { |
| 8918 | let line = prefix + connector + node.name; |
| 8919 | if (node.file && includeMetadata) { |
| 8920 | line += ` (${node.file.language}, ${node.file.nodeCount} symbols)`; |
| 8921 | } |
| 8922 | lines.push(line); |
| 8923 | } |
| 8924 | |
| 8925 | const children = [...node.children.values()]; |
| 8926 | // Sort: directories first, then files, both alphabetically |
| 8927 | children.sort((a, b) => { |
| 8928 | const aIsDir = a.children.size > 0 && !a.file; |
| 8929 | const bIsDir = b.children.size > 0 && !b.file; |
| 8930 | if (aIsDir !== bIsDir) return aIsDir ? -1 : 1; |
| 8931 | return a.name.localeCompare(b.name); |
| 8932 | }); |
| 8933 | |
| 8934 | for (let i = 0; i < children.length; i++) { |
| 8935 | const child = children[i]!; |
| 8936 | const nextPrefix = node.name ? prefix + childPrefix : prefix; |
| 8937 | renderNode(child, nextPrefix, i === children.length - 1, depth + 1); |
| 8938 | } |
| 8939 | }; |
| 8940 | |
| 8941 | renderNode(root, '', true, 0); |
| 8942 |
nothing calls this directly
no test coverage detected