* The calls a route closure's body makes, each once, keeping the receiver * (`Todo.query`, `req.auth.require`) so they resolve as calls on it. A member * of an expression (`a.b().c(`) names nothing this can follow.
(body: string)
| 424 | * of an expression (`a.b().c(`) names nothing this can follow. |
| 425 | */ |
| 426 | function closureCallNames(body: string): string[] { |
| 427 | const out: string[] = []; |
| 428 | const seen = new Set<string>(); |
| 429 | const callRe = /((?:[A-Za-z_]\w*\s*[?!]?\.\s*)*)([A-Za-z_]\w*)\s*\(/g; |
| 430 | let m: RegExpExecArray | null; |
| 431 | while ((m = callRe.exec(body)) !== null) { |
| 432 | const callee = m[2]!; |
| 433 | const receiver = m[1]!.replace(/[\s?!]/g, '').replace(/\.$/, ''); |
| 434 | if (!receiver && (SWIFT_NOT_CALLS.has(callee) || /[.)\]]\s*$/.test(body.slice(0, m.index)))) continue; |
| 435 | const name = receiver ? `${receiver}.${callee}` : callee; |
| 436 | if (seen.has(name)) continue; |
| 437 | seen.add(name); |
| 438 | out.push(name); |
| 439 | } |
| 440 | return out; |
| 441 | } |
| 442 | |
| 443 | // Directory patterns |
| 444 | const VIEW_DIRS = ['/Views/', '/View/', '/Screens/', '/Components/', '/UI/']; |