* The bracket closing the one at `open`. A `[…]` list counts only square * brackets and parentheses — Scala's bounds `B >: A` and `A <: AnyRef` are not * angle brackets — and a `<…>` list skips the `->` / `=>` inside its bounds.
(text: string, open: number)
| 304 | * angle brackets — and a `<…>` list skips the `->` / `=>` inside its bounds. |
| 305 | */ |
| 306 | function matchingBracket(text: string, open: number): number { |
| 307 | const angle = text[open] === '<'; |
| 308 | const closer = angle ? '>' : text[open] === '[' ? ']' : ')'; |
| 309 | let depth = 0; |
| 310 | for (let i = open; i < text.length; i++) { |
| 311 | const c = text[i]!; |
| 312 | if (c === '{' || c === ';') return -1; |
| 313 | if (isOpener(c, angle)) depth++; |
| 314 | else if (isCloser(c, angle, text[i - 1])) { |
| 315 | depth--; |
| 316 | if (depth === 0) return c === closer ? i : -1; |
| 317 | } |
| 318 | } |
| 319 | return -1; |
| 320 | } |
| 321 | |
| 322 | function splitTopLevel(inner: string, angle: boolean): string[] { |
| 323 | const out: string[] = []; |
no test coverage detected