Source order of two hops: a hop written inside the other's call runs first; else by position; another file sorts after.
(a: HopSite | undefined, b: HopSite | undefined)
| 1735 | |
| 1736 | /** Source order of two hops: a hop written inside the other's call runs first; else by position; another file sorts after. */ |
| 1737 | function hopCompare(a: HopSite | undefined, b: HopSite | undefined): number { |
| 1738 | if (!a || !b) return a ? -1 : b ? 1 : 0; |
| 1739 | if (a.file !== b.file) return a.file.localeCompare(b.file); |
| 1740 | if (hopInside(a, b)) return -1; |
| 1741 | if (hopInside(b, a)) return 1; |
| 1742 | return a.line - b.line || a.column - b.column; |
| 1743 | } |
| 1744 | |
| 1745 | /** `x` starts strictly after `y` starts and before `y` ends. */ |
| 1746 | function hopInside(x: HopSite, y: HopSite): boolean { |
no test coverage detected