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

Function resolveUnder

src/resolution/import-resolver.ts:2162–2176  ·  view source on GitHub ↗
(startDir: string | null, rest: string[])

Source from the content-addressed store, hash-verified

2160 // `<seg>.rs` or `<seg>/mod.rs` file. Returns the leaf module's file, or null
2161 // if `startDir` is null or any segment has no file on disk.
2162 const resolveUnder = (startDir: string | null, rest: string[]): string | null => {
2163 if (!startDir) return null;
2164 let dir = startDir;
2165 let targetFile: string | null = null;
2166 for (const seg of rest) {
2167 if (seg === 'self' || seg === 'crate' || seg === 'super') continue;
2168 const asFile = toRel(path.join(dir, seg + '.rs'));
2169 const asMod = toRel(path.join(dir, seg, 'mod.rs'));
2170 if (context.fileExists(asFile)) targetFile = asFile;
2171 else if (context.fileExists(asMod)) targetFile = asMod;
2172 else return null;
2173 dir = path.join(dir, seg);
2174 }
2175 return targetFile;
2176 };
2177
2178 const first = segments[0]!;
2179 if (first === 'crate') {

Callers 1

resolveRustModuleFileFunction · 0.85

Calls 3

toRelFunction · 0.85
fileExistsMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected