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

Method whenLabel

src/mcp/tools.ts:3660–3676  ·  view source on GitHub ↗

* The branch conditions a flow hop's call site runs under, read from the * caller's source now (`graph/branch-guards.ts`); '' when unconditional, * unreadable, or the grammar for that language is not loaded.

(cg: CodeGraph, caller: Node, edge: Edge)

Source from the content-addressed store, hash-verified

3658 * unreadable, or the grammar for that language is not loaded.
3659 */
3660 private whenLabel(cg: CodeGraph, caller: Node, edge: Edge): string {
3661 if (!edge.line || !supportsBranchGuards(caller.language)) return '';
3662 try {
3663 const rec = cg.getFile(caller.filePath);
3664 if (!rec) return '';
3665 const abs = validatePathWithinRoot(cg.getProjectRoot(), caller.filePath);
3666 if (!abs) return '';
3667 const st = statSync(abs);
3668 // Drifted since the index: the recorded line may point elsewhere.
3669 if (st.size !== rec.size || Math.floor(st.mtimeMs) !== Math.floor(rec.modifiedAt)) return '';
3670 const site = { line: edge.line, column: typeof edge.column === 'number' ? edge.column : null };
3671 const g = guardsForFileSync(abs, caller.language, [site]).get(siteKey(site));
3672 return g ? guardLabel(g) : '';
3673 } catch {
3674 return '';
3675 }
3676 }
3677
3678 /**
3679 * The tag a synthesized (dynamic-dispatch) hop carries in explore's Flow and

Callers 1

Calls 8

supportsBranchGuardsFunction · 0.90
validatePathWithinRootFunction · 0.90
guardsForFileSyncFunction · 0.90
siteKeyFunction · 0.90
guardLabelFunction · 0.90
getFileMethod · 0.80
getProjectRootMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected