* The index after the `]` closing the attribute group whose `[` is at `i`, * or -1 when the group doesn't close the way an attribute does: nested * brackets and parentheses balance, strings and comments are skipped, and an * attribute's arguments hold no `;`.
(s: string, i: number)
| 247 | * attribute's arguments hold no `;`. |
| 248 | */ |
| 249 | function attributeEnd(s: string, i: number): number { |
| 250 | const limit = Math.min(s.length, i + MAX_ATTRIBUTE_LENGTH); |
| 251 | let depth = 0; |
| 252 | let j = i; |
| 253 | while (j < limit) { |
| 254 | const k = commentOrStringEnd(s, j); |
| 255 | if (k >= 0) { |
| 256 | j = k; |
| 257 | continue; |
| 258 | } |
| 259 | const c = s.charCodeAt(j); |
| 260 | if (c === CH_LBRACKET || c === CH_LPAREN) { |
| 261 | depth++; |
| 262 | } else if (c === CH_RBRACKET || c === CH_RPAREN) { |
| 263 | depth--; |
| 264 | if (depth === 0) return c === CH_RBRACKET ? j + 1 : -1; |
| 265 | } else if (c === CH_SEMI) { |
| 266 | return -1; |
| 267 | } |
| 268 | j++; |
| 269 | } |
| 270 | return -1; |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * The index after a routine's name — `Name`, `TFoo.Bar`, `TFoo<T>.Bar<U>`, |
no test coverage detected