MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / resolveUnder

Function resolveUnder

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

Source from the content-addressed store, hash-verified

1638 // `<seg>.rs` or `<seg>/mod.rs` file. Returns the leaf module's file, or null
1639 // if `startDir` is null or any segment has no file on disk.
1640 const resolveUnder = (startDir: string | null, rest: string[]): string | null => {
1641 if (!startDir) return null;
1642 let dir = startDir;
1643 let targetFile: string | null = null;
1644 for (const seg of rest) {
1645 if (seg === 'self' || seg === 'crate' || seg === 'super') continue;
1646 const asFile = toRel(path.join(dir, seg + '.rs'));
1647 const asMod = toRel(path.join(dir, seg, 'mod.rs'));
1648 if (context.fileExists(asFile)) targetFile = asFile;
1649 else if (context.fileExists(asMod)) targetFile = asMod;
1650 else return null;
1651 dir = path.join(dir, seg);
1652 }
1653 return targetFile;
1654 };
1655
1656 const first = segments[0]!;
1657 if (first === 'crate') {

Callers 1

resolveRustModuleFileFunction · 0.85

Calls 3

toRelFunction · 0.85
joinMethod · 0.80
fileExistsMethod · 0.80

Tested by

no test coverage detected