()
| 813 | return markup.split('\n').filter((line) => /async\s*\(/.test(line)); |
| 814 | }, |
| 815 | nestedAsyncCallbacks(): EnumeratedBlock[] { |
| 816 | const out: EnumeratedBlock[] = []; |
| 817 | // `async (args) =>`, `async arg =>`, and anonymous `async function (`. |
| 818 | // A NAMED `async function foo(` cannot match either alternative, so |
| 819 | // instrument A's rows are excluded by construction rather than by a |
| 820 | // filter that could drift out of step with A's own regex. |
| 821 | const re = /async\s*(?:\([^)]*\)|\w+)\s*=>|async\s+function\s*\(/g; |
| 822 | let m: RegExpExecArray | null; |
| 823 | while ((m = re.exec(script)) !== null) { |
| 824 | const label = `nested async callback at offset ${m.index}`; |
| 825 | // THE BODY STARTS AFTER THE ARROW, not at the first `{` after |
| 826 | // `async` (BUG-3084, ItemDetail). A DESTRUCTURED parameter — |
| 827 | // `async ({ ws, itemId }) => { … }` — opens a brace of its own, and |
| 828 | // delimiting from `async` returned the parameter list as the body: |
| 829 | // no awaits, no commits, so every rule a guard ran on it passed |
| 830 | // vacuously. An anonymous `async function (` is a declaration-shaped |
| 831 | // signature and takes `delimitDeclaration`, which already reads past |
| 832 | // braces in the parameter list. |
| 833 | if (m[0].startsWith('async') && /function\s*\($/.test(m[0])) { |
| 834 | out.push({ label, body: delimitDeclaration(script, m.index, label), index: m.index }); |
| 835 | continue; |
| 836 | } |
| 837 | const afterArrow = m.index + m[0].length; |
| 838 | const rest = script.slice(afterArrow); |
| 839 | const lead = /^\s*/.exec(rest)![0].length; |
| 840 | if (rest[lead] !== '{') { |
| 841 | // An expression-bodied async arrow has no block to delimit, and |
| 842 | // "the next `{` in the file" is somebody else's. Refuse. |
| 843 | throw new Error( |
| 844 | `${label} is not brace-bodied — this enumerator does not read that form. ` + |
| 845 | 'Teach it the shape rather than accepting a body it may have mis-delimited.' |
| 846 | ); |
| 847 | } |
| 848 | const brace = afterArrow + lead; |
| 849 | const end = matchBrace(script, brace); |
| 850 | if (end === -1) { |
| 851 | throw new Error(`could not delimit ${label} — re-point this guard rather than widening it`); |
| 852 | } |
| 853 | out.push({ label, body: script.slice(m.index, end + 1), index: m.index }); |
| 854 | } |
| 855 | return out; |
| 856 | }, |
| 857 | effectBlocks(): EnumeratedBlock[] { |
| 858 | const out: EnumeratedBlock[] = []; |
| 859 | // `$effect(` and `$effect.pre(` — NOT `$effect.root(`, which creates a |
nothing calls this directly
no test coverage detected