( absPath: string, language: Language, sites: readonly CallSite[] )
| 246 | * empty map. |
| 247 | */ |
| 248 | export async function guardsForFile( |
| 249 | absPath: string, |
| 250 | language: Language, |
| 251 | sites: readonly CallSite[] |
| 252 | ): Promise<Map<string, BranchGuard[]>> { |
| 253 | const out = new Map<string, BranchGuard[]>(); |
| 254 | if (!supportsBranchGuards(language) || sites.length === 0) return out; |
| 255 | const cached = await treeFor(absPath, language); |
| 256 | if (!cached) return out; |
| 257 | for (const site of sites) { |
| 258 | const key = siteKey(site); |
| 259 | if (out.has(key)) continue; |
| 260 | out.set(key, guardsInTree(cached.tree.rootNode, cached.source, language, site.line, site.column ?? null)); |
| 261 | } |
| 262 | return out; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Synchronous twin of {@link guardsForFile} for callers that cannot await |
no test coverage detected