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

Method whenLabel

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

3837 * unreadable, or the grammar for that language is not loaded.
3838 */
3839 private whenLabel(cg: CodeGraph, caller: Node, edge: Edge): string {
3840 if (!edge.line || !supportsBranchGuards(caller.language)) return '';
3841 try {
3842 const rec = cg.getFile(caller.filePath);
3843 if (!rec) return '';
3844 const abs = validatePathWithinRoot(cg.getProjectRoot(), caller.filePath);
3845 if (!abs) return '';
3846 const st = statSync(abs);
3847 // Drifted since the index: the recorded line may point elsewhere.
3848 if (st.size !== rec.size || Math.floor(st.mtimeMs) !== Math.floor(rec.modifiedAt)) return '';
3849 const site = { line: edge.line, column: typeof edge.column === 'number' ? edge.column : null };
3850 const g = guardsForFileSync(abs, caller.language, [site]).get(siteKey(site));
3851 return g ? guardLabel(g) : '';
3852 } catch {
3853 return '';
3854 }
3855 }
3856
3857 /**
3858 * 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