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