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

Function handlerCallNames

src/resolution/frameworks/express.ts:64–83  ·  view source on GitHub ↗

* The calls an inline handler's body makes, each once, framework noise aside. * A member call keeps its receiver (`userService.find`, `c.text`) so it * resolves as one: bare, hono's `c.text('…')` matched its client's * `ClientResponse.text` 423 times. A member of an expression (`a.b().c(`) * nam

(body: string)

Source from the content-addressed store, hash-verified

62 * names nothing this can follow.
63 */
64function handlerCallNames(body: string): string[] {
65 const out: string[] = [];
66 const seen = new Set<string>();
67 const callRe = /((?:[A-Za-z_$][\w$]*\s*\??\.\s*)*)([A-Za-z_$][\w$]*)\s*\(/g;
68 let cm: RegExpExecArray | null;
69 while ((cm = callRe.exec(body)) !== null) {
70 const method = cm[2]!;
71 const receiver = cm[1]!.replace(/\s|\?/g, '').replace(/\.$/, '');
72 if (!receiver && /\.\s*$/.test(body.slice(0, cm.index))) continue;
73 // A keyword is only a keyword when it isn't a member: `if (` is not a
74 // call, `userService.delete(` is. `function helper(` declares helper.
75 if (!receiver && JS_KEYWORDS.has(method)) continue;
76 if (!receiver && /\bfunction\s*\*?\s*$/.test(body.slice(Math.max(0, cm.index - 12), cm.index))) continue;
77 const name = receiver ? `${receiver}.${method}` : method;
78 if (seen.has(name) || RESERVED_CALLS.has(method)) continue;
79 seen.add(name);
80 out.push(name);
81 }
82 return out;
83}
84
85/**
86 * The replies an inline handler makes — `res.status(404).json({…})`,

Callers 1

handlerRefsFunction · 0.85

Calls 4

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

Tested by

no test coverage detected