(filePath: string, context: ResolutionContext)
| 182 | * include it: the translation units (and headers) it is part of. |
| 183 | */ |
| 184 | export function cppIncluders(filePath: string, context: ResolutionContext): ReadonlySet<string> { |
| 185 | const memo = memoFor(context); |
| 186 | const hit = memo.includers.get(filePath); |
| 187 | if (hit) return hit; |
| 188 | const byName = includesByName(context, memo); |
| 189 | const found = new Set<string>(); |
| 190 | const queue = [filePath]; |
| 191 | for (let i = 0; i < queue.length; i++) { |
| 192 | const target = queue[i]!; |
| 193 | const name = fileName(target); |
| 194 | const dot = name.lastIndexOf('.'); |
| 195 | // `#include "foo"` can name `foo.h`: the include resolver tries extensions. |
| 196 | for (const spelled of dot > 0 ? [name, name.slice(0, dot)] : [name]) { |
| 197 | for (const include of byName.get(spelled) ?? []) { |
| 198 | if (include.file === filePath || found.has(include.file)) continue; |
| 199 | if (includedFile(include, context, memo) !== target) continue; |
| 200 | found.add(include.file); |
| 201 | queue.push(include.file); |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | memo.includers.set(filePath, found); |
| 206 | return found; |
| 207 | } |
no test coverage detected