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

Function resolveUnder

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

Source from the content-addressed store, hash-verified

1886 // `<seg>.rs` or `<seg>/mod.rs` file. Returns the leaf module's file, or null
1887 // if `startDir` is null or any segment has no file on disk.
1888 const resolveUnder = (startDir: string | null, rest: string[]): string | null => {
1889 if (!startDir) return null;
1890 let dir = startDir;
1891 let targetFile: string | null = null;
1892 for (const seg of rest) {
1893 if (seg === 'self' || seg === 'crate' || seg === 'super') continue;
1894 const asFile = toRel(path.join(dir, seg + '.rs'));
1895 const asMod = toRel(path.join(dir, seg, 'mod.rs'));
1896 if (context.fileExists(asFile)) targetFile = asFile;
1897 else if (context.fileExists(asMod)) targetFile = asMod;
1898 else return null;
1899 dir = path.join(dir, seg);
1900 }
1901 return targetFile;
1902 };
1903
1904 const first = segments[0]!;
1905 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