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

Function flutterBuildEdges

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

* 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)

Source from the content-addressed store, hash-verified

483 * Flutter State classes. Over-approximation accepted (reachability-correct).
484 */
485async function flutterBuildEdges(queries: QueryBuilder, ctx: ResolutionContext, onYield: MaybeYield): Promise<Edge[]> {
486 let scanned255 = 0;
487 const edges: Edge[] = [];
488 const seen = new Set<string>();
489 for (const cls of queries.iterateNodesByKind('class')) {
490 if ((++scanned255 & 63) === 0) await onYield();
491 const children = queries.getOutgoingEdges(cls.id, ['contains'])
492 .map((e) => queries.getNodeById(e.target))
493 .filter((n): n is Node => !!n && n.kind === 'method');
494 const build = children.find((n) => n.name === 'build');
495 if (!build || !build.filePath.endsWith('.dart')) continue;
496 let added = 0;
497 for (const m of children) {
498 if (added >= MAX_CALLBACKS_PER_CHANNEL) break;
499 if (m.id === build.id) continue;
500 const content = ctx.readFile(m.filePath);
501 const src = content && sliceLines(content, m.startLine, m.endLine);
502 if (!src || !FLUTTER_SETSTATE_RE.test(src)) continue;
503 const key = `${m.id}>${build.id}`;
504 if (seen.has(key)) continue;
505 seen.add(key);
506 edges.push({
507 source: m.id, target: build.id, kind: 'calls', line: m.startLine,
508 provenance: 'heuristic',
509 metadata: { synthesizedBy: 'flutter-build', via: 'setState', registeredAt: `${build.filePath}:${build.startLine}` },
510 });
511 added++;
512 }
513 }
514 return edges;
515}
516
517/**
518 * Reactive ArkUI property decorators: assigning a property carrying one of

Callers 1

Calls 9

sliceLinesFunction · 0.85
mapMethod · 0.80
readFileMethod · 0.80
hasMethod · 0.80
pushMethod · 0.80
iterateNodesByKindMethod · 0.65
getNodeByIdMethod · 0.65
getOutgoingEdgesMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected