Past the bracket group opening at `i`, strings and comments inside skipped; -1 when it doesn't close.
(source: string, i: number, open: number, close: number)
| 214 | |
| 215 | /** Past the bracket group opening at `i`, strings and comments inside skipped; -1 when it doesn't close. */ |
| 216 | function groupEnd(source: string, i: number, open: number, close: number): number { |
| 217 | let depth = 0; |
| 218 | for (let j = i; j < source.length; j++) { |
| 219 | const c = source.charCodeAt(j); |
| 220 | if (c === QUOTE || c === APOSTROPHE) j = quotedEnd(source, j) - 1; |
| 221 | else if (c === SLASH && source.charCodeAt(j + 1) === SLASH) j = lineCommentEnd(source, j + 2) - 1; |
| 222 | else if (c === SLASH && source.charCodeAt(j + 1) === STAR) { |
| 223 | const end = source.indexOf('*/', j + 2); |
| 224 | if (end < 0) return -1; |
| 225 | j = end + 1; |
| 226 | } else if (c === open) depth++; |
| 227 | else if (c === close && --depth === 0) return j + 1; |
| 228 | else if (c === SEMICOLON || c === LBRACE) return -1; |
| 229 | } |
| 230 | return -1; |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Split an Objective-C++ file into what the Objective-C grammar reads and what |
no test coverage detected