MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / nearestAncestorMatch

Function nearestAncestorMatch

src/resolution/frameworks/terraform.ts:116–122  ·  view source on GitHub ↗

Nearest candidate walking UP the directory tree from refDir (exclusive).

(candidates: T[], refDir: string)

Source from the content-addressed store, hash-verified

114
115/** Nearest candidate walking UP the directory tree from refDir (exclusive). */
116function nearestAncestorMatch<T extends { filePath: string }>(candidates: T[], refDir: string): T | null {
117 for (let dir = parentOf(refDir); dir !== null; dir = parentOf(dir)) {
118 const inDir = candidates.filter((c) => dirOf(c.filePath) === dir);
119 if (inDir.length > 0) return inDir[0]!;
120 }
121 return null;
122}
123
124/**
125 * Resolve `module.M:<child>` by locating the `module "M"` declaration in the

Callers 1

resolveFunction · 0.85

Calls 2

parentOfFunction · 0.85
dirOfFunction · 0.70

Tested by

no test coverage detected