* The blocks the code from `from` to `to` leaves open, in order, each as its * opener's offset and kind (OPEN_BEGIN, OPEN_ASM, or OPEN_OTHER for `try`, * `case` and `record`), or null when it closes a block it didn't open.
(s: string, from: number, to: number)
| 619 | * `case` and `record`), or null when it closes a block it didn't open. |
| 620 | */ |
| 621 | function openBlocks(s: string, from: number, to: number): Array<[number, number]> | null { |
| 622 | const open: Array<[number, number]> = []; |
| 623 | let i = from; |
| 624 | while (i < to) { |
| 625 | const k = commentOrStringEnd(s, i); |
| 626 | if (k >= 0) { |
| 627 | i = k; |
| 628 | continue; |
| 629 | } |
| 630 | if (isIdentStart(s.charCodeAt(i))) { |
| 631 | const e = wordEnd(s, i + 1); |
| 632 | if (e - i >= 3 && e - i <= 6) { |
| 633 | const word = s.slice(i, e).toLowerCase(); |
| 634 | if (word === 'end') { |
| 635 | if (open.pop() === undefined) return null; |
| 636 | } else if (BLOCK_OPENERS.has(word)) { |
| 637 | open.push([i, word === 'begin' ? OPEN_BEGIN : word === 'asm' ? OPEN_ASM : OPEN_OTHER]); |
| 638 | } |
| 639 | } |
| 640 | i = e; |
| 641 | continue; |
| 642 | } |
| 643 | i++; |
| 644 | } |
| 645 | return open; |
| 646 | } |
| 647 | |
| 648 | /** |
| 649 | * In every conditional (holding no conditional of its own) whose branches |
no test coverage detected