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

Function guardsForFile

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

Source from the content-addressed store, hash-verified

246 * empty map.
247 */
248export 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

Callers 3

annotateWhenFunction · 0.90
guardsFunction · 0.90
whenAtFunction · 0.90

Calls 6

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

Tested by

no test coverage detected