nullShortingTermination property
Returns the expression that terminates any null shorting that might occur in this expression. This may be called regardless of whether this expression is itself null-aware.
For example, the statement a?.b[c] = d;
contains the following
null-shortable subexpressions:
a?.b
a?.b[c]
a?.b[c] = d
Calling nullShortingTermination on any of these subexpressions yields
the expression a?.b[c] = d
, indicating that the null-shorting induced by
the ?.
causes the rest of the subexpression a?.b[c] = d
to be skipped.
Implementation
@override
Expression get nullShortingTermination {
var result = this;
while (true) {
var parent = result._nullShortingExtensionCandidate;
if (parent is NullShortableExpressionImpl &&
parent._extendsNullShorting(result)) {
result = parent;
} else {
return result;
}
}
}