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