From 622e079c88b1ccedb34c479ab7fdce1663cdc567 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Sat, 15 Nov 2025 09:04:50 -0800 Subject: [PATCH] [messages] Refactor DiagnosticClassInfo.typeCode. `DiagnosticClassInfo.typeCode` is replaced with a `code` getter on the `AnalyzerDiagnosticType` enum. This is part of a longer term effort to remove the `DiagnosticCode`-derived classes entirely. Change-Id: I6a6a69641b013d7c2ce8af3f4d54c82a9980bdb7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462320 Commit-Queue: Paul Berry Reviewed-by: Konstantin Shcheglov --- pkg/analyzer_utilities/lib/analyzer_messages.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/analyzer_utilities/lib/analyzer_messages.dart b/pkg/analyzer_utilities/lib/analyzer_messages.dart index 3882e672cc8..6dbfc272056 100644 --- a/pkg/analyzer_utilities/lib/analyzer_messages.dart +++ b/pkg/analyzer_utilities/lib/analyzer_messages.dart @@ -466,6 +466,9 @@ enum AnalyzerDiagnosticType { final DiagnosticBaseClasses baseClasses; const AnalyzerDiagnosticType({this.baseClasses = analyzerBaseClasses}); + + /// The representation of this type in analyzer source code. + String get code => 'DiagnosticType.${name.toSnakeCase().toUpperCase()}'; } /// In-memory representation of diagnostic information obtained from the @@ -599,10 +602,6 @@ class DiagnosticClassInfo { this.comment = '', }); - /// Generates the code to compute the type of diagnostics of this class. - String get typeCode => - 'DiagnosticType.${type.name.toSnakeCase().toUpperCase()}'; - static DiagnosticClassInfo byName(String name) => _diagnosticClassesByName[name] ?? (throw 'No diagnostic class named ${json.encode(name)}. Possible names: ' @@ -730,7 +729,7 @@ LocatableDiagnostic $withArgumentsName({$withArgumentsParams}) { constant.writeln('isUnresolvedIdentifier:true,'); } if (baseClasses.requiresTypeArgument) { - constant.writeln('type: ${diagnosticClassInfo.typeCode},'); + constant.writeln('type: ${diagnosticClassInfo.type.code},'); } String uniqueName = analyzerCode.toString().replaceFirst( 'LinterLintCode.',