(edges: readonly GraphEdge[], root: number)
| 52 | /** The root's outgoing CALLS in source order: by call-site line, calls without |
| 53 | * a recorded line last, then by callee. Every call site is its own step. */ |
| 54 | export function callOrder(edges: readonly GraphEdge[], root: number): ScopePathStep[] { |
| 55 | return edges.map((edge, index) => ({ edge, index })) |
| 56 | .filter(({ edge }) => edge.type === 'CALLS' && edge.source === root && edge.target !== root) |
| 57 | .sort((a, b) => (a.edge.line ?? Number.MAX_SAFE_INTEGER) - (b.edge.line ?? Number.MAX_SAFE_INTEGER) |
| 58 | || a.edge.target - b.edge.target || a.index - b.index) |
| 59 | .map(({ edge }) => ({ edge, from: root, to: edge.target })); |
| 60 | } |
| 61 | |
| 62 | /** Every node a path touches, roots included. */ |
| 63 | export function pathNodes(steps: readonly ScopePathStep[], roots: ReadonlySet<number>): Set<number> { |
no outgoing calls
no test coverage detected