Past an implicit expression starting at `at` (after the `@`): names, members, calls and indexers.
(s: string, at: number)
| 66 | |
| 67 | /** Past an implicit expression starting at `at` (after the `@`): names, members, calls and indexers. */ |
| 68 | function pastExpression(s: string, at: number): number { |
| 69 | let i = at; |
| 70 | const awaited = /^await\s+/.exec(s.slice(i, i + 16)); |
| 71 | if (awaited) i += awaited[0].length; |
| 72 | const name = /^[A-Za-z_]\w*/.exec(s.slice(i, i + 128)); |
| 73 | if (!name) return at; |
| 74 | i += name[0].length; |
| 75 | for (;;) { |
| 76 | const c = s[i]; |
| 77 | if (c === '(' || c === '[') { |
| 78 | const end = pastBracket(s, i); |
| 79 | if (end < 0) return i; |
| 80 | i = end; |
| 81 | } else if (c === '<' && /^<[A-Z][\w.,\s<>?]*>\(/.test(s.slice(i, i + 80))) { |
| 82 | // A generic call: `@Html.Partial<Foo>(…)`. |
| 83 | i = s.indexOf('(', i); |
| 84 | } else if ((c === '.' || (c === '?' && s[i + 1] === '.')) && /[A-Za-z_]/.test(s[i + (c === '.' ? 1 : 2)] ?? '')) { |
| 85 | i += c === '.' ? 1 : 2; |
| 86 | const member = /^\w+/.exec(s.slice(i, i + 128)); |
| 87 | i += member?.[0].length ?? 0; |
| 88 | } else { |
| 89 | return i; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /** Where the `</text>` closing the `<text>` at `open` starts, nested ones counted; -1 if none before `to`. */ |
| 95 | function closingText(s: string, open: number, to: number): number { |
no test coverage detected