MCPcopy Index your code
hub / github.com/codeaashu/claude-code / collectDirectoryNames

Function collectDirectoryNames

src/hooks/fileSuggestions.ts:420–440  ·  view source on GitHub ↗
(
  files: string[],
  start: number,
  end: number,
  out: Set<string>,
)

Source from the content-addressed store, hash-verified

418}
419
420function collectDirectoryNames(
421 files: string[],
422 start: number,
423 end: number,
424 out: Set<string>,
425): void {
426 for (let i = start; i < end; i++) {
427 let currentDir = path.dirname(files[i]!)
428 // Early exit if we've already processed this directory and all its parents.
429 // Root detection: path.dirname returns its input at the root (fixed point),
430 // so we stop when dirname stops changing. Checking this before add() keeps
431 // the root out of the result set (matching the old path.parse().root guard).
432 // This avoids path.parse() which allocates a 5-field object per file.
433 while (currentDir !== '.' && !out.has(currentDir)) {
434 const parent = path.dirname(currentDir)
435 if (parent === currentDir) break
436 out.add(currentDir)
437 currentDir = parent
438 }
439 }
440}
441
442/**
443 * Gets additional files from Claude config directories

Callers 2

getDirectoryNamesFunction · 0.85
getDirectoryNamesAsyncFunction · 0.85

Calls 2

hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected