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

Function unitFilesOf

src/resolution/pascal-scope.ts:890–907  ·  view source on GitHub ↗

* The files one unit is made of: its own file, then the include files it * pulls in (`{$I name.inc}`, `{$INCLUDE name}`), nested ones too. For an * include file, the unit that includes it, nearest it when several do.

(filePath: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

888 * include file, the unit that includes it, nearest it when several do.
889 */
890function unitFilesOf(filePath: string, context: ResolutionContext): string[] {
891 const m = memos(context);
892 const hit = m.unitFileSets.get(filePath);
893 if (hit) return hit;
894 let root = filePath;
895 for (let i = 0; i < 3 && /\.inc$/i.test(root); i++) {
896 const up = includerOf(root, context);
897 if (!up || up === filePath) break;
898 root = up;
899 }
900 const files = [root];
901 for (let i = 0; i < files.length && files.length < 32; i++) {
902 for (const inc of includesOf(files[i]!, context)) if (!files.includes(inc)) files.push(inc);
903 }
904 if (!files.includes(filePath)) files.push(filePath);
905 m.unitFileSets.set(filePath, files);
906 return files;
907}
908
909/** The include files a Pascal file pulls in (`{$I name.inc}`, `{$INCLUDE name}`), each the one of that name nearest it. */
910function includesOf(filePath: string, context: ResolutionContext): string[] {

Callers 2

usedUnitFilesFunction · 0.85
ownUnitFilesFunction · 0.85

Calls 6

memosFunction · 0.85
includerOfFunction · 0.85
includesOfFunction · 0.85
pushMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected