( file: string, quote: string, spec: string, language: UnresolvedRef['language'], context: ResolutionContext, cache: Cache )
| 210 | } |
| 211 | |
| 212 | function resolveInclude( |
| 213 | file: string, |
| 214 | quote: string, |
| 215 | spec: string, |
| 216 | language: UnresolvedRef['language'], |
| 217 | context: ResolutionContext, |
| 218 | cache: Cache |
| 219 | ): string | null { |
| 220 | const key = `${language}\0${file}\0${quote}${spec}`; |
| 221 | const cached = cache.includes.get(key); |
| 222 | if (cached !== undefined) return cached; |
| 223 | const local = path.posix.normalize(path.posix.join(path.posix.dirname(file), spec.replace(/\\/g, '/'))); |
| 224 | let target = |
| 225 | quote === '"' && !local.startsWith('../') && !path.posix.isAbsolute(local) && context.fileExists(local) |
| 226 | ? local |
| 227 | : resolveImportPath(spec, file, language, context); |
| 228 | if (!target) { |
| 229 | if (!cache.byBasename) { |
| 230 | cache.byBasename = new Map(); |
| 231 | for (const f of context.getAllFiles()) { |
| 232 | const base = f.slice(f.lastIndexOf('/') + 1); |
| 233 | const list = cache.byBasename.get(base); |
| 234 | if (list) list.push(f); |
| 235 | else cache.byBasename.set(base, [f]); |
| 236 | } |
| 237 | } |
| 238 | const normalized = spec.replace(/\\/g, '/'); |
| 239 | const matches = (cache.byBasename.get(normalized.slice(normalized.lastIndexOf('/') + 1)) ?? []).filter( |
| 240 | (f) => f === normalized || f.endsWith('/' + normalized) |
| 241 | ); |
| 242 | if (matches.length === 1) target = matches[0]!; |
| 243 | } |
| 244 | cache.includes.set(key, target); |
| 245 | return target; |
| 246 | } |
| 247 | |
| 248 | function walkTranslationUnit( |
| 249 | rootFile: string, |
no test coverage detected