@@ -233,67 +233,67 @@ object DocumentRegistry {
233233 fileCount = paths.size
234234 )
235235 }
236-
236+
237237 /* *
238238 * Build a tree-like string representation of file paths.
239239 */
240- private fun buildStructureTree (paths : List <String >): String {
240+ fun buildStructureTree (paths : List <String >): String {
241241 if (paths.isEmpty()) return " No files found."
242-
242+
243243 // Build tree structure
244244 data class TreeNode (
245245 val name : String ,
246246 val children : MutableMap <String , TreeNode > = mutableMapOf(),
247247 var isFile : Boolean = false
248248 )
249-
249+
250250 val root = TreeNode (" " )
251-
251+
252252 for (path in paths.sorted()) {
253253 val parts = path.split(' /' )
254254 var current = root
255-
255+
256256 for ((index, part) in parts.withIndex()) {
257257 if (part.isEmpty()) continue
258258 val isLast = index == parts.size - 1
259-
259+
260260 if (! current.children.containsKey(part)) {
261261 current.children[part] = TreeNode (part)
262262 }
263263 current = current.children[part]!!
264264 if (isLast) current.isFile = true
265265 }
266266 }
267-
267+
268268 // Render tree to string
269269 fun renderNode (node : TreeNode , prefix : String , isLast : Boolean , isRoot : Boolean ): String {
270270 val sb = StringBuilder ()
271-
271+
272272 if (! isRoot) {
273273 val connector = if (isLast) " `-- " else " |-- "
274274 val icon = if (node.isFile) " " else " /"
275275 sb.appendLine(" $prefix$connector${node.name}$icon " )
276276 }
277-
277+
278278 val childPrefix = if (isRoot) " " else prefix + (if (isLast) " " else " | " )
279279 // Sort: directories first, then files, both alphabetically
280280 val sortedChildren = node.children.values.sortedWith(compareBy({ it.children.isEmpty() }, { it.name }))
281-
281+
282282 for ((index, child) in sortedChildren.withIndex()) {
283283 val childIsLast = index == sortedChildren.size - 1
284284 sb.append(renderNode(child, childPrefix, childIsLast, false ))
285285 }
286-
286+
287287 return sb.toString()
288288 }
289-
289+
290290 return renderNode(root, " " , true , true ).trimEnd()
291291 }
292-
292+
293293 /* *
294294 * Count unique directories from file paths.
295295 */
296- private fun countDirectories (paths : List <String >): Int {
296+ fun countDirectories (paths : List <String >): Int {
297297 val directories = mutableSetOf<String >()
298298 for (path in paths) {
299299 val parts = path.split(' /' )
@@ -303,7 +303,7 @@ object DocumentRegistry {
303303 }
304304 return directories.size
305305 }
306-
306+
307307 /* *
308308 * Execute $.files query across multiple documents
309309 */
0 commit comments