The index after the last character before `i` that is neither whitespace nor in a `{…}` or `(*…*)` comment.
(s: string, i: number)
| 192 | |
| 193 | /** The index after the last character before `i` that is neither whitespace nor in a `{…}` or `(*…*)` comment. */ |
| 194 | function tokenEndBefore(s: string, i: number): number { |
| 195 | for (;;) { |
| 196 | while (i > 0 && isSpace(s.charCodeAt(i - 1))) i--; |
| 197 | if (i > 0 && s.charCodeAt(i - 1) === CH_RBRACE) { |
| 198 | const open = s.lastIndexOf('{', i - 2); |
| 199 | if (open < 0) return i; |
| 200 | i = open; |
| 201 | } else if (i > 1 && s.charCodeAt(i - 1) === CH_RPAREN && s.charCodeAt(i - 2) === CH_STAR) { |
| 202 | const open = s.lastIndexOf('(*', i - 3); |
| 203 | if (open < 0) return i; |
| 204 | i = open; |
| 205 | } else { |
| 206 | return i; |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | /** The start of the identifier that ends at `i`, or -1 when none does. */ |
| 212 | function wordStartBefore(s: string, i: number): number { |
no test coverage detected