Add which() for multi checks.

Change-Id: I07dff9db3c7870b8799477d949b23a45ba689130
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223920
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer_utilities/lib/check/check_target.dart b/pkg/analyzer_utilities/lib/check/check_target.dart
index 1d0e608..d22a1ac 100644
--- a/pkg/analyzer_utilities/lib/check/check_target.dart
+++ b/pkg/analyzer_utilities/lib/check/check_target.dart
@@ -16,13 +16,6 @@
 
   String get _indent => '  ' * (_depth + 1);
 
-  String valueStr(value) {
-    if (value is String) {
-      return "'$value'";
-    }
-    return '$value';
-  }
-
   Never fail(String message) {
     test_package.fail(_describe() + '\n' + _indent + message);
   }
@@ -37,4 +30,16 @@
       return _describe() + '\n' + _indent + describe(value);
     });
   }
+
+  String valueStr(value) {
+    if (value is String) {
+      return "'$value'";
+    }
+    return '$value';
+  }
+
+  /// Use this if multiple checks are required on the value.
+  void which(void Function(CheckTarget<T> e) checker) {
+    checker(this);
+  }
 }
diff --git a/pkg/analyzer_utilities/test/check/check_test.dart b/pkg/analyzer_utilities/test/check/check_test.dart
index 3b929ec..907438f 100644
--- a/pkg/analyzer_utilities/test/check/check_test.dart
+++ b/pkg/analyzer_utilities/test/check/check_test.dart
@@ -165,6 +165,10 @@
         _fails(() => check('abc' as dynamic).isA<int>());
       });
     });
+    test('which', () {
+      check(0).which((e) => e.isZero);
+      _fails(() => check(1).which((e) => e.isZero));
+    });
   });
 }