* The edge that already connects two symbols the reader walked between. * * A trail is not searched — the hops are given — so all that is missing is * which recorded edge the reader crossed. A `down` hop is a call out of the * previous symbol; an `up` hop is the same edge read backwards, which i
( cg: CodeGraph, from: Node, to: Node )
| 625 | * `upward` exists and why the link says "called by" rather than "calls". |
| 626 | */ |
| 627 | function edgeBetween( |
| 628 | cg: CodeGraph, |
| 629 | from: Node, |
| 630 | to: Node |
| 631 | ): { edge: Edge; upward: boolean } | null { |
| 632 | let best: Edge | null = null; |
| 633 | for (const { node, edge } of cg.getCallees(from.id)) { |
| 634 | if (node.id !== to.id) continue; |
| 635 | if (best === null || (edge.kind === 'calls' && best.kind !== 'calls')) best = edge; |
| 636 | } |
| 637 | if (best) return { edge: best, upward: false }; |
| 638 | for (const { node, edge } of cg.getCallers(from.id)) { |
| 639 | if (node.id !== to.id) continue; |
| 640 | if (best === null || (edge.kind === 'calls' && best.kind !== 'calls')) best = edge; |
| 641 | } |
| 642 | return best ? { edge: best, upward: true } : null; |
| 643 | } |
| 644 | |
| 645 | function ambiguitiesOf( |
| 646 | tokenNodes: ReadonlyMap<string, string[]>, |
no test coverage detected