( files: string[], overrides?: Record<string, Language>, rootDir?: string )
| 1005 | * (#1628). C++ was already covered; Objective-C was not. |
| 1006 | */ |
| 1007 | export function preloadLanguagesForFiles( |
| 1008 | files: string[], |
| 1009 | overrides?: Record<string, Language>, |
| 1010 | rootDir?: string |
| 1011 | ): Language[] { |
| 1012 | const languages = [...new Set(files.map((f) => detectLanguage(f, undefined, overrides, rootDir)))]; |
| 1013 | // A Flow-typed `.js` is read with the TSX grammar (see detectLanguage). |
| 1014 | if ((languages.includes('javascript') || languages.includes('jsx')) && !languages.includes('tsx')) languages.push('tsx'); |
| 1015 | if (languages.includes('c')) { |
| 1016 | for (const ambiguous of ['cpp', 'objc'] as const) { |
| 1017 | if (!languages.includes(ambiguous)) languages.push(ambiguous); |
| 1018 | } |
| 1019 | } |
| 1020 | // An `.inc` path-detects as PHP but may read as Pascal (#2279) — unless |
| 1021 | // codegraph.json maps `.inc` explicitly, which detectLanguage never overrides. |
| 1022 | if ( |
| 1023 | !languages.includes('pascal') && |
| 1024 | !(overrides && overrides['.inc']) && |
| 1025 | files.some((f) => f.toLowerCase().endsWith('.inc')) |
| 1026 | ) { |
| 1027 | languages.push('pascal'); |
| 1028 | } |
| 1029 | return languages; |
| 1030 | } |
| 1031 | |
| 1032 | export class ScopeIgnore { |
| 1033 | private embedded: Array<{ root: string; matcher: Ignore }>; |
no test coverage detected