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

Method whenLabel

src/mcp/tools.ts:3678–3694  ·  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

3676 * unreadable, or the grammar for that language is not loaded.
3677 */
3678 private whenLabel(cg: CodeGraph, caller: Node, edge: Edge): string {
3679 if (!edge.line || !supportsBranchGuards(caller.language)) return '';
3680 try {
3681 const rec = cg.getFile(caller.filePath);
3682 if (!rec) return '';
3683 const abs = validatePathWithinRoot(cg.getProjectRoot(), caller.filePath);
3684 if (!abs) return '';
3685 const st = statSync(abs);
3686 // Drifted since the index: the recorded line may point elsewhere.
3687 if (st.size !== rec.size || Math.floor(st.mtimeMs) !== Math.floor(rec.modifiedAt)) return '';
3688 const site = { line: edge.line, column: typeof edge.column === 'number' ? edge.column : null };
3689 const g = guardsForFileSync(abs, caller.language, [site]).get(siteKey(site));
3690 return g ? guardLabel(g) : '';
3691 } catch {
3692 return '';
3693 }
3694 }
3695
3696 /**
3697 * 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.65
getProjectRootMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected