queuedBodyOf function
- AstNode node
The job body of this controller that waits for node, when there is
one: its context, and the lane field whose enqueue takes the body.
node is in the body itself, in the actions of waiting calls on its
context or in its cleanup, which the queue waits for as well. The body
takes a SoloContext and is given to a call on this controller, on the
context of a body queued here or on a lane field, or to no call; the
class or the mixin around is a controller. A child runs where its parent
does: the child of a job of another controller runs there.
The lane is null for a body given to anything but enqueue of a lane:
a body given to job may run as a child in another lane, and a handler
of collect or accumulate runs where its group goes. A rule that
reports a wait for the own queue or the own lane looks at this body, and
a rule that leaves a wait for the own lane to it asks the same.
Implementation
({Element ctx, Element? lane})? queuedBodyOf(AstNode node) {
final around = controllerAround(node);
if (!isSolo(around) && !isSoloController(around)) return null;
final crossed = <Element>[];
for (var at = node.parent; at != null; at = at.parent) {
if (at is! FunctionExpression) continue;
final ctx = jobContextOf(at);
if (ctx != null) {
if (!isSoloContext(ctx.type)) return null;
if (!crossed.every((c) => c == ctx)) return null;
return _queuedHere(at, ctx);
}
final through = waitingContext(at) ?? cleanupContext(at);
if (through == null) return null;
crossed.add(through);
}
return null;
}