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

Function unitFilesOf

src/resolution/pascal-scope.ts:2426–2443  ·  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

2424 * include file, the unit that includes it, nearest it when several do.
2425 */
2426function unitFilesOf(filePath: string, context: ResolutionContext): string[] {
2427 const m = memos(context);
2428 const hit = m.unitFileSets.get(filePath);
2429 if (hit) return hit;
2430 let root = filePath;
2431 for (let i = 0; i < 3 && /\.inc$/i.test(root); i++) {
2432 const up = includerOf(root, context);
2433 if (!up || up === filePath) break;
2434 root = up;
2435 }
2436 const files = [root];
2437 for (let i = 0; i < files.length && files.length < 32; i++) {
2438 for (const inc of includesOf(files[i]!, context)) if (!files.includes(inc)) files.push(inc);
2439 }
2440 if (!files.includes(filePath)) files.push(filePath);
2441 m.unitFileSets.set(filePath, files);
2442 return files;
2443}
2444
2445/** The include files a Pascal file pulls in (`{$I name.inc}`, `{$INCLUDE name}`), each the one of that name nearest it. */
2446function includesOf(filePath: string, context: ResolutionContext): string[] {

Callers 7

unitRoutineInScopeFunction · 0.85
sameRoutineFunction · 0.85
routineAlternativeFunction · 0.85
scopeKnownFunction · 0.85
exportedRoutineFunction · 0.85
usedUnitFilesFunction · 0.85
ownUnitFilesFunction · 0.85

Calls 6

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

Tested by

no test coverage detected