(absPath: string, language: Language, sites: readonly CallSite[])
| 1031 | |
| 1032 | /** Loops for many sites in one file, keyed by {@link siteKey}. */ |
| 1033 | export async function loopsForFile(absPath: string, language: Language, sites: readonly CallSite[]): Promise<Map<string, SiteLoop[]>> { |
| 1034 | const out = new Map<string, SiteLoop[]>(); |
| 1035 | if (!supportsBranchGuards(language) || sites.length === 0) return out; |
| 1036 | const cached = await treeFor(absPath, language); |
| 1037 | if (!cached) return out; |
| 1038 | for (const site of sites) { |
| 1039 | const key = siteKey(site); |
| 1040 | if (!out.has(key)) out.set(key, loopsInTree(cached.tree.rootNode, cached.source, language, site.line, site.column ?? null)); |
| 1041 | } |
| 1042 | return out; |
| 1043 | } |
| 1044 | |
| 1045 | /** A loop's header as written, keyword and braces dropped: `item of items`, `queue.length > 0`. */ |
| 1046 | function loopHeader(loop: SyntaxNode): string { |
no test coverage detected