2b5e655c34
Changes the test logic in `analysis_server` and `analyzer_testing` so that after printing `To accept the current state, expect:`, it prints diagnostic codes in their proper camelCase format. Also removes some bogus code from `pkg/analyzer_testing/lib/analysis_rule/analysis_rule.dart` that erroneously suggested passing a `name:` parameter to the top level `error` function. This function does not accept any parameter called `name`. Previously, only tests in `pkg/analyzer/test` printed the diagnostic codes correctly. Fixes https://github.com/dart-lang/sdk/issues/62651. Change-Id: I6a6a6964b17cf798c1355e09f9a4633e1fbe388c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480041 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
19 lines
852 B
Dart
19 lines
852 B
Dart
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:analyzer/error/error.dart';
|
|
import 'package:analyzer_testing/utilities/extensions/string.dart';
|
|
|
|
extension DiagnosticCodeExtension on DiagnosticCode {
|
|
/// The name of the constant in the analyzer package (or other related
|
|
/// package) that represents this diagnostic code.
|
|
///
|
|
/// This string is used when generating test failure messages that suggest how
|
|
/// to change test expectations to match the current behavior.
|
|
///
|
|
/// For example, if the unique name is `TestClass.MY_ERROR`, this method will
|
|
/// return `diag.myError`.
|
|
String get constantName => 'diag.${lowerCaseUniqueName.toCamelCase()}';
|
|
}
|