* Phase 4b: Flutter setState → build (the Dart analog of react-render). In a * StatefulWidget's State class, `setState(() {…})` re-runs `build(context)`, but * that hop is framework-internal (Flutter calls build), so a flow like * "onPressed → _increment → setState → rebuilt UI" dead-ends at setS
(queries: QueryBuilder, ctx: ResolutionContext, onYield: MaybeYield)
| 419 | * Flutter State classes. Over-approximation accepted (reachability-correct). |
| 420 | */ |
| 421 | async function flutterBuildEdges(queries: QueryBuilder, ctx: ResolutionContext, onYield: MaybeYield): Promise<Edge[]> { |
| 422 | let scanned255 = 0; |
| 423 | const edges: Edge[] = []; |
| 424 | const seen = new Set<string>(); |
| 425 | for (const cls of queries.iterateNodesByKind('class')) { |
| 426 | if ((++scanned255 & 63) === 0) await onYield(); |
| 427 | const children = queries.getOutgoingEdges(cls.id, ['contains']) |
| 428 | .map((e) => queries.getNodeById(e.target)) |
| 429 | .filter((n): n is Node => !!n && n.kind === 'method'); |
| 430 | const build = children.find((n) => n.name === 'build'); |
| 431 | if (!build || !build.filePath.endsWith('.dart')) continue; |
| 432 | let added = 0; |
| 433 | for (const m of children) { |
| 434 | if (added >= MAX_CALLBACKS_PER_CHANNEL) break; |
| 435 | if (m.id === build.id) continue; |
| 436 | const content = ctx.readFile(m.filePath); |
| 437 | const src = content && sliceLines(content, m.startLine, m.endLine); |
| 438 | if (!src || !FLUTTER_SETSTATE_RE.test(src)) continue; |
| 439 | const key = `${m.id}>${build.id}`; |
| 440 | if (seen.has(key)) continue; |
| 441 | seen.add(key); |
| 442 | edges.push({ |
| 443 | source: m.id, target: build.id, kind: 'calls', line: m.startLine, |
| 444 | provenance: 'heuristic', |
| 445 | metadata: { synthesizedBy: 'flutter-build', via: 'setState', registeredAt: `${build.filePath}:${build.startLine}` }, |
| 446 | }); |
| 447 | added++; |
| 448 | } |
| 449 | } |
| 450 | return edges; |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * Reactive ArkUI property decorators: assigning a property carrying one of |
no test coverage detected