(sub: string)
| 404 | // ----- Recursive summarizer for nested patterns ----- |
| 405 | // 递归汇总:将子模式转为 glob,并估算 min/var |
| 406 | function summarizePattern(sub: string): Unit | null { |
| 407 | const g = regexToGlob(sub); |
| 408 | if (g === null) return null; |
| 409 | let min = 0, |
| 410 | varStar = false; |
| 411 | for (let k = 0; k < g.length; k++) { |
| 412 | const ch = g[k]; |
| 413 | if (ch === "\\") { |
| 414 | k++; |
| 415 | if (k < g.length) min += 1; |
| 416 | } else if (ch === "*") { |
| 417 | varStar = true; |
| 418 | } else if (ch === "?") { |
| 419 | min += 1; |
| 420 | } else { |
| 421 | min += 1; |
| 422 | } |
| 423 | } |
| 424 | return { glob: g, baseGlob: "?".repeat(min), canRepeat: true, min, isLiteral: false, varLen: varStar }; |
| 425 | } |
| 426 | const globIsPureLiteral = (s: string) => s.indexOf("*") === -1 && s.indexOf("?") === -1; |
| 427 | |
| 428 | // ----- Group parsing (alternations, lookaheads, etc.) ----- |
no test coverage detected