(
source: string,
openIndex: number,
open: "{" | "[",
close: "}" | "]",
)
| 201 | } |
| 202 | |
| 203 | function findMatchingDelimiter( |
| 204 | source: string, |
| 205 | openIndex: number, |
| 206 | open: "{" | "[", |
| 207 | close: "}" | "]", |
| 208 | ): number { |
| 209 | let depth = 0; |
| 210 | |
| 211 | for (let current = openIndex; current < source.length; current++) { |
| 212 | const char = source[current]; |
| 213 | const next = source[current + 1]; |
| 214 | |
| 215 | if (char === "\"" || char === "'" || char === "`") { |
| 216 | const literal = readStringLiteral(source, current); |
| 217 | if (!literal) return -1; |
| 218 | current = literal.end - 1; |
| 219 | continue; |
| 220 | } |
| 221 | |
| 222 | if (char === "/" && next === "/") { |
| 223 | const newline = source.indexOf("\n", current + 2); |
| 224 | current = newline === -1 ? source.length : newline; |
| 225 | continue; |
| 226 | } |
| 227 | |
| 228 | if (char === "/" && next === "*") { |
| 229 | const end = source.indexOf("*/", current + 2); |
| 230 | if (end === -1) return -1; |
| 231 | current = end + 1; |
| 232 | continue; |
| 233 | } |
| 234 | |
| 235 | if (char === open) { |
| 236 | depth += 1; |
| 237 | continue; |
| 238 | } |
| 239 | |
| 240 | if (char === close) { |
| 241 | depth -= 1; |
| 242 | if (depth === 0) return current; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | return -1; |
| 247 | } |
| 248 | |
| 249 | function collectStringConstants(source: string): Map<string, string> { |
| 250 | const constants = new Map<string, string>(); |
no test coverage detected