* 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)
| 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 |
no test coverage detected