buildScope method
void
buildScope()
Rebuilds all dirty elements in maintained-depth order under a reentrancy guard. Performs zero Element parent walks.
A throwing rebuild ends the pass and propagates unchanged. The failed element is not retried, but every element the pass had not reached yet stays queued in its original order, and a frame is requested for it, so a host that survives the error drains that work on its next pass.
Implementation
void buildScope() {
if (_building) {
throw StateError('BuildOwner.buildScope cannot be re-entered');
}
_building = true;
try {
while (!_pendingBuckets.isEmpty) {
final batch = _pendingBuckets;
_pendingBuckets = _DirtyBuckets();
final entries = batch.entriesInOrder().iterator;
try {
while (entries.moveNext()) {
final dirty = entries.current;
final element = dirty.element;
if (!_holdsLiveReservation(dirty)) {
// Stale: cascade rebuild, rebucket, or clearDirty already won.
continue;
}
_dirtyReservations.remove(element);
if (!element.active) {
continue;
}
element.rebuild();
}
} on Object {
_restoreUnvisited(entries);
rethrow;
}
}
finalizeTree();
} finally {
_building = false;
}
}