* 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)
| 242 | * attribute's arguments hold no `;`. |
| 243 | */ |
| 244 | function attributeEnd(s: string, i: number): number { |
| 245 | const limit = Math.min(s.length, i + MAX_ATTRIBUTE_LENGTH); |
| 246 | let depth = 0; |
| 247 | let j = i; |
| 248 | while (j < limit) { |
| 249 | const k = commentOrStringEnd(s, j); |
| 250 | if (k >= 0) { |
| 251 | j = k; |
| 252 | continue; |
| 253 | } |
| 254 | const c = s.charCodeAt(j); |
| 255 | if (c === CH_LBRACKET || c === CH_LPAREN) { |
| 256 | depth++; |
| 257 | } else if (c === CH_RBRACKET || c === CH_RPAREN) { |
| 258 | depth--; |
| 259 | if (depth === 0) return c === CH_RBRACKET ? j + 1 : -1; |
| 260 | } else if (c === CH_SEMI) { |
| 261 | return -1; |
| 262 | } |
| 263 | j++; |
| 264 | } |
| 265 | return -1; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * The index after a routine's name — `Name`, `TFoo.Bar`, `TFoo<T>.Bar<U>`, |
no test coverage detected