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

Method run

src/resolution/parameter-flow.ts:378–405  ·  view source on GitHub ↗

* Every flow of `candidates` into a parameter something is called on: the * typed ones, and the abstentions counted. A sync can type a method's * parameter that it only passes on, which no flow of its own shows, so it * hands `onward` the calls such a method makes, for the methods to go on

(candidates: FlowMethod[], maybeYield: MaybeYield, onward?: (names: string[]) => FlowMethod[])

Source from the content-addressed store, hash-verified

376 * hands `onward` the calls such a method makes, for the methods to go on to.
377 */
378 async run(candidates: FlowMethod[], maybeYield: MaybeYield, onward?: (names: string[]) => FlowMethod[]): Promise<TypedFlow[]> {
379 const typed: TypedFlow[] = [];
380 const queue = [...candidates];
381 for (let i = 0; i < queue.length; i++) {
382 const method = queue[i]!;
383 if (method.kind !== 'method' && !onward) continue;
384 const pause = maybeYield();
385 if (pause) await pause;
386 const signature = this.adapter.signature(method);
387 if (!signature || signature.parameters.length === 0) continue;
388 const receivers = this.adapter.receivers(method);
389 for (const parameter of signature.parameters) {
390 // A call no project method is named for has nothing for a flow to move.
391 const called = method.kind === 'method' && [...receivers.get(parameter.name) ?? []].some((name) => this.methods.isName(name));
392 if (!called && !(onward && this.adapter.passesOn(parameter.name, method))) continue;
393 const through = new Set<string>();
394 const value = this.flow(method, parameter, [], through);
395 if (!isFlowValue(value)) {
396 if (called) this.abstained[value] = (this.abstained[value] ?? 0) + 1;
397 } else if (called) {
398 typed.push({ method, parameter, sites: this.sitesOn(method, parameter.name), value, through });
399 } else {
400 queue.push(...onward!(this.callsPassingOn(method)));
401 }
402 }
403 }
404 return typed;
405 }
406
407 /** Whether a typed flow still stands now that `writtenElsewhere` is known. */
408 stands(flow: TypedFlow): boolean {

Callers 1

planFlowsFunction · 0.95

Calls 10

flowMethod · 0.95
sitesOnMethod · 0.95
callsPassingOnMethod · 0.95
isFlowValueFunction · 0.85
signatureMethod · 0.80
receiversMethod · 0.80
passesOnMethod · 0.80
pushMethod · 0.80
getMethod · 0.65
isNameMethod · 0.65

Tested by

no test coverage detected