Skip to content

Commit 6811463

Browse files
stereotype441Commit Queue
authored andcommitted
[messages] Fix analyzer unit test failure output.
When an analyzer unit test fails due to unexpected diagnostic errors, the failure message contains text like this: To accept the current state, expect: error(<diagnostic code>, <offset>, <length>), ... This change fixes the "diagnostic code" part of the output so that it uses the new `diag` prefix, rather than trying to refer to static constants in `DiagnosticCode`-derived classes, e.g.: To accept the current state, expect: error(diag.missingConstFinalVarOrType, 50, 1), error(diag.expectedToken, 50, 1), This paves the way for removing the `DiagnosticCode`-derived classes entirely. Change-Id: I6a6a6964176a29fa7c50bc06be5b79898da538b8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462520 Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent ef9a322 commit 6811463

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pkg/analyzer/test/generated/test_support.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,9 @@ extension on DiagnosticCode {
499499
/// to change test expectations to match the current behavior.
500500
///
501501
/// For example, if the unique name is `TestClass.MY_ERROR`, this method will
502-
/// return `TestClass.myError`.
502+
/// return `diag.myError`.
503503
String get constantName => switch (uniqueName.split('.')) {
504-
[var className, var snakeCaseName] =>
505-
'$className.${snakeCaseName.toCamelCase()}',
504+
[_, var snakeCaseName] => 'diag.${snakeCaseName.toCamelCase()}',
506505
_ => throw StateError('Malformed DiagnosticCode: $uniqueName'),
507506
};
508507
}

0 commit comments

Comments
 (0)