* The names a sync has to look at the methods of: any a changed file declares or * calls, then or now; those of the methods calling a name it defined or * undefined; and those of the flows on record that read one, or that rest on a * name a file now writes a different number of times, which it co
(sync: FlowSync, adapter: ParameterFlowAdapter<any>, pass: FlowPass<any>, queries: ParameterFlowQueries)
| 551 | * an ancestor, what the adapter says shapes a class. |
| 552 | */ |
| 553 | async function namesToReview(sync: FlowSync, adapter: ParameterFlowAdapter<any>, pass: FlowPass<any>, queries: ParameterFlowQueries): Promise<Set<string> | null> { |
| 554 | const { before, record } = sync; |
| 555 | const names = new Set<string>(); |
| 556 | const defined = new Set<string>(); |
| 557 | for (const [file, was] of before) { |
| 558 | const now = queries.getFlowFacts(file); |
| 559 | if (was.classes.join('\0') !== now.classes.join('\0')) return null; |
| 560 | const declared = new Set(now.methods); |
| 561 | const declaredThen = new Set(was.methods); |
| 562 | for (const method of declared) { |
| 563 | names.add(method); |
| 564 | if (!declaredThen.has(method)) defined.add(method); |
| 565 | } |
| 566 | for (const method of declaredThen) { |
| 567 | names.add(method); |
| 568 | if (!declared.has(method)) defined.add(method); |
| 569 | } |
| 570 | for (const refName of [...was.calls, ...now.calls]) { |
| 571 | const call = adapter.readCall(refName); |
| 572 | if (call) names.add(call.method); |
| 573 | } |
| 574 | } |
| 575 | for (const name of defined) { |
| 576 | if (adapter.shapesClass(name)) return null; |
| 577 | for (const caller of pass.callersOf(name)) names.add(caller.name); |
| 578 | } |
| 579 | // Every name on record stays counted, so the next sync can trust them all. |
| 580 | const files = [...before.keys()]; |
| 581 | const written = await adapter.written(new Set(record.written.keys()), files); |
| 582 | const recounted = new Set<string>(); |
| 583 | for (const [name, byFile] of record.written) { |
| 584 | for (const file of files) { |
| 585 | const count = written.get(name)?.get(file); |
| 586 | if (count === byFile.get(file)) continue; |
| 587 | recounted.add(name); |
| 588 | if (count === undefined) byFile.delete(file); |
| 589 | else byFile.set(file, count); |
| 590 | } |
| 591 | } |
| 592 | for (const flow of record.flows) { |
| 593 | if (flow.names === null || flow.names.some((name) => names.has(name) || recounted.has(name))) names.add(flowKeyName(flow.key)); |
| 594 | } |
| 595 | return names; |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * What the flows want done to the graph, for one language. Handed a sync, null |
no test coverage detected