MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / closureCallNames

Function closureCallNames

src/resolution/frameworks/swift.ts:426–441  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

424 * of an expression (`a.b().c(`) names nothing this can follow.
425 */
426function 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
444const VIEW_DIRS = ['/Views/', '/View/', '/Screens/', '/Components/', '/UI/'];

Callers 1

extractFunction · 0.85

Calls 4

hasMethod · 0.80
pushMethod · 0.80
execMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected