Add diagnostic location info to more tests

Change-Id: Id5d0e617a55abc2e1ed3d0bac7ae56544aa348e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103543
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart b/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart
index 4a01b55..f92a108 100644
--- a/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart
@@ -16,12 +16,14 @@
 @reflectiveTest
 class CheckedModeCompileTimeErrorCodeTest extends DriverResolutionTest {
   test_assertion_throws() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(int x, int y) : assert(x < y);
 }
 var v = const A(3, 2);
-''', [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
+''', [
+      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 61, 13),
+    ]);
   }
 
   test_fieldFormalParameterAssignableToField_extends() async {
@@ -46,13 +48,15 @@
   test_fieldFormalParameterAssignableToField_fieldType_unresolved_null() async {
     // Null always passes runtime type checks, even when the type is
     // unresolved.
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   final Unresolved x;
   const A(String this.x);
 }
 var v = const A(null);
-''', [StaticWarningCode.UNDEFINED_CLASS]);
+''', [
+      error(StaticWarningCode.UNDEFINED_CLASS, 18, 10),
+    ]);
   }
 
   test_fieldFormalParameterAssignableToField_implements() async {
@@ -151,7 +155,7 @@
   test_fieldFormalParameterAssignableToField_typedef() async {
     // foo has the runtime type dynamic -> dynamic, so it is not assignable
     // to A.f.
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 typedef String Int2String(int x);
 class A {
   final Int2String f;
@@ -159,7 +163,9 @@
 }
 foo(x) => 1;
 var v = const A(foo);
-''', [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
+''', [
+      error(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 116, 3),
+    ]);
   }
 
   test_fieldFormalParameterAssignableToField_typeSubstitution() async {
@@ -175,15 +181,18 @@
   }
 
   test_fieldFormalParameterNotAssignableToField() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   final int x;
   const A(this.x);
 }
 var v = const A('foo');
 ''', [
-      CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
-      StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          62,
+          5),
+      error(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 62, 5),
     ]);
   }
 
@@ -191,7 +200,7 @@
     // According to checked-mode type checking rules, a value of type A is not
     // assignable to a field of type B, because B extends A (the subtyping
     // relationship is in the wrong direction).
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A();
 }
@@ -204,37 +213,47 @@
 }
 const A u = const A();
 var v = const C(u);
-''', [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
+''', [
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          143,
+          1),
+    ]);
   }
 
   test_fieldFormalParameterNotAssignableToField_fieldType() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   final int x;
   const A(this.x);
 }
 var v = const A('foo');
 ''', [
-      CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
-      StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          62,
+          5),
+      error(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 62, 5),
     ]);
   }
 
   test_fieldFormalParameterNotAssignableToField_fieldType_unresolved() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   final Unresolved x;
   const A(String this.x);
 }
 var v = const A('foo');
-''', [StaticWarningCode.UNDEFINED_CLASS]);
+''', [
+      error(StaticWarningCode.UNDEFINED_CLASS, 18, 10),
+    ]);
   }
 
   test_fieldFormalParameterNotAssignableToField_implements() async {
     // According to checked-mode type checking rules, a value of type A is not
     // assignable to a field of type B, because B implements A (the subtyping
     // relationship is in the wrong direction).
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A();
 }
@@ -245,61 +264,84 @@
 }
 const A u = const A();
 var v = const C(u);
-''', [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
+''', [
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          132,
+          1),
+    ]);
   }
 
   test_fieldFormalParameterNotAssignableToField_list() async {
     // <num>[1, 2, 3] has type List<num>, which is not a subtype of List<int>.
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(List<int> x);
 }
 const dynamic w = const <num>[1, 2, 3];
 var x = const A(w);
-''', [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
+''', [
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          92,
+          1),
+    ]);
   }
 
   test_fieldFormalParameterNotAssignableToField_map_keyMismatch() async {
     // <num, int>{1: 2} has type Map<num, int>, which is not a subtype of
     // Map<int, int>.
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(Map<int, int> x);
 }
 const dynamic w = const <num, int>{1: 2};
 var x = const A(w);
-''', [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
+''', [
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          98,
+          1),
+    ]);
   }
 
   test_fieldFormalParameterNotAssignableToField_map_valueMismatch() async {
     // <int, num>{1: 2} has type Map<int, num>, which is not a subtype of
     // Map<int, int>.
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(Map<int, int> x);
 }
 const dynamic w = const <int, num>{1: 2};
 var x = const A(w);
-''', [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
+''', [
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          98,
+          1),
+    ]);
   }
 
   test_fieldFormalParameterNotAssignableToField_optional() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   final int x;
   const A([this.x = 'foo']);
 }
 var v = const A();
 ''', [
-      CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
-      StaticTypeWarningCode.INVALID_ASSIGNMENT
+      error(StaticTypeWarningCode.INVALID_ASSIGNMENT, 45, 5),
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          64,
+          9),
     ]);
   }
 
   test_fieldFormalParameterNotAssignableToField_typedef() async {
     // foo has the runtime type String -> int, so it should not be assignable
     // to A.f (A.f requires it to be int -> String).
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 typedef String Int2String(int x);
 class A {
   final Int2String f;
@@ -308,35 +350,47 @@
 int foo(String x) => 1;
 var v = const A(foo);
 ''', [
-      CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
-      StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
+      error(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 127, 3),
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          127,
+          3),
     ]);
   }
 
   test_fieldInitializerNotAssignable() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   final int x;
   const A() : x = '';
 }
 ''', [
-      CheckedModeCompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE,
-      StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE
+      error(StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE, 43, 2),
+      error(
+          CheckedModeCompileTimeErrorCode
+              .CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE,
+          43,
+          2),
     ]);
   }
 
   test_fieldTypeMismatch() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(x) : y = x;
   final int y;
 }
 var v = const A('foo');
-''', [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH]);
+''', [
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
+          57,
+          14),
+    ]);
   }
 
   test_fieldTypeMismatch_generic() async {
-    await assertErrorCodesInCode(
+    await assertErrorsInCode(
       r'''
 class C<T> {
   final T x = y;
@@ -346,24 +400,30 @@
 var v = const C<String>();
 ''',
       [
-        CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
-        StaticTypeWarningCode.INVALID_ASSIGNMENT
+        error(StaticTypeWarningCode.INVALID_ASSIGNMENT, 27, 1),
+        error(
+            CheckedModeCompileTimeErrorCode
+                .CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
+            70,
+            17),
       ],
     );
   }
 
   test_fieldTypeMismatch_unresolved() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(x) : y = x;
   final Unresolved y;
 }
 var v = const A('foo');
-''', [StaticWarningCode.UNDEFINED_CLASS]);
+''', [
+      error(StaticWarningCode.UNDEFINED_CLASS, 40, 10),
+    ]);
   }
 
   test_fieldTypeOk_generic() async {
-    await assertErrorCodesInCode(
+    await assertErrorsInCode(
       r'''
 class C<T> {
   final T x = y;
@@ -372,7 +432,9 @@
 const int y = 1;
 var v = const C<int>();
 ''',
-      [StaticTypeWarningCode.INVALID_ASSIGNMENT],
+      [
+        error(StaticTypeWarningCode.INVALID_ASSIGNMENT, 27, 1),
+      ],
     );
   }
 
@@ -389,40 +451,50 @@
   test_fieldTypeOk_unresolved_null() async {
     // Null always passes runtime type checks, even when the type is
     // unresolved.
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(x) : y = x;
   final Unresolved y;
 }
 var v = const A(null);
-''', [StaticWarningCode.UNDEFINED_CLASS]);
+''', [
+      error(StaticWarningCode.UNDEFINED_CLASS, 40, 10),
+    ]);
   }
 
   test_listElementTypeNotAssignable() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 var v = const <String> [42];
-''', [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
+''', [
+      error(StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE, 24, 2),
+    ]);
   }
 
   test_listLiteral_inferredElementType() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 const Object x = [1];
 const List<String> y = x;
-''', [CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH]);
+''', [
+      error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 41, 1),
+    ]);
   }
 
   test_mapLiteral_inferredKeyType() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 const Object x = {1: 1};
 const Map<String, dynamic> y = x;
-''', [CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH]);
+''', [
+      error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 52, 1),
+    ]);
   }
 
   test_mapLiteral_inferredValueType() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 const Object x = {1: 1};
 const Map<dynamic, String> y = x;
-''', [CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH]);
+''', [
+      error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 52, 1),
+    ]);
   }
 
   test_parameterAssignable_null() async {
@@ -445,59 +517,71 @@
   test_parameterAssignable_undefined_null() async {
     // Null always passes runtime type checks, even when the type is
     // unresolved.
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(Unresolved x);
 }
 var v = const A(null);
-''', [StaticWarningCode.UNDEFINED_CLASS]);
+''', [
+      error(StaticWarningCode.UNDEFINED_CLASS, 20, 10),
+    ]);
   }
 
   test_parameterNotAssignable() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(int x);
 }
 var v = const A('foo');
 ''', [
-      CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
-      StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          46,
+          5),
+      error(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 46, 5),
     ]);
   }
 
   test_parameterNotAssignable_typeSubstitution() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A<T> {
   const A(T x);
 }
 var v = const A<int>('foo');
 ''', [
-      CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
-      StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
+      error(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 52, 5),
+      error(
+          CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
+          52,
+          5),
     ]);
   }
 
   test_parameterNotAssignable_undefined() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A(Unresolved x);
 }
 var v = const A('foo');
-''', [StaticWarningCode.UNDEFINED_CLASS]);
+''', [
+      error(StaticWarningCode.UNDEFINED_CLASS, 20, 10),
+    ]);
   }
 
   test_redirectingConstructor_paramTypeMismatch() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A {
   const A.a1(x) : this.a2(x);
   const A.a2(String x);
 }
 var v = const A.a1(0);
-''', [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
+''', [
+      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 74, 13),
+    ]);
   }
 
   test_superConstructor_paramTypeMismatch() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class C {
   final double d;
   const C(this.d);
@@ -506,7 +590,9 @@
   const D(d) : super(d);
 }
 const f = const D('0.0');
-''', [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
+''', [
+      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 106, 14),
+    ]);
   }
 
   test_topLevelVarAssignable_null() async {
@@ -518,23 +604,27 @@
   test_topLevelVarAssignable_undefined_null() async {
     // Null always passes runtime type checks, even when the type is
     // unresolved.
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 const Unresolved x = null;
-''', [StaticWarningCode.UNDEFINED_CLASS]);
+''', [
+      error(StaticWarningCode.UNDEFINED_CLASS, 6, 10),
+    ]);
   }
 
   test_topLevelVarNotAssignable() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 const int x = 'foo';
 ''', [
-      CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
-      StaticTypeWarningCode.INVALID_ASSIGNMENT
+      error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 10, 1),
+      error(StaticTypeWarningCode.INVALID_ASSIGNMENT, 14, 5),
     ]);
   }
 
   test_topLevelVarNotAssignable_undefined() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 const Unresolved x = 'foo';
-''', [StaticWarningCode.UNDEFINED_CLASS]);
+''', [
+      error(StaticWarningCode.UNDEFINED_CLASS, 6, 10),
+    ]);
   }
 }
diff --git a/pkg/analyzer/test/generated/compile_time_error_code_test.dart b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
index 57e5769..7346b25 100644
--- a/pkg/analyzer/test/generated/compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
@@ -79,21 +79,21 @@
 class CompileTimeErrorCodeTest_WithUIAsCode extends DriverResolutionTest {
   test_defaultValueInFunctionTypeAlias_new_named() async {
     // This test used to fail with UI as code enabled. Test the fix here.
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 typedef F = int Function({Map<String, String> m: const {}});
 ''', [
-      ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE,
+      error(ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE, 47, 1),
     ]);
   }
 
   test_defaultValueInFunctionTypeAlias_new_named_ambiguous() async {
     // Test that the strong checker does not crash when given an ambiguous
     // set or map literal.
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 typedef F = int Function({Object m: const {1, 2: 3}});
 ''', [
-      ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE,
-      CompileTimeErrorCode.AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH,
+      error(ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE, 34, 1),
+      error(CompileTimeErrorCode.AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH, 36, 15),
     ]);
   }
 }
@@ -101,236 +101,298 @@
 @reflectiveTest
 class ControlFlowCollectionsTest extends DriverResolutionTest {
   test_awaitForIn_declaredVariableWrongType() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 import 'dart:async';
 f() async {
   Stream<String> stream;
   await for (int i in stream) {}
 }
-''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 75, 1),
+      error(StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE, 80, 6),
+    ]);
   }
 
   test_awaitForIn_existingVariableWrongType() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 import 'dart:async';
 f() async {
   Stream<String> stream;
   int i;
   await for (i in stream) {}
 }
-''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 64, 1),
+      error(StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE, 85, 6),
+    ]);
   }
 
   test_awaitForIn_notStream() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 f() async {
   await for (var i in true) {}
 }
-''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 29, 1),
+      error(StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE, 34, 4),
+    ]);
   }
 
   test_duplicateDefinition_for_initializers() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 f() {
   for (int i = 0, i = 0; i < 5;) {}
 }
-''', [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
+''', [
+      error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 24, 1),
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 24, 1),
+    ]);
   }
 
   test_expectedOneListTypeArgument() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 main() {
   <int, int>[];
-}''', [StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS]);
+}''', [
+      error(StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS, 11, 10),
+    ]);
   }
 
   test_expectedOneSetTypeArgument() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 main() {
   <int, int, int>{2, 3};
-}''', [StaticTypeWarningCode.EXPECTED_ONE_SET_TYPE_ARGUMENTS]);
+}''', [
+      error(StaticTypeWarningCode.EXPECTED_ONE_SET_TYPE_ARGUMENTS, 11, 15),
+    ]);
   }
 
   test_expectedTwoMapTypeArguments_three_ambiguous() async {
     // TODO(brianwilkerson) We probably need a new error code for "expected
     //  either one or two type arguments" to handle the ambiguous case.
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 main() {
   <int, int, int>{};
-}''', [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]);
+}''', [
+      error(StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS, 11, 15),
+    ]);
   }
 
   test_expectedTwoMapTypeArguments_three_map() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 main() {
   <int, int, int>{1:2};
-}''', [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]);
+}''', [
+      error(StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS, 11, 15),
+    ]);
   }
 
   test_forIn_declaredVariableWrongType() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 f() {
   for (int i in <String>[]) {}
 }
-''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 17, 1),
+      error(StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE, 22, 10),
+    ]);
   }
 
   test_forIn_existingVariableWrongType() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 f() {
   int i;
   for (i in <String>[]) {}
 }
-''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 12, 1),
+      error(StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE, 27, 10),
+    ]);
   }
 
   test_forIn_notIterable() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 f() {
   for (var i in true) {}
 }
-''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 17, 1),
+      error(StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE, 22, 4),
+    ]);
   }
 
   test_forIn_typeBoundBad() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 class Foo<T extends Iterable<int>> {
   void method(T iterable) {
     for (String i in iterable) {}
   }
 }
-''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 81, 1),
+      error(StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE, 86, 8),
+    ]);
   }
 
   test_forInWithConstVariable_forEach_identifier() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 f() {
   const x = 0;
   for (x in [0, 1, 2]) {}
 }
-''', [CompileTimeErrorCode.FOR_IN_WITH_CONST_VARIABLE]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 14, 1),
+      error(CompileTimeErrorCode.FOR_IN_WITH_CONST_VARIABLE, 28, 1),
+    ]);
   }
 
   test_forInWithConstVariable_forEach_loopVariable() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 f() {
   for (const x in [0, 1, 2]) {}
 }
-''', [CompileTimeErrorCode.FOR_IN_WITH_CONST_VARIABLE]);
+''', [
+      error(CompileTimeErrorCode.FOR_IN_WITH_CONST_VARIABLE, 13, 7),
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 19, 1),
+    ]);
   }
 
   test_generalizedVoid_useOfInForeachIterableError() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 void main() {
   void x;
   for (var v in x) {}
 }
-''', [StaticWarningCode.USE_OF_VOID_RESULT]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 35, 1),
+      error(StaticWarningCode.USE_OF_VOID_RESULT, 40, 1),
+    ]);
   }
 
   test_generalizedVoid_useOfVoidInForeachVariableError() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 void main() {
   void x;
   var y;
   for (y in x) {}
 }
-''', [StaticWarningCode.USE_OF_VOID_RESULT]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 30, 1),
+      error(StaticWarningCode.USE_OF_VOID_RESULT, 45, 1),
+    ]);
   }
 
   test_invalidTypeArgumentInConstList() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A<E> {
   m() {
     return const <E>[];
   }
 }
-''', [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST]);
+''', [
+      error(CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST, 39, 1),
+    ]);
   }
 
   test_invalidTypeArgumentInConstMap_key() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A<E> {
   m() {
     return const <E, String>{};
   }
 }
-''', [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]);
+''', [
+      error(CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP, 39, 1),
+    ]);
   }
 
   test_invalidTypeArgumentInConstMap_value() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A<E> {
   m() {
     return const <String, E>{};
   }
 }
-''', [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]);
+''', [
+      error(CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP, 47, 1),
+    ]);
   }
 
   test_invalidTypeArgumentInConstSet_class() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A<E> {
   m() {
     return const <E>{};
   }
 }
-''', [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_SET]);
+''', [
+      error(CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_SET, 39, 1),
+    ]);
   }
 
   test_listElementTypeNotAssignable_const() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 var v = const <String>[42];
-''', [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
+''', [
+      error(StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE, 23, 2),
+    ]);
   }
 
   test_mapValueTypeNotAssignable_const() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 var v = const <String, String>{'a' : 2};
-''', [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
+''', [
+      error(StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE, 37, 1),
+    ]);
   }
 
   test_nonBoolCondition_for_declaration() async {
     // https://github.com/dart-lang/sdk/issues/24713
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 f() {
   for (int i = 0; 3;) {}
 }
-''', [StaticTypeWarningCode.NON_BOOL_CONDITION]);
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 17, 1),
+      error(StaticTypeWarningCode.NON_BOOL_CONDITION, 24, 1),
+    ]);
   }
 
   test_nonBoolCondition_for_expression() async {
     // https://github.com/dart-lang/sdk/issues/24713
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 f() {
   int i;
   for (i = 0; 3;) {}
-}''', [StaticTypeWarningCode.NON_BOOL_CONDITION]);
+}''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 12, 1),
+      error(StaticTypeWarningCode.NON_BOOL_CONDITION, 29, 1),
+    ]);
   }
 
   test_nonConstMapAsExpressionStatement_begin() async {
     // TODO(danrubel) Fasta is not recovering well.
     // Ideally we would produce a single diagnostic:
     // CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 f() {
   {'a' : 0, 'b' : 1}.length;
 }
 ''', [
-      ParserErrorCode.UNEXPECTED_TOKEN,
-      ParserErrorCode.UNEXPECTED_TOKEN,
-      ParserErrorCode.UNEXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.MISSING_IDENTIFIER,
-      ParserErrorCode.MISSING_IDENTIFIER,
-      ParserErrorCode.MISSING_IDENTIFIER,
-      ParserErrorCode.MISSING_IDENTIFIER
+      error(ParserErrorCode.EXPECTED_TOKEN, 9, 3),
+      error(ParserErrorCode.EXPECTED_TOKEN, 13, 1),
+      error(ParserErrorCode.MISSING_IDENTIFIER, 13, 1),
+      error(ParserErrorCode.UNEXPECTED_TOKEN, 13, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 15, 1),
+      error(ParserErrorCode.UNEXPECTED_TOKEN, 16, 1),
+      error(ParserErrorCode.MISSING_IDENTIFIER, 16, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 16, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 18, 3),
+      error(ParserErrorCode.UNEXPECTED_TOKEN, 22, 1),
+      error(ParserErrorCode.MISSING_IDENTIFIER, 22, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 22, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 24, 1),
+      error(ParserErrorCode.MISSING_IDENTIFIER, 26, 1),
     ]);
   }
 
@@ -338,43 +400,47 @@
     // TODO(danrubel) Fasta is not recovering well.
     // Ideally we would produce a single diagnostic:
     // CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 f() {
   {'a' : 0, 'b' : 1};
 }
 ''', [
-      ParserErrorCode.UNEXPECTED_TOKEN,
-      ParserErrorCode.UNEXPECTED_TOKEN,
-      ParserErrorCode.UNEXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.EXPECTED_TOKEN,
-      ParserErrorCode.MISSING_IDENTIFIER,
-      ParserErrorCode.MISSING_IDENTIFIER,
-      ParserErrorCode.MISSING_IDENTIFIER
+      error(ParserErrorCode.EXPECTED_TOKEN, 9, 3),
+      error(ParserErrorCode.EXPECTED_TOKEN, 13, 1),
+      error(ParserErrorCode.MISSING_IDENTIFIER, 13, 1),
+      error(ParserErrorCode.UNEXPECTED_TOKEN, 13, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 15, 1),
+      error(ParserErrorCode.UNEXPECTED_TOKEN, 16, 1),
+      error(ParserErrorCode.MISSING_IDENTIFIER, 16, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 16, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 18, 3),
+      error(ParserErrorCode.UNEXPECTED_TOKEN, 22, 1),
+      error(ParserErrorCode.MISSING_IDENTIFIER, 22, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 22, 1),
+      error(ParserErrorCode.EXPECTED_TOKEN, 24, 1),
     ]);
   }
 
   test_setElementTypeNotAssignable_const() async {
-    await assertErrorCodesInCode('''
+    await assertErrorsInCode('''
 var v = const <String>{42};
-''', [StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE]);
+''', [
+      error(StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE, 23, 2),
+    ]);
   }
 }
 
 @reflectiveTest
 class InvalidTypeArgumentInConstSetTest extends DriverResolutionTest {
   test_class() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorsInCode(r'''
 class A<E> {
   m() {
     return const <E>{};
   }
 }
-''', [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_SET]);
+''', [
+      error(CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_SET, 39, 1),
+    ]);
   }
 }
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index 7fa83ed..9cc2c26 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -170,7 +170,7 @@
 @reflectiveTest
 class ErrorResolverTest extends DriverResolutionTest {
   test_breakLabelOnSwitchMember() async {
-    assertErrorCodesInCode(r'''
+    assertErrorsInCode(r'''
 class A {
   void m(int i) {
     switch (i) {
@@ -180,11 +180,13 @@
         break l;
     }
   }
-}''', [ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]);
+}''', [
+      error(ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER, 105, 1),
+    ]);
   }
 
   test_continueLabelOnSwitch() async {
-    assertErrorCodesInCode(r'''
+    assertErrorsInCode(r'''
 class A {
   void m(int i) {
     l: switch (i) {
@@ -192,7 +194,9 @@
         continue l;
     }
   }
-}''', [ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]);
+}''', [
+      error(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, 79, 1),
+    ]);
   }
 
   test_enclosingElement_invalidLocalFunction() async {