[analyzer] Sort generated diagnostic message files.

Previously, the generated files containing definitions of diagnostic
messages were not sorted. This didn't cause a failure in
`verify_sorted_test.dart` because the definitions of diagnostic
messages were all static constant fields, and member sorting ignores
fields.

However, a follow-up CL will be introducing static methods to
implement the new `.withArguments()` functionality for error codes
that take arguments, and these will need to be sorted. So to prepare
for that, this CL modifies the code generator so that its output is
already sorted.

Change-Id: I6a6a6964c476d8a7b5841860998c50b01e592942
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446120
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart b/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
index aeb968d..cdb0d8e 100644
--- a/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
+++ b/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
@@ -253,18 +253,6 @@
         "'{0}' isn't a recognized error code.",
       );
 
-  /// An error code indicating that a plugin is being configured with an
-  /// unsupported option and legal options are provided.
-  ///
-  /// Parameters:
-  /// String p0: the plugin name
-  /// String p1: the unsupported option key
-  static const AnalysisOptionsWarningCode unsupportedOptionWithoutValues =
-      AnalysisOptionsWarningCode(
-        'UNSUPPORTED_OPTION_WITHOUT_VALUES',
-        "The option '{1}' isn't supported by '{0}'.",
-      );
-
   /// An error code indicating that a YAML section is being configured with an
   /// unsupported option where there is just one legal value.
   ///
@@ -293,6 +281,18 @@
         correctionMessage: "Try using one of the supported options: {2}.",
       );
 
+  /// An error code indicating that a plugin is being configured with an
+  /// unsupported option and legal options are provided.
+  ///
+  /// Parameters:
+  /// String p0: the plugin name
+  /// String p1: the unsupported option key
+  static const AnalysisOptionsWarningCode unsupportedOptionWithoutValues =
+      AnalysisOptionsWarningCode(
+        'UNSUPPORTED_OPTION_WITHOUT_VALUES',
+        "The option '{1}' isn't supported by '{0}'.",
+      );
+
   /// An error code indicating that an option entry is being configured with an
   /// unsupported value.
   ///
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 b5439af..767f0a0 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
@@ -339,20 +339,6 @@
     correctionMessage: "Try removing one of the keywords.",
   );
 
-  static const ParserErrorCode constructorWithReturnType = ParserErrorCode(
-    'CONSTRUCTOR_WITH_RETURN_TYPE',
-    "Constructors can't have a return type.",
-    correctionMessage: "Try removing the return type.",
-  );
-
-  static const ParserErrorCode constructorWithTypeArguments = ParserErrorCode(
-    'CONSTRUCTOR_WITH_TYPE_ARGUMENTS',
-    "A constructor invocation can't have type arguments after the constructor "
-        "name.",
-    correctionMessage:
-        "Try removing the type arguments or placing them after the class name.",
-  );
-
   static const ParserErrorCode constAndFinal = ParserErrorCode(
     'CONST_AND_FINAL',
     "Members can't be declared to be both 'const' and 'final'.",
@@ -389,6 +375,20 @@
     correctionMessage: "Try removing the 'const' keyword.",
   );
 
+  static const ParserErrorCode constructorWithReturnType = ParserErrorCode(
+    'CONSTRUCTOR_WITH_RETURN_TYPE',
+    "Constructors can't have a return type.",
+    correctionMessage: "Try removing the return type.",
+  );
+
+  static const ParserErrorCode constructorWithTypeArguments = ParserErrorCode(
+    'CONSTRUCTOR_WITH_TYPE_ARGUMENTS',
+    "A constructor invocation can't have type arguments after the constructor "
+        "name.",
+    correctionMessage:
+        "Try removing the type arguments or placing them after the class name.",
+  );
+
   static const ParserErrorCode continueOutsideOfLoop = ParserErrorCode(
     'CONTINUE_OUTSIDE_OF_LOOP',
     "A continue statement can't be used outside of a loop or switch statement.",
@@ -451,6 +451,12 @@
     correctionMessage: "Try moving the directive before any declarations.",
   );
 
+  static const ParserErrorCode duplicateDeferred = ParserErrorCode(
+    'DUPLICATE_DEFERRED',
+    "An import directive can only have one 'deferred' keyword.",
+    correctionMessage: "Try removing all but one 'deferred' keyword.",
+  );
+
   /// Parameters:
   /// 0: the modifier that was duplicated
   static const ParserErrorCode duplicatedModifier = ParserErrorCode(
@@ -459,12 +465,6 @@
     correctionMessage: "Try removing all but one occurrence of the modifier.",
   );
 
-  static const ParserErrorCode duplicateDeferred = ParserErrorCode(
-    'DUPLICATE_DEFERRED',
-    "An import directive can only have one 'deferred' keyword.",
-    correctionMessage: "Try removing all but one 'deferred' keyword.",
-  );
-
   /// Parameters:
   /// 0: the label that was duplicated
   static const ParserErrorCode duplicateLabelInSwitchStatement =
@@ -703,6 +703,9 @@
     "Expected a type name.",
   );
 
+  @Deprecated("Please use experimentNotEnabled")
+  static const ParserErrorCode EXPERIMENT_NOT_ENABLED = experimentNotEnabled;
+
   static const ParserErrorCode experimentNotEnabled = ParserErrorCode(
     'EXPERIMENT_NOT_ENABLED',
     "This requires the '{0}' language feature to be enabled.",
@@ -711,9 +714,6 @@
         "{1} or higher, and running 'pub get'.",
   );
 
-  @Deprecated("Please use experimentNotEnabled")
-  static const ParserErrorCode EXPERIMENT_NOT_ENABLED = experimentNotEnabled;
-
   static const ParserErrorCode experimentNotEnabledOffByDefault =
       ParserErrorCode(
         'EXPERIMENT_NOT_ENABLED_OFF_BY_DEFAULT',
@@ -883,13 +883,6 @@
   );
 
   /// No parameters.
-  static const ParserErrorCode factoryWithoutBody = ParserErrorCode(
-    'FACTORY_WITHOUT_BODY',
-    "A non-redirecting 'factory' constructor must have a body.",
-    correctionMessage: "Try adding a body to the constructor.",
-  );
-
-  /// No parameters.
   static const ParserErrorCode factoryWithInitializers = ParserErrorCode(
     'FACTORY_WITH_INITIALIZERS',
     "A 'factory' constructor can't have initializers.",
@@ -898,6 +891,13 @@
         "constructor, or removing the initializers.",
   );
 
+  /// No parameters.
+  static const ParserErrorCode factoryWithoutBody = ParserErrorCode(
+    'FACTORY_WITHOUT_BODY',
+    "A non-redirecting 'factory' constructor must have a body.",
+    correctionMessage: "Try adding a body to the constructor.",
+  );
+
   static const ParserErrorCode
   fieldInitializedOutsideDeclaringClass = ParserErrorCode(
     'FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS',
@@ -1935,12 +1935,6 @@
         "be a function.",
   );
 
-  static const ParserErrorCode typedefInClass = ParserErrorCode(
-    'TYPEDEF_IN_CLASS',
-    "Typedefs can't be declared inside classes.",
-    correctionMessage: "Try moving the typedef to the top-level.",
-  );
-
   static const ParserErrorCode typeArgumentsOnTypeVariable = ParserErrorCode(
     'TYPE_ARGUMENTS_ON_TYPE_VARIABLE',
     "Can't use type arguments with type variable '{0}'.",
@@ -1953,6 +1947,12 @@
     correctionMessage: "Try removing the type appearing before 'factory'.",
   );
 
+  static const ParserErrorCode typedefInClass = ParserErrorCode(
+    'TYPEDEF_IN_CLASS',
+    "Typedefs can't be declared inside classes.",
+    correctionMessage: "Try moving the typedef to the top-level.",
+  );
+
   static const ParserErrorCode typeParameterOnConstructor = ParserErrorCode(
     'TYPE_PARAMETER_ON_CONSTRUCTOR',
     "Constructors can't have type parameters.",
@@ -1967,6 +1967,9 @@
     correctionMessage: "Try removing the type parameters.",
   );
 
+  @Deprecated("Please use unexpectedToken")
+  static const ParserErrorCode UNEXPECTED_TOKEN = unexpectedToken;
+
   /// Parameters:
   /// Object p0: the starting character that was missing
   static const ParserErrorCode unexpectedTerminatorForParameterGroup =
@@ -1985,24 +1988,11 @@
     correctionMessage: "Try removing the text.",
   );
 
-  @Deprecated("Please use unexpectedToken")
-  static const ParserErrorCode UNEXPECTED_TOKEN = unexpectedToken;
-
   static const ParserErrorCode unexpectedTokens = ParserErrorCode(
     'UNEXPECTED_TOKENS',
     "Unexpected tokens.",
   );
 
-  /// No parameters.
-  static const ParserErrorCode
-  variablePatternKeywordInDeclarationContext = ParserErrorCode(
-    'VARIABLE_PATTERN_KEYWORD_IN_DECLARATION_CONTEXT',
-    "Variable patterns in declaration context can't specify 'var' or 'final' "
-        "keyword.",
-    correctionMessage: "Try removing the keyword.",
-    hasPublishedDocs: true,
-  );
-
   static const ParserErrorCode varAndType = ParserErrorCode(
     'VAR_AND_TYPE',
     "Variables can't be declared using both 'var' and a type name.",
@@ -2028,6 +2018,16 @@
     correctionMessage: "Try removing the keyword 'var'.",
   );
 
+  /// No parameters.
+  static const ParserErrorCode
+  variablePatternKeywordInDeclarationContext = ParserErrorCode(
+    'VARIABLE_PATTERN_KEYWORD_IN_DECLARATION_CONTEXT',
+    "Variable patterns in declaration context can't specify 'var' or 'final' "
+        "keyword.",
+    correctionMessage: "Try removing the keyword.",
+    hasPublishedDocs: true,
+  );
+
   static const ParserErrorCode varReturnType = ParserErrorCode(
     'VAR_RETURN_TYPE',
     "The return type can't be 'var'.",
diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart
index 72a0309..6bdad01 100644
--- a/pkg/analyzer/lib/src/error/codes.g.dart
+++ b/pkg/analyzer/lib/src/error/codes.g.dart
@@ -1616,13 +1616,6 @@
         hasPublishedDocs: true,
       );
 
-  /// No parameters.
-  static const CompileTimeErrorCode enumWithoutConstants = CompileTimeErrorCode(
-    'ENUM_WITHOUT_CONSTANTS',
-    "The enum must have at least one enum constant.",
-    correctionMessage: "Try declaring an enum constant.",
-  );
-
   /// Parameters:
   /// String p0: the name of the abstract method
   /// String p1: the name of the enclosing enum
@@ -1643,6 +1636,13 @@
   );
 
   /// No parameters.
+  static const CompileTimeErrorCode enumWithoutConstants = CompileTimeErrorCode(
+    'ENUM_WITHOUT_CONSTANTS',
+    "The enum must have at least one enum constant.",
+    correctionMessage: "Try declaring an enum constant.",
+  );
+
+  /// No parameters.
   static const CompileTimeErrorCode equalElementsInConstSet =
       CompileTimeErrorCode(
         'EQUAL_ELEMENTS_IN_CONST_SET',
@@ -1856,15 +1856,6 @@
   );
 
   /// No parameters.
-  static const CompileTimeErrorCode extensionOverrideWithoutAccess =
-      CompileTimeErrorCode(
-        'EXTENSION_OVERRIDE_WITHOUT_ACCESS',
-        "An extension override can only be used to access instance members.",
-        correctionMessage: "Consider adding an access to an instance member.",
-        hasPublishedDocs: true,
-      );
-
-  /// No parameters.
   static const CompileTimeErrorCode
   extensionOverrideWithCascade = CompileTimeErrorCode(
     'EXTENSION_OVERRIDE_WITH_CASCADE',
@@ -1875,6 +1866,15 @@
   );
 
   /// No parameters.
+  static const CompileTimeErrorCode extensionOverrideWithoutAccess =
+      CompileTimeErrorCode(
+        'EXTENSION_OVERRIDE_WITHOUT_ACCESS',
+        "An extension override can only be used to access instance members.",
+        correctionMessage: "Consider adding an access to an instance member.",
+        hasPublishedDocs: true,
+      );
+
+  /// No parameters.
   static const CompileTimeErrorCode
   extensionTypeConstructorWithSuperFormalParameter = CompileTimeErrorCode(
     'EXTENSION_TYPE_CONSTRUCTOR_WITH_SUPER_FORMAL_PARAMETER',
@@ -2649,6 +2649,10 @@
         hasPublishedDocs: true,
       );
 
+  @Deprecated("Please use instanceAccessToStaticMember")
+  static const CompileTimeErrorCode INSTANCE_ACCESS_TO_STATIC_MEMBER =
+      instanceAccessToStaticMember;
+
   /// Parameters:
   /// String p0: the name of the static member
   /// String p1: the kind of the static member (field, getter, setter, or
@@ -2664,10 +2668,6 @@
         hasPublishedDocs: true,
       );
 
-  @Deprecated("Please use instanceAccessToStaticMember")
-  static const CompileTimeErrorCode INSTANCE_ACCESS_TO_STATIC_MEMBER =
-      instanceAccessToStaticMember;
-
   /// Parameters:
   /// Object p0: the name of the static member
   /// Object p1: the kind of the static member (field, getter, setter, or
@@ -2763,6 +2763,9 @@
     uniqueName: 'INTERFACE_CLASS_EXTENDED_OUTSIDE_OF_LIBRARY',
   );
 
+  @Deprecated("Please use invalidOverride")
+  static const CompileTimeErrorCode INVALID_OVERRIDE = invalidOverride;
+
   /// No parameters.
   static const CompileTimeErrorCode invalidAnnotation = CompileTimeErrorCode(
     'INVALID_ANNOTATION',
@@ -3043,9 +3046,6 @@
     hasPublishedDocs: true,
   );
 
-  @Deprecated("Please use invalidOverride")
-  static const CompileTimeErrorCode INVALID_OVERRIDE = invalidOverride;
-
   /// Parameters:
   /// Object p0: the name of the declared setter that is not a valid override.
   /// Object p1: the name of the interface that declares the setter.
@@ -3456,17 +3456,6 @@
       );
 
   /// Parameters:
-  /// Element p0: the name of the class that appears in both "extends" and
-  ///             "with" clauses
-  static const CompileTimeErrorCode mixinsSuperClass = CompileTimeErrorCode(
-    'IMPLEMENTS_SUPER_CLASS',
-    "'{0}' can't be used in both the 'extends' and 'with' clauses.",
-    correctionMessage: "Try removing one of the occurrences.",
-    hasPublishedDocs: true,
-    uniqueName: 'MIXINS_SUPER_CLASS',
-  );
-
-  /// Parameters:
   /// String p0: the name of the super-invoked member
   /// DartType p1: the display name of the type of the super-invoked member in
   ///              the mixin
@@ -3481,18 +3470,6 @@
   );
 
   /// Parameters:
-  /// DartType p0: the display name of the mixin
-  /// DartType p1: the display name of the superclass
-  /// DartType p2: the display name of the type that is not implemented
-  static const CompileTimeErrorCode
-  mixinApplicationNotImplementedInterface = CompileTimeErrorCode(
-    'MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE',
-    "'{0}' can't be mixed onto '{1}' because '{1}' doesn't implement '{2}'.",
-    correctionMessage: "Try extending the class '{0}'.",
-    hasPublishedDocs: true,
-  );
-
-  /// Parameters:
   /// String p0: the display name of the member without a concrete
   ///            implementation
   static const CompileTimeErrorCode
@@ -3516,6 +3493,18 @@
   );
 
   /// Parameters:
+  /// DartType p0: the display name of the mixin
+  /// DartType p1: the display name of the superclass
+  /// DartType p2: the display name of the type that is not implemented
+  static const CompileTimeErrorCode
+  mixinApplicationNotImplementedInterface = CompileTimeErrorCode(
+    'MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE',
+    "'{0}' can't be mixed onto '{1}' because '{1}' doesn't implement '{2}'.",
+    correctionMessage: "Try extending the class '{0}'.",
+    hasPublishedDocs: true,
+  );
+
+  /// Parameters:
   /// String p0: the name of the mixin class that is invalid
   static const CompileTimeErrorCode mixinClassDeclarationExtendsNotObject =
       CompileTimeErrorCode(
@@ -3604,6 +3593,17 @@
       );
 
   /// Parameters:
+  /// Element p0: the name of the class that appears in both "extends" and
+  ///             "with" clauses
+  static const CompileTimeErrorCode mixinsSuperClass = CompileTimeErrorCode(
+    'IMPLEMENTS_SUPER_CLASS',
+    "'{0}' can't be used in both the 'extends' and 'with' clauses.",
+    correctionMessage: "Try removing one of the occurrences.",
+    hasPublishedDocs: true,
+    uniqueName: 'MIXINS_SUPER_CLASS',
+  );
+
+  /// Parameters:
   /// String p0: the name of the mixin that is not 'base'
   /// String p1: the name of the 'base' supertype
   static const CompileTimeErrorCode mixinSubtypeOfBaseIsNotBase =
@@ -3730,6 +3730,72 @@
         hasPublishedDocs: true,
       );
 
+  /// No parameters.
+  static const CompileTimeErrorCode noAnnotationConstructorArguments =
+      CompileTimeErrorCode(
+        'NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS',
+        "Annotation creation must have arguments.",
+        correctionMessage: "Try adding an empty argument list.",
+        hasPublishedDocs: true,
+      );
+
+  /// Parameters:
+  /// String p0: the name of the class where override error was detected
+  /// String p1: the list of candidate signatures which cannot be combined
+  static const CompileTimeErrorCode
+  noCombinedSuperSignature = CompileTimeErrorCode(
+    'NO_COMBINED_SUPER_SIGNATURE',
+    "Can't infer missing types in '{0}' from overridden methods: {1}.",
+    correctionMessage:
+        "Try providing explicit types for this method's parameters and return "
+        "type.",
+    hasPublishedDocs: true,
+  );
+
+  /// Parameters:
+  /// Object p0: the name of the superclass that does not define an implicitly
+  ///            invoked constructor
+  static const CompileTimeErrorCode noDefaultSuperConstructorExplicit =
+      CompileTimeErrorCode(
+        'NO_DEFAULT_SUPER_CONSTRUCTOR',
+        "The superclass '{0}' doesn't have a zero argument constructor.",
+        correctionMessage:
+            "Try declaring a zero argument constructor in '{0}', or explicitly "
+            "invoking a different constructor in '{0}'.",
+        uniqueName: 'NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT',
+      );
+
+  /// Parameters:
+  /// DartType p0: the name of the superclass that does not define an implicitly
+  ///              invoked constructor
+  /// String p1: the name of the subclass that does not contain any explicit
+  ///            constructors
+  static const CompileTimeErrorCode
+  noDefaultSuperConstructorImplicit = CompileTimeErrorCode(
+    'NO_DEFAULT_SUPER_CONSTRUCTOR',
+    "The superclass '{0}' doesn't have a zero argument constructor.",
+    correctionMessage:
+        "Try declaring a zero argument constructor in '{0}', or declaring a "
+        "constructor in {1} that explicitly invokes a constructor in '{0}'.",
+    uniqueName: 'NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT',
+  );
+
+  /// Parameters:
+  /// String p0: the name of the subclass
+  /// String p1: the name of the superclass
+  static const CompileTimeErrorCode
+  noGenerativeConstructorsInSuperclass = CompileTimeErrorCode(
+    'NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS',
+    "The class '{0}' can't extend '{1}' because '{1}' only has factory "
+        "constructors (no generative constructors), and '{0}' has at least one "
+        "generative constructor.",
+    correctionMessage:
+        "Try implementing the class instead, adding a generative (not factory) "
+        "constructor to the superclass '{1}', or a factory constructor to the "
+        "subclass.",
+    hasPublishedDocs: true,
+  );
+
   /// Parameters:
   /// String p0: the name of the first member
   /// String p1: the name of the second member
@@ -4291,72 +4357,6 @@
       );
 
   /// No parameters.
-  static const CompileTimeErrorCode noAnnotationConstructorArguments =
-      CompileTimeErrorCode(
-        'NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS',
-        "Annotation creation must have arguments.",
-        correctionMessage: "Try adding an empty argument list.",
-        hasPublishedDocs: true,
-      );
-
-  /// Parameters:
-  /// String p0: the name of the class where override error was detected
-  /// String p1: the list of candidate signatures which cannot be combined
-  static const CompileTimeErrorCode
-  noCombinedSuperSignature = CompileTimeErrorCode(
-    'NO_COMBINED_SUPER_SIGNATURE',
-    "Can't infer missing types in '{0}' from overridden methods: {1}.",
-    correctionMessage:
-        "Try providing explicit types for this method's parameters and return "
-        "type.",
-    hasPublishedDocs: true,
-  );
-
-  /// Parameters:
-  /// Object p0: the name of the superclass that does not define an implicitly
-  ///            invoked constructor
-  static const CompileTimeErrorCode noDefaultSuperConstructorExplicit =
-      CompileTimeErrorCode(
-        'NO_DEFAULT_SUPER_CONSTRUCTOR',
-        "The superclass '{0}' doesn't have a zero argument constructor.",
-        correctionMessage:
-            "Try declaring a zero argument constructor in '{0}', or explicitly "
-            "invoking a different constructor in '{0}'.",
-        uniqueName: 'NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT',
-      );
-
-  /// Parameters:
-  /// DartType p0: the name of the superclass that does not define an implicitly
-  ///              invoked constructor
-  /// String p1: the name of the subclass that does not contain any explicit
-  ///            constructors
-  static const CompileTimeErrorCode
-  noDefaultSuperConstructorImplicit = CompileTimeErrorCode(
-    'NO_DEFAULT_SUPER_CONSTRUCTOR',
-    "The superclass '{0}' doesn't have a zero argument constructor.",
-    correctionMessage:
-        "Try declaring a zero argument constructor in '{0}', or declaring a "
-        "constructor in {1} that explicitly invokes a constructor in '{0}'.",
-    uniqueName: 'NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT',
-  );
-
-  /// Parameters:
-  /// String p0: the name of the subclass
-  /// String p1: the name of the superclass
-  static const CompileTimeErrorCode
-  noGenerativeConstructorsInSuperclass = CompileTimeErrorCode(
-    'NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS',
-    "The class '{0}' can't extend '{1}' because '{1}' only has factory "
-        "constructors (no generative constructors), and '{0}' has at least one "
-        "generative constructor.",
-    correctionMessage:
-        "Try implementing the class instead, adding a generative (not factory) "
-        "constructor to the superclass '{1}', or a factory constructor to the "
-        "subclass.",
-    hasPublishedDocs: true,
-  );
-
-  /// No parameters.
   static const CompileTimeErrorCode nullableTypeInExtendsClause =
       CompileTimeErrorCode(
         'NULLABLE_TYPE_IN_EXTENDS_CLAUSE',
@@ -5161,26 +5161,6 @@
     hasPublishedDocs: true,
   );
 
-  /// 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
-  /// is a compile-time error if a generative constructor of class Object
-  /// includes a superinitializer.
-  ///
-  /// No parameters.
-  static const CompileTimeErrorCode superInitializerInObject =
-      CompileTimeErrorCode(
-        'SUPER_INITIALIZER_IN_OBJECT',
-        "The class 'Object' can't invoke a constructor from a superclass.",
-      );
-
-  /// Parameters:
-  /// String p0: the superinitializer
-  static const CompileTimeErrorCode superInvocationNotLast =
-      CompileTimeErrorCode(
-        'SUPER_INVOCATION_NOT_LAST',
-        "The superconstructor call must be last in an initializer list: '{0}'.",
-        hasPublishedDocs: true,
-      );
-
   /// No parameters.
   static const CompileTimeErrorCode superInEnumConstructor =
       CompileTimeErrorCode(
@@ -5214,6 +5194,17 @@
         hasPublishedDocs: true,
       );
 
+  /// 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
+  /// is a compile-time error if a generative constructor of class Object
+  /// includes a superinitializer.
+  ///
+  /// No parameters.
+  static const CompileTimeErrorCode superInitializerInObject =
+      CompileTimeErrorCode(
+        'SUPER_INITIALIZER_IN_OBJECT',
+        "The class 'Object' can't invoke a constructor from a superclass.",
+      );
+
   /// No parameters.
   static const CompileTimeErrorCode superInRedirectingConstructor =
       CompileTimeErrorCode(
@@ -5222,6 +5213,15 @@
         hasPublishedDocs: true,
       );
 
+  /// Parameters:
+  /// String p0: the superinitializer
+  static const CompileTimeErrorCode superInvocationNotLast =
+      CompileTimeErrorCode(
+        'SUPER_INVOCATION_NOT_LAST',
+        "The superconstructor call must be last in an initializer list: '{0}'.",
+        hasPublishedDocs: true,
+      );
+
   /// No parameters.
   static const CompileTimeErrorCode switchCaseCompletesNormally =
       CompileTimeErrorCode(
@@ -5263,6 +5263,10 @@
     hasPublishedDocs: true,
   );
 
+  @Deprecated("Please use typeArgumentNotMatchingBounds")
+  static const CompileTimeErrorCode TYPE_ARGUMENT_NOT_MATCHING_BOUNDS =
+      typeArgumentNotMatchingBounds;
+
   /// No parameters.
   static const CompileTimeErrorCode
   typeAliasCannotReferenceItself = CompileTimeErrorCode(
@@ -5301,10 +5305,6 @@
         hasPublishedDocs: true,
       );
 
-  @Deprecated("Please use typeArgumentNotMatchingBounds")
-  static const CompileTimeErrorCode TYPE_ARGUMENT_NOT_MATCHING_BOUNDS =
-      typeArgumentNotMatchingBounds;
-
   /// No parameters.
   static const CompileTimeErrorCode typeParameterReferencedByStatic =
       CompileTimeErrorCode(
@@ -5449,6 +5449,9 @@
         uniqueName: 'UNCHECKED_USE_OF_NULLABLE_VALUE_IN_YIELD_EACH',
       );
 
+  @Deprecated("Please use undefinedClass")
+  static const CompileTimeErrorCode UNDEFINED_CLASS = undefinedClass;
+
   /// Parameters:
   /// String p0: the name of the annotation
   static const CompileTimeErrorCode undefinedAnnotation = CompileTimeErrorCode(
@@ -5472,9 +5475,6 @@
     isUnresolvedIdentifier: true,
   );
 
-  @Deprecated("Please use undefinedClass")
-  static const CompileTimeErrorCode UNDEFINED_CLASS = undefinedClass;
-
   /// Same as [CompileTimeErrorCode.UNDEFINED_CLASS], but to catch using
   /// "boolean" instead of "bool" in order to improve the correction message.
   ///
diff --git a/pkg/analyzer/tool/messages/error_code_info.dart b/pkg/analyzer/tool/messages/error_code_info.dart
index 202761a..060507f 100644
--- a/pkg/analyzer/tool/messages/error_code_info.dart
+++ b/pkg/analyzer/tool/messages/error_code_info.dart
@@ -7,6 +7,7 @@
 
 import 'package:analyzer/src/utilities/extensions/string.dart';
 import 'package:analyzer_testing/package_root.dart' as pkg_root;
+import 'package:analyzer_utilities/tools.dart';
 import 'package:path/path.dart';
 import 'package:yaml/yaml.dart' show loadYaml;
 
@@ -409,6 +410,20 @@
           .firstWhere((element) => element.name == aliasForClass)
           .file
           .path;
+
+  @override
+  void toAnalyzerCode(
+    ErrorClassInfo errorClassInfo,
+    String diagnosticCode, {
+    String? sharedNameReference,
+    required MemberAccumulator memberAccumulator,
+  }) {
+    var constant = StringBuffer();
+    _outputConstantHeader(constant);
+    constant.writeln('  static const $aliasForClass $diagnosticCode =');
+    constant.writeln('$aliasFor;');
+    memberAccumulator.constants[diagnosticCode] = constant.toString();
+  }
 }
 
 /// In-memory representation of error code information obtained from the
@@ -719,10 +734,10 @@
   ///
   /// [diagnosticCode] is the name of the error code to be generated.
   void toAnalyzerCode(
-    StringBuffer out,
     ErrorClassInfo errorClassInfo,
     String diagnosticCode, {
     String? sharedNameReference,
+    required MemberAccumulator memberAccumulator,
   }) {
     var correctionMessage = this.correctionMessage;
     var parameters = this.parameters;
@@ -734,7 +749,6 @@
     String className;
     String templateParameters = '';
     String? withArgumentsName;
-    String? withArgumentsText;
     if (parameters != null && parameters.isNotEmpty && !usesParameters) {
       throw StateError(
         "Error code declares parameters using a `parameters` entry, but "
@@ -757,7 +771,7 @@
           '<LocatableDiagnostic Function({$withArgumentsParams})>';
       var newIfNeeded =
           errorClassInfo.file.shouldUseExplicitNewOrConst ? 'new ' : '';
-      withArgumentsText = '''
+      memberAccumulator.staticMethods[withArgumentsName] = '''
 static LocatableDiagnostic $withArgumentsName({$withArgumentsParams}) {
   return ${newIfNeeded}LocatableDiagnosticImpl($constantName, [$argumentNames]);
 }''';
@@ -766,10 +780,16 @@
       className = errorClassInfo.withoutArgumentsName;
     }
 
-    out.writeln('  static const $className$templateParameters $constantName =');
-    if (errorClassInfo.file.shouldUseExplicitNewOrConst) out.writeln('const ');
-    out.writeln('$className(');
-    out.writeln(
+    var constant = StringBuffer();
+    _outputConstantHeader(constant);
+    constant.writeln(
+      '  static const $className$templateParameters $constantName =',
+    );
+    if (errorClassInfo.file.shouldUseExplicitNewOrConst) {
+      constant.writeln('const ');
+    }
+    constant.writeln('$className(');
+    constant.writeln(
       '${sharedNameReference ?? "'${sharedName ?? diagnosticCode}'"},',
     );
     var maxWidth = 80 - 8 /* indentation */ - 2 /* quotes */ - 1 /* comma */;
@@ -780,37 +800,33 @@
       maxWidth: maxWidth,
       firstLineWidth: maxWidth + 4,
     );
-    out.writeln('${messageLines.map(_encodeString).join('\n')},');
+    constant.writeln('${messageLines.map(_encodeString).join('\n')},');
     if (correctionMessage is String) {
-      out.write('correctionMessage: ');
+      constant.write('correctionMessage: ');
       var code = convertTemplate(placeholderToIndexMap, correctionMessage);
       var codeLines = _splitText(code, maxWidth: maxWidth);
-      out.writeln('${codeLines.map(_encodeString).join('\n')},');
+      constant.writeln('${codeLines.map(_encodeString).join('\n')},');
     }
     if (hasPublishedDocs ?? false) {
-      out.writeln('hasPublishedDocs:true,');
+      constant.writeln('hasPublishedDocs:true,');
     }
     if (isUnresolvedIdentifier) {
-      out.writeln('isUnresolvedIdentifier:true,');
+      constant.writeln('isUnresolvedIdentifier:true,');
     }
     if (sharedName != null) {
-      out.writeln("uniqueName: '$diagnosticCode',");
+      constant.writeln("uniqueName: '$diagnosticCode',");
     }
     if (withArgumentsName != null) {
-      out.writeln('withArguments: $withArgumentsName,');
+      constant.writeln('withArguments: $withArgumentsName,');
     }
-    out.writeln(');');
-    if (withArgumentsText != null) {
-      out.writeln();
-      out.writeln(withArgumentsText);
-    }
+    constant.writeln(');');
+    memberAccumulator.constants[constantName] = constant.toString();
 
     if (errorClassInfo.deprecatedSnakeCaseNames.contains(diagnosticCode)) {
-      out.writeln();
-      out.writeln('  @Deprecated("Please use $constantName")');
-      out.writeln(
-        '  static const ${errorClassInfo.name} $diagnosticCode = $constantName;',
-      );
+      memberAccumulator.constants[diagnosticCode] = '''
+  @Deprecated("Please use $constantName")
+  static const ${errorClassInfo.name} $diagnosticCode = $constantName;
+''';
     }
   }
 
@@ -873,6 +889,13 @@
     return jsonEncoded.replaceAll(r'$', r'\$');
   }
 
+  void _outputConstantHeader(StringSink out) {
+    out.write(toAnalyzerComments(indent: '  '));
+    if (deprecatedMessage != null) {
+      out.writeln('  @Deprecated("$deprecatedMessage")');
+    }
+  }
+
   static List<ErrorCodeParameter>? _decodeParameters(Object? yaml) {
     if (yaml == null) return null;
     if (yaml == 'none') return const [];
diff --git a/pkg/analyzer/tool/messages/generate.dart b/pkg/analyzer/tool/messages/generate.dart
index 23589ac..1137e62 100644
--- a/pkg/analyzer/tool/messages/generate.dart
+++ b/pkg/analyzer/tool/messages/generate.dart
@@ -124,33 +124,26 @@
         });
       }
       out.write('class ${errorClass.name} extends DiagnosticCode {');
+      var memberAccumulator = MemberAccumulator();
       var entries = [
         ...analyzerMessages[errorClass.name]!.entries,
         if (errorClass.includeCfeMessages)
           ...cfeToAnalyzerErrorCodeTables.analyzerCodeToInfo.entries,
-      ].where((error) => !error.value.isRemoved).sortedBy((e) => e.key);
+      ].where((error) => !error.value.isRemoved);
       for (var entry in entries) {
         var errorName = entry.key;
         var errorCodeInfo = entry.value;
 
         try {
-          out.writeln();
-          out.write(errorCodeInfo.toAnalyzerComments(indent: '  '));
-          var deprecatedMessage = errorCodeInfo.deprecatedMessage;
-          if (deprecatedMessage != null) {
-            out.writeln('  @Deprecated("$deprecatedMessage")');
+          if (errorCodeInfo is! AliasErrorCodeInfo &&
+              errorClass.includeInDiagnosticCodeValues) {
+            generatedCodes.add((errorClass.name, errorName));
           }
-          if (errorCodeInfo is AliasErrorCodeInfo) {
-            out.writeln(
-              '  static const ${errorCodeInfo.aliasForClass} $errorName =',
-            );
-            out.writeln('${errorCodeInfo.aliasFor};');
-          } else {
-            if (errorClass.includeInDiagnosticCodeValues) {
-              generatedCodes.add((errorClass.name, errorName));
-            }
-            errorCodeInfo.toAnalyzerCode(out, errorClass, errorName);
-          }
+          errorCodeInfo.toAnalyzerCode(
+            errorClass,
+            errorName,
+            memberAccumulator: memberAccumulator,
+          );
         } catch (e, st) {
           Error.throwWithStackTrace(
             'While processing ${errorClass.name}.$errorName: $e',
@@ -158,33 +151,40 @@
           );
         }
       }
-      out.writeln();
-      out.writeln(
+
+      var constructor = StringBuffer();
+      constructor.writeln(
         '/// Initialize a newly created error code to have the given '
         '[name].',
       );
-      out.writeln(
+      constructor.writeln(
         'const ${errorClass.name}(String name, String problemMessage, {',
       );
-      out.writeln('super.correctionMessage,');
-      out.writeln('super.hasPublishedDocs = false,');
-      out.writeln('super.isUnresolvedIdentifier = false,');
-      out.writeln('String? uniqueName,');
-      out.writeln('}) : super(');
-      out.writeln('name: name,');
-      out.writeln('problemMessage: problemMessage,');
-      out.writeln("uniqueName: '${errorClass.name}.\${uniqueName ?? name}',");
-      out.writeln(');');
-      out.writeln();
-      out.writeln('@override');
-      out.writeln(
-        'DiagnosticSeverity get severity => '
-        '${errorClass.severityCode};',
+      constructor.writeln('super.correctionMessage,');
+      constructor.writeln('super.hasPublishedDocs = false,');
+      constructor.writeln('super.isUnresolvedIdentifier = false,');
+      constructor.writeln('String? uniqueName,');
+      constructor.writeln('}) : super(');
+      constructor.writeln('name: name,');
+      constructor.writeln('problemMessage: problemMessage,');
+      constructor.writeln(
+        "uniqueName: '${errorClass.name}.\${uniqueName ?? name}',",
       );
-      out.writeln();
-      out.writeln('@override');
-      out.writeln('DiagnosticType get type => ${errorClass.typeCode};');
+      constructor.writeln(');');
+      memberAccumulator.constructors[''] = constructor.toString();
+
+      memberAccumulator.accessors['severity'] = '''
+@override
+DiagnosticSeverity get severity => ${errorClass.severityCode};
+''';
+      memberAccumulator.accessors['type'] = '''
+@override
+DiagnosticType get type => ${errorClass.typeCode};
+''';
+
+      memberAccumulator.writeTo(out);
       out.writeln('}');
+
       if (literateApiEnabled) {
         out.writeln();
         _outputDerivedClass(errorClass, withArguments: true);
diff --git a/pkg/analyzer_utilities/lib/tools.dart b/pkg/analyzer_utilities/lib/tools.dart
index b7dc965..065acac 100644
--- a/pkg/analyzer_utilities/lib/tools.dart
+++ b/pkg/analyzer_utilities/lib/tools.dart
@@ -11,6 +11,7 @@
 import 'package:analyzer_utilities/html_dom.dart' as dom;
 import 'package:analyzer_utilities/html_generator.dart';
 import 'package:analyzer_utilities/text_formatter.dart';
+import 'package:collection/collection.dart';
 import 'package:path/path.dart';
 
 final RegExp trailingSpacesInLineRegExp = RegExp(r' +$', multiLine: true);
@@ -419,6 +420,45 @@
   }
 }
 
+/// Helper class that can accumulate members of a generated class and then
+/// output them in sorted order.
+///
+/// To use this class, accumulate the desired members into the maps [constants],
+/// [constructors], [accessors], and [staticMethods], and then call [writeTo].
+/// The members will be sorted by map key prior to output them, so the map keys
+/// should be the member names.
+class MemberAccumulator {
+  final Map<String, String> constants = {};
+  final Map<String, String> constructors = {};
+  final Map<String, String> accessors = {};
+  final Map<String, String> staticMethods = {};
+
+  /// Writes the accumulated members to [out].
+  void writeTo(StringBuffer out) {
+    Iterable<String> sortMembers(Map<String, String> nameToMemberMap) =>
+        nameToMemberMap.entries
+            .sortedBy((e) => e.key.toLowerCase())
+            .map((e) => e.value);
+
+    var members = [
+      ...sortMembers(constants),
+      ...sortMembers(constructors),
+      ...sortMembers(accessors),
+      ...sortMembers(staticMethods),
+    ];
+
+    var blankLineNeeded = false;
+    for (var member in members) {
+      if (blankLineNeeded) {
+        out.writeln();
+      } else {
+        blankLineNeeded = true;
+      }
+      out.write(member);
+    }
+  }
+}
+
 /// State used by [CodeGenerator].
 class _CodeGeneratorState {
   StringBuffer buffer = StringBuffer();
diff --git a/pkg/linter/lib/src/lint_codes.g.dart b/pkg/linter/lib/src/lint_codes.g.dart
index 2eb9519..855d41a 100644
--- a/pkg/linter/lib/src/lint_codes.g.dart
+++ b/pkg/linter/lib/src/lint_codes.g.dart
@@ -421,14 +421,6 @@
   );
 
   /// No parameters.
-  static const LinterLintCode avoidReturnTypesOnSetters = LinterLintCode(
-    LintNames.avoid_return_types_on_setters,
-    "Unnecessary return type on a setter.",
-    correctionMessage: "Try removing the return type.",
-    hasPublishedDocs: true,
-  );
-
-  /// No parameters.
   static const LinterLintCode avoidReturningNullForVoidFromFunction =
       LinterLintCode(
         LintNames.avoid_returning_null_for_void,
@@ -457,6 +449,14 @@
   );
 
   /// No parameters.
+  static const LinterLintCode avoidReturnTypesOnSetters = LinterLintCode(
+    LintNames.avoid_return_types_on_setters,
+    "Unnecessary return type on a setter.",
+    correctionMessage: "Try removing the return type.",
+    hasPublishedDocs: true,
+  );
+
+  /// No parameters.
   static const LinterLintCode avoidSettersWithoutGetters = LinterLintCode(
     LintNames.avoid_setters_without_getters,
     "Setter has no corresponding getter.",
@@ -492,15 +492,6 @@
     hasPublishedDocs: true,
   );
 
-  /// No parameters.
-  static const LinterLintCode avoidTypeToString = LinterLintCode(
-    LintNames.avoid_type_to_string,
-    "Using 'toString' on a 'Type' is not safe in production code.",
-    correctionMessage:
-        "Try a normal type check or compare the 'runtimeType' directly.",
-    hasPublishedDocs: true,
-  );
-
   /// Parameters:
   /// Object p0: undocumented
   static const LinterLintCode
@@ -534,6 +525,15 @@
   );
 
   /// No parameters.
+  static const LinterLintCode avoidTypeToString = LinterLintCode(
+    LintNames.avoid_type_to_string,
+    "Using 'toString' on a 'Type' is not safe in production code.",
+    correctionMessage:
+        "Try a normal type check or compare the 'runtimeType' directly.",
+    hasPublishedDocs: true,
+  );
+
+  /// No parameters.
   static const LinterLintCode avoidUnnecessaryContainers = LinterLintCode(
     LintNames.avoid_unnecessary_containers,
     "Unnecessary instance of 'Container'.",
@@ -815,13 +815,6 @@
   );
 
   /// No parameters.
-  static const LinterLintCode doNotUseEnvironment = LinterLintCode(
-    LintNames.do_not_use_environment,
-    "Invalid use of an environment declaration.",
-    correctionMessage: "Try removing the environment declaration usage.",
-  );
-
-  /// No parameters.
   static const LinterLintCode documentIgnores = LinterLintCode(
     LintNames.document_ignores,
     "Missing documentation explaining why the diagnostic is ignored.",
@@ -830,6 +823,13 @@
   );
 
   /// No parameters.
+  static const LinterLintCode doNotUseEnvironment = LinterLintCode(
+    LintNames.do_not_use_environment,
+    "Invalid use of an environment declaration.",
+    correctionMessage: "Try removing the environment declaration usage.",
+  );
+
+  /// No parameters.
   static const LinterLintCode emptyCatches = LinterLintCode(
     LintNames.empty_catches,
     "Empty catch block.",
@@ -1206,6 +1206,23 @@
     hasPublishedDocs: true,
   );
 
+  /// Parameters:
+  /// Object p0: undocumented
+  static const LinterLintCode nonConstantIdentifierNames = LinterLintCode(
+    LintNames.non_constant_identifier_names,
+    "The variable name '{0}' isn't a lowerCamelCase identifier.",
+    correctionMessage:
+        "Try changing the name to follow the lowerCamelCase style.",
+    hasPublishedDocs: true,
+  );
+
+  /// No parameters.
+  static const LinterLintCode noopPrimitiveOperations = LinterLintCode(
+    LintNames.noop_primitive_operations,
+    "The expression has no effect and can be removed.",
+    correctionMessage: "Try removing the expression.",
+  );
+
   /// No parameters.
   static const LinterLintCode noRuntimetypeTostring = LinterLintCode(
     LintNames.no_runtimeType_toString,
@@ -1246,23 +1263,6 @@
     hasPublishedDocs: true,
   );
 
-  /// Parameters:
-  /// Object p0: undocumented
-  static const LinterLintCode nonConstantIdentifierNames = LinterLintCode(
-    LintNames.non_constant_identifier_names,
-    "The variable name '{0}' isn't a lowerCamelCase identifier.",
-    correctionMessage:
-        "Try changing the name to follow the lowerCamelCase style.",
-    hasPublishedDocs: true,
-  );
-
-  /// No parameters.
-  static const LinterLintCode noopPrimitiveOperations = LinterLintCode(
-    LintNames.noop_primitive_operations,
-    "The expression has no effect and can be removed.",
-    correctionMessage: "Try removing the expression.",
-  );
-
   /// No parameters.
   static const LinterLintCode nullCheckOnNullableTypeParameter = LinterLintCode(
     LintNames.null_check_on_nullable_type_parameter,
@@ -1530,16 +1530,6 @@
   );
 
   /// No parameters.
-  static const LinterLintCode preferForElementsToMapFromiterable =
-      LinterLintCode(
-        LintNames.prefer_for_elements_to_map_fromIterable,
-        "Use 'for' elements when building maps from iterables.",
-        correctionMessage:
-            "Try using a collection literal with a 'for' element.",
-        hasPublishedDocs: true,
-      );
-
-  /// No parameters.
   static const LinterLintCode preferForeach = LinterLintCode(
     LintNames.prefer_foreach,
     "Use 'forEach' and a tear-off rather than a 'for' loop to apply a function "
@@ -1550,6 +1540,16 @@
   );
 
   /// No parameters.
+  static const LinterLintCode preferForElementsToMapFromiterable =
+      LinterLintCode(
+        LintNames.prefer_for_elements_to_map_fromIterable,
+        "Use 'for' elements when building maps from iterables.",
+        correctionMessage:
+            "Try using a collection literal with a 'for' element.",
+        hasPublishedDocs: true,
+      );
+
+  /// No parameters.
   static const LinterLintCode
   preferFunctionDeclarationsOverVariables = LinterLintCode(
     LintNames.prefer_function_declarations_over_variables,
@@ -1615,13 +1615,6 @@
   );
 
   /// No parameters.
-  static const LinterLintCode preferIntLiterals = LinterLintCode(
-    LintNames.prefer_int_literals,
-    "Unnecessary use of a 'double' literal.",
-    correctionMessage: "Try using an 'int' literal.",
-  );
-
-  /// No parameters.
   static const LinterLintCode preferInterpolationToComposeStrings =
       LinterLintCode(
         LintNames.prefer_interpolation_to_compose_strings,
@@ -1632,6 +1625,13 @@
       );
 
   /// No parameters.
+  static const LinterLintCode preferIntLiterals = LinterLintCode(
+    LintNames.prefer_int_literals,
+    "Unnecessary use of a 'double' literal.",
+    correctionMessage: "Try using an 'int' literal.",
+  );
+
+  /// No parameters.
   static const LinterLintCode preferIsEmptyAlwaysFalse = LinterLintCode(
     LintNames.prefer_is_empty,
     "The comparison is always 'false' because the length is always greater "
@@ -1797,6 +1797,14 @@
     hasPublishedDocs: true,
   );
 
+  /// A lint code that removed lints can specify as their `lintCode`.
+  ///
+  /// Avoid other usages as it should be made unnecessary and removed.
+  static const LintCode removedLint = LinterLintCode(
+    'removed_lint',
+    'Removed lint.',
+  );
+
   /// No parameters.
   static const LinterLintCode requireTrailingCommas = LinterLintCode(
     LintNames.require_trailing_commas,
@@ -2044,6 +2052,14 @@
   );
 
   /// No parameters.
+  static const LinterLintCode unnecessaryFinalWithoutType = LinterLintCode(
+    LintNames.unnecessary_final,
+    "Local variables should not be marked as 'final'.",
+    correctionMessage: "Replace 'final' with 'var'.",
+    uniqueName: 'unnecessary_final_without_type',
+  );
+
+  /// No parameters.
   static const LinterLintCode unnecessaryFinalWithType = LinterLintCode(
     LintNames.unnecessary_final,
     "Local variables should not be marked as 'final'.",
@@ -2053,14 +2069,6 @@
   );
 
   /// No parameters.
-  static const LinterLintCode unnecessaryFinalWithoutType = LinterLintCode(
-    LintNames.unnecessary_final,
-    "Local variables should not be marked as 'final'.",
-    correctionMessage: "Replace 'final' with 'var'.",
-    uniqueName: 'unnecessary_final_without_type',
-  );
-
-  /// No parameters.
   static const LinterLintCode unnecessaryGettersSetters = LinterLintCode(
     LintNames.unnecessary_getters_setters,
     "Unnecessary use of getter and setter to wrap a field.",
@@ -2150,6 +2158,15 @@
   );
 
   /// No parameters.
+  static const LinterLintCode unnecessaryNullableForFinalVariableDeclarations =
+      LinterLintCode(
+        LintNames.unnecessary_nullable_for_final_variable_declarations,
+        "Type could be non-nullable.",
+        correctionMessage: "Try changing the type to be non-nullable.",
+        hasPublishedDocs: true,
+      );
+
+  /// No parameters.
   static const LinterLintCode unnecessaryNullAwareAssignments = LinterLintCode(
     LintNames.unnecessary_null_aware_assignments,
     "Unnecessary assignment of 'null'.",
@@ -2184,15 +2201,6 @@
   );
 
   /// No parameters.
-  static const LinterLintCode unnecessaryNullableForFinalVariableDeclarations =
-      LinterLintCode(
-        LintNames.unnecessary_nullable_for_final_variable_declarations,
-        "Type could be non-nullable.",
-        correctionMessage: "Try changing the type to be non-nullable.",
-        hasPublishedDocs: true,
-      );
-
-  /// No parameters.
   static const LinterLintCode unnecessaryOverrides = LinterLintCode(
     LintNames.unnecessary_overrides,
     "Unnecessary override.",
@@ -2553,14 +2561,6 @@
     hasPublishedDocs: true,
   );
 
-  /// A lint code that removed lints can specify as their `lintCode`.
-  ///
-  /// Avoid other usages as it should be made unnecessary and removed.
-  static const LintCode removedLint = LinterLintCode(
-    'removed_lint',
-    'Removed lint.',
-  );
-
   const LinterLintCode(
     super.name,
     super.problemMessage, {
diff --git a/pkg/linter/tool/generate_lints.dart b/pkg/linter/tool/generate_lints.dart
index 40cd1c0..a0a2f8c 100644
--- a/pkg/linter/tool/generate_lints.dart
+++ b/pkg/linter/tool/generate_lints.dart
@@ -65,26 +65,21 @@
 
 class LinterLintCode extends LintCode {
 ''');
-
+      var memberAccumulator = MemberAccumulator();
       for (var MapEntry(key: errorName, value: codeInfo)
           in lintMessages['LintCode']!.entries) {
         var lintName = codeInfo.sharedName ?? errorName;
         if (messagesRuleInfo[lintName]!.removed) continue;
-        out.write(codeInfo.toAnalyzerComments(indent: '  '));
-        if (codeInfo.deprecatedMessage case var deprecatedMessage?) {
-          out.writeln('  @Deprecated("$deprecatedMessage")');
-        }
         codeInfo.toAnalyzerCode(
-          out,
           linterLintCodeInfo,
           errorName,
           sharedNameReference: 'LintNames.$lintName',
+          memberAccumulator: memberAccumulator,
         );
-        out.writeln();
       }
 
       var removedLintName = 'removedLint';
-      out.writeln('''
+      memberAccumulator.constants[removedLintName] = '''
   /// A lint code that removed lints can specify as their `lintCode`.
   ///
   /// Avoid other usages as it should be made unnecessary and removed.
@@ -92,9 +87,9 @@
     'removed_lint',
     'Removed lint.',
   );
-''');
+''';
 
-      out.writeln('''
+      memberAccumulator.constructors[''] = '''
   const LinterLintCode(
     super.name,
     super.problemMessage, {
@@ -102,7 +97,9 @@
     super.hasPublishedDocs,
     String? uniqueName,
   }) : super(uniqueName: 'LintCode.\${uniqueName ?? name}');
+''';
 
+      memberAccumulator.accessors['url'] = '''
   @override
   String get url {
     if (hasPublishedDocs) {
@@ -110,8 +107,10 @@
     }
     return 'https://dart.dev/lints/\$name';
   }
-}
-''');
+''';
+      memberAccumulator.writeTo(out);
+      out.writeln('}');
+
       if (literateApiEnabled) {
         out.write('''