From 47e77939fce74ffda0b7252f33ba1ced2ea09c52 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Sat, 15 Nov 2025 19:09:04 -0800 Subject: [PATCH] [messages] Get rid of deprecatedSnakeCaseNames. The only remaining deprecated snake-case name was `ParserErrorCode.UNEXPECTED_TOKEN`, which is no longer being used by `package:dart_style`. Note that the commit that removed `package:dart_style`'s use of `ParserErrorCode.UNEXPECTED_TOKEN` (https://github.com/dart-lang/dart_style/commit/ade6076f731c39306e3dd32608dfd00622e4492f) was also the commit that bumped `package:dart_style`'s pubspec dependency to permit analyzer versions >= `9.0.0`. Since the current version of `package:analyzer` is `9.0.1-dev`, this means that `pub get` will never pair a future version of `dart:analyzer` with a version of `package:dart_style` that uses `ParserErrorCode.UNEXPECTED_TOKEN`, so this removal is safe. Change-Id: I6a6a6964a6e1dde6d8c1f1420b39f998b8a4073a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462322 Commit-Queue: Paul Berry Reviewed-by: Konstantin Shcheglov --- .../src/dart/error/syntactic_errors.g.dart | 3 --- .../lib/src/diagnostic/diagnostic.g.dart | 3 --- .../lib/analyzer_messages.dart | 26 ------------------- 3 files changed, 32 deletions(-) diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart index 6e47f4174aa..d2275de2a1d 100644 --- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart +++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart @@ -1116,9 +1116,6 @@ class ParserErrorCode { static const DiagnosticWithoutArguments typeParameterOnOperator = diag.typeParameterOnOperator; - @Deprecated("Please use unexpectedToken") - static const DiagnosticCode UNEXPECTED_TOKEN = unexpectedToken; - /// Parameters: /// Object p0: the starting character that was missing static const DiagnosticWithArguments< diff --git a/pkg/analyzer/lib/src/diagnostic/diagnostic.g.dart b/pkg/analyzer/lib/src/diagnostic/diagnostic.g.dart index 7401e2264dc..104bb8ef9e9 100644 --- a/pkg/analyzer/lib/src/diagnostic/diagnostic.g.dart +++ b/pkg/analyzer/lib/src/diagnostic/diagnostic.g.dart @@ -16094,9 +16094,6 @@ undone = DiagnosticWithArguments( expectedTypes: [ExpectedType.string], ); -@Deprecated("Please use unexpectedToken") -const DiagnosticCode UNEXPECTED_TOKEN = unexpectedToken; - /// No parameters. const DiagnosticWithoutArguments unexpectedDollarInString = DiagnosticWithoutArgumentsImpl( diff --git a/pkg/analyzer_utilities/lib/analyzer_messages.dart b/pkg/analyzer_utilities/lib/analyzer_messages.dart index 6dbfc272056..7856f34b4a1 100644 --- a/pkg/analyzer_utilities/lib/analyzer_messages.dart +++ b/pkg/analyzer_utilities/lib/analyzer_messages.dart @@ -81,9 +81,6 @@ const List diagnosticClasses = [ file: syntacticErrorsFile, name: 'ParserErrorCode', type: AnalyzerDiagnosticType.syntacticError, - deprecatedSnakeCaseNames: { - 'UNEXPECTED_TOKEN', // Referenced by `package:dart_style`. - }, ), DiagnosticClassInfo( file: manifestWarningCodeFile, @@ -584,11 +581,6 @@ class DiagnosticClassInfo { /// The type of diagnostics in this class. final AnalyzerDiagnosticType type; - /// The names of any diagnostics which are relied upon by analyzer clients, - /// and therefore will need their "snake case" form preserved (with a - /// deprecation notice) after migration to camel case diagnostic codes. - final Set deprecatedSnakeCaseNames; - /// Documentation comment to generate for the diagnostic class. /// /// If no documentation comment is needed, this should be the empty string. @@ -598,7 +590,6 @@ class DiagnosticClassInfo { required this.file, required this.name, required this.type, - this.deprecatedSnakeCaseNames = const {}, this.comment = '', }); @@ -742,14 +733,6 @@ LocatableDiagnostic $withArgumentsName({$withArgumentsParams}) { constant.writeln('expectedTypes: ${_computeExpectedTypes()},'); constant.writeln(');'); memberAccumulator.constants[constantName] = constant.toString(); - - if (diagnosticClassInfo.deprecatedSnakeCaseNames.contains(diagnosticCode)) { - memberAccumulator.constants[diagnosticCode] = - ''' -@Deprecated("Please use $constantName") -const DiagnosticCode $diagnosticCode = $constantName; -'''; - } } /// Generates doc comments for this error code. @@ -799,21 +782,12 @@ const DiagnosticCode $diagnosticCode = $constantName; /// diagnostic, imported from `diagnostic.g.dart` using the import prefix /// `diag`. void toAnalyzerRedirectCode({required MemberAccumulator memberAccumulator}) { - var diagnosticCode = analyzerCode.snakeCaseName; var ConstantStyle(:staticType) = constantStyle; var constant = StringBuffer(); outputConstantHeader(constant); constant.writeln(' static const $staticType $constantName ='); constant.writeln(' diag.$constantName;'); memberAccumulator.constants[constantName] = constant.toString(); - - if (diagnosticClassInfo.deprecatedSnakeCaseNames.contains(diagnosticCode)) { - memberAccumulator.constants[diagnosticCode] = - ''' - @Deprecated("Please use $constantName") - static const DiagnosticCode $diagnosticCode = $constantName; -'''; - } } /// Generates the appropriate declaration for this diagnostic to include in