@@ -29,8 +29,12 @@ class AnyNodeMatcher implements NodeMatcher {
29
29
NullabilityNode get matchingNode => _matchingNodes.single;
30
30
31
31
@override
32
- bool matches (NullabilityNode node) {
32
+ void matched (NullabilityNode node) {
33
33
_matchingNodes.add (node);
34
+ }
35
+
36
+ @override
37
+ bool matches (NullabilityNode node) {
34
38
return true ;
35
39
}
36
40
}
@@ -208,12 +212,16 @@ mixin EdgeTester {
208
212
List <NullabilityEdge > getEdges (Object source, Object destination) {
209
213
var sourceMatcher = NodeMatcher (source);
210
214
var destinationMatcher = NodeMatcher (destination);
211
- return graph
212
- .getAllEdges ()
213
- .where ((e) =>
214
- sourceMatcher.matches (e.sourceNode) &&
215
- destinationMatcher.matches (e.destinationNode))
216
- .toList ();
215
+ var result = < NullabilityEdge > [];
216
+ for (var edge in graph.getAllEdges ()) {
217
+ if (sourceMatcher.matches (edge.sourceNode) &&
218
+ destinationMatcher.matches (edge.destinationNode)) {
219
+ sourceMatcher.matched (edge.sourceNode);
220
+ destinationMatcher.matched (edge.destinationNode);
221
+ result.add (edge);
222
+ }
223
+ }
224
+ return result;
217
225
}
218
226
219
227
/// Creates a [NodeMatcher] matching a substitution node whose inner and outer
@@ -365,6 +373,8 @@ abstract class NodeMatcher {
365
373
'Unclear how to match node expectation of type ${expectation .runtimeType }' );
366
374
}
367
375
376
+ void matched (NullabilityNode node);
377
+
368
378
bool matches (NullabilityNode node);
369
379
}
370
380
@@ -374,6 +384,9 @@ class _ExactNodeMatcher implements NodeMatcher {
374
384
375
385
_ExactNodeMatcher (this ._expectation);
376
386
387
+ @override
388
+ void matched (NullabilityNode node) {}
389
+
377
390
@override
378
391
bool matches (NullabilityNode node) => node == _expectation;
379
392
}
@@ -386,6 +399,18 @@ class _SubstitutionNodeMatcher implements NodeMatcher {
386
399
387
400
_SubstitutionNodeMatcher (this .inner, this .outer);
388
401
402
+ @override
403
+ void matched (NullabilityNode node) {
404
+ if (node is NullabilityNodeForSubstitution ) {
405
+ inner.matched (node.innerNode);
406
+ outer.matched (node.outerNode);
407
+ } else {
408
+ throw StateError (
409
+ 'matched should only be called on nodes for which matches returned '
410
+ 'true' );
411
+ }
412
+ }
413
+
389
414
@override
390
415
bool matches (NullabilityNode node) {
391
416
return node is NullabilityNodeForSubstitution &&
0 commit comments