* 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)
| 2424 | * include file, the unit that includes it, nearest it when several do. |
| 2425 | */ |
| 2426 | function 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. */ |
| 2446 | function includesOf(filePath: string, context: ResolutionContext): string[] { |
no test coverage detected