MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / loopsForFile

Function loopsForFile

src/graph/branch-guards.ts:1033–1043  ·  view source on GitHub ↗
(absPath: string, language: Language, sites: readonly CallSite[])

Source from the content-addressed store, hash-verified

1031
1032/** Loops for many sites in one file, keyed by {@link siteKey}. */
1033export 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`. */
1046function loopHeader(loop: SyntaxNode): string {

Callers 1

loopsFunction · 0.90

Calls 6

supportsBranchGuardsFunction · 0.85
treeForFunction · 0.85
siteKeyFunction · 0.85
loopsInTreeFunction · 0.85
hasMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected