* 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[])
| 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 { |