(node: TreeNode, prefix: string, isLast: boolean, depth: number)
| 4339 | const lines: string[] = [`**Project Structure (${files.length} files)**`, '']; |
| 4340 | |
| 4341 | const renderNode = (node: TreeNode, prefix: string, isLast: boolean, depth: number): void => { |
| 4342 | if (maxDepth !== undefined && depth > maxDepth) return; |
| 4343 | |
| 4344 | const connector = isLast ? '└── ' : '├── '; |
| 4345 | const childPrefix = isLast ? ' ' : '│ '; |
| 4346 | |
| 4347 | if (node.name) { |
| 4348 | let line = prefix + connector + node.name; |
| 4349 | if (node.file && includeMetadata) { |
| 4350 | line += ` (${node.file.language}, ${node.file.nodeCount} symbols)`; |
| 4351 | } |
| 4352 | lines.push(line); |
| 4353 | } |
| 4354 | |
| 4355 | const children = [...node.children.values()]; |
| 4356 | // Sort: directories first, then files, both alphabetically |
| 4357 | children.sort((a, b) => { |
| 4358 | const aIsDir = a.children.size > 0 && !a.file; |
| 4359 | const bIsDir = b.children.size > 0 && !b.file; |
| 4360 | if (aIsDir !== bIsDir) return aIsDir ? -1 : 1; |
| 4361 | return a.name.localeCompare(b.name); |
| 4362 | }); |
| 4363 | |
| 4364 | for (let i = 0; i < children.length; i++) { |
| 4365 | const child = children[i]!; |
| 4366 | const nextPrefix = node.name ? prefix + childPrefix : prefix; |
| 4367 | renderNode(child, nextPrefix, i === children.length - 1, depth + 1); |
| 4368 | } |
| 4369 | }; |
| 4370 | |
| 4371 | renderNode(root, '', true, 0); |
| 4372 |
nothing calls this directly
no test coverage detected