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

Function resolveRegistryHandler

src/resolution/callback-synthesizer.ts:2206–2226  ·  view source on GitHub ↗

Resolve a registered handler name to its callable entry: a function value, or a class's * `execute`-like method (preferring the method chained at the dispatch site), else the class.

(ctx: ResolutionContext, name: string, chained: string | null)

Source from the content-addressed store, hash-verified

2204/** Resolve a registered handler name to its callable entry: a function value, or a class's
2205 * `execute`-like method (preferring the method chained at the dispatch site), else the class. */
2206function resolveRegistryHandler(ctx: ResolutionContext, name: string, chained: string | null): Node | null {
2207 const cands = ctx.getNodesByName(name);
2208 const fn = cands.find((n) => n.kind === 'function');
2209 if (fn) return fn;
2210 const cls = cands.find((n) => n.kind === 'class' || n.kind === 'struct');
2211 if (cls) {
2212 const methods = ctx
2213 .getNodesInFile(cls.filePath)
2214 .filter((n) => n.kind === 'method' && n.startLine >= cls.startLine && n.startLine <= (cls.endLine ?? cls.startLine));
2215 const want = chained && REGISTRY_CLASS_ENTRY.has(chained) ? chained : null;
2216 const entry =
2217 (want && methods.find((m) => m.name === want)) ||
2218 methods.find((m) => REGISTRY_CLASS_ENTRY.has(m.name)) ||
2219 methods.find((m) => m.name === 'constructor');
2220 return entry ?? cls;
2221 }
2222 // Require a CALLABLE target — a registry dispatched as `reg[k](…)` invokes a function/
2223 // method, never a data `constant` (dropping it removes false positives like a `{ x: URL }`
2224 // entry resolving to the global URL constant).
2225 return cands.find((n) => n.kind === 'method') ?? null;
2226}
2227
2228async function objectRegistryEdges(ctx: ResolutionContext, onYield: MaybeYield): Promise<Edge[]> {
2229 let scannedFiles = 0;

Callers 1

objectRegistryEdgesFunction · 0.85

Calls 3

hasMethod · 0.80
getNodesByNameMethod · 0.65
getNodesInFileMethod · 0.65

Tested by

no test coverage detected