More shared fasta/analyzer error codes

Change-Id: I1b80ce7f8b17e0bb1e974d4effcf8d64a250dda1
Reviewed-on: https://dart-review.googlesource.com/c/80944
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart
index 86444e7..e689cd1 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart
@@ -135,14 +135,9 @@
    * 0: the label that was duplicated
    */
   static const ParserErrorCode DUPLICATE_LABEL_IN_SWITCH_STATEMENT =
-      const ParserErrorCode('DUPLICATE_LABEL_IN_SWITCH_STATEMENT',
-          "The label '{0}' was already used in this switch statement.",
-          correction: "Try choosing a different name for this label.");
+      _DUPLICATE_LABEL_IN_SWITCH_STATEMENT;
 
-  static const ParserErrorCode DUPLICATE_DEFERRED = const ParserErrorCode(
-      'DUPLICATE_DEFERRED',
-      "An import directive can only have one 'deferred' keyword.",
-      correction: "Try removing all but one 'deferred' keyword.");
+  static const ParserErrorCode DUPLICATE_DEFERRED = _DUPLICATE_DEFERRED;
 
   /**
    * Parameters:
@@ -150,18 +145,13 @@
    */
   static const ParserErrorCode DUPLICATED_MODIFIER = _DUPLICATED_MODIFIER;
 
-  static const ParserErrorCode DUPLICATE_PREFIX = const ParserErrorCode(
-      'DUPLICATE_PREFIX',
-      "An import directive can only have one prefix ('as' clause).",
-      correction: "Try removing all but one prefix.");
+  static const ParserErrorCode DUPLICATE_PREFIX = _DUPLICATE_PREFIX;
 
   static const ParserErrorCode EMPTY_ENUM_BODY = const ParserErrorCode(
       'EMPTY_ENUM_BODY', "An enum must declare at least one constant name.",
       correction: "Try declaring a constant.");
 
-  static const ParserErrorCode ENUM_IN_CLASS = const ParserErrorCode(
-      'ENUM_IN_CLASS', "Enums can't be declared inside classes.",
-      correction: "Try moving the enum to the top-level.");
+  static const ParserErrorCode ENUM_IN_CLASS = _ENUM_IN_CLASS;
 
   static const ParserErrorCode EQUALITY_CANNOT_BE_EQUALITY_OPERAND =
       _EQUALITY_CANNOT_BE_EQUALITY_OPERAND;
@@ -201,10 +191,7 @@
       const ParserErrorCode('EXPECTED_TYPE_NAME', "Expected a type name.");
 
   static const ParserErrorCode EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
-      const ParserErrorCode('EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
-          "Export directives must preceed part directives.",
-          correction:
-              "Try moving the export directives before the part directives.");
+      _EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE;
 
   static const ParserErrorCode EXTERNAL_AFTER_CONST = _EXTERNAL_AFTER_CONST;
 
@@ -245,18 +232,12 @@
           correction: "Try removing the body of the setter, or "
               "removing the keyword 'external'.");
 
-  static const ParserErrorCode EXTERNAL_TYPEDEF = const ParserErrorCode(
-      'EXTERNAL_TYPEDEF', "Typedefs can't be declared to be 'external'.",
-      correction: "Try removing the keyword 'external'.");
+  static const ParserErrorCode EXTERNAL_TYPEDEF = _EXTERNAL_TYPEDEF;
 
-  static const ParserErrorCode EXTRANEOUS_MODIFIER = const ParserErrorCode(
-      'EXTRANEOUS_MODIFIER', "Can't have modifier '{0}' here.",
-      correction: "Try removing '{0}'.");
+  static const ParserErrorCode EXTRANEOUS_MODIFIER = _EXTRANEOUS_MODIFIER;
 
   static const ParserErrorCode FACTORY_TOP_LEVEL_DECLARATION =
-      const ParserErrorCode('FACTORY_TOP_LEVEL_DECLARATION',
-          "Top-level declarations can't be declared to be 'factory'.",
-          correction: "Try removing the keyword 'factory'.");
+      _FACTORY_TOP_LEVEL_DECLARATION;
 
   static const ParserErrorCode FACTORY_WITH_INITIALIZERS = const ParserErrorCode(
       'FACTORY_WITH_INITIALIZERS',
@@ -271,15 +252,9 @@
       correction: "Try adding a body to the constructor.");
 
   static const ParserErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR =
-      const ParserErrorCode('FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
-          "Field formal parameters can only be used in a constructor.",
-          correction:
-              "Try replacing the field formal parameter with a normal parameter.");
+      _FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR;
 
-  static const ParserErrorCode FINAL_AND_COVARIANT = const ParserErrorCode(
-      'FINAL_AND_COVARIANT',
-      "Members can't be declared to be both 'final' and 'covariant'.",
-      correction: "Try removing either the 'final' or 'covariant' keyword.");
+  static const ParserErrorCode FINAL_AND_COVARIANT = _FINAL_AND_COVARIANT;
 
   static const ParserErrorCode FINAL_AND_VAR = const ParserErrorCode(
       'FINAL_AND_VAR',
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 ce95cfc..b523e42 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
@@ -78,6 +78,16 @@
   _DEFERRED_AFTER_PREFIX,
   _DIRECTIVE_AFTER_DECLARATION,
   _DUPLICATED_MODIFIER,
+  _DUPLICATE_DEFERRED,
+  _DUPLICATE_LABEL_IN_SWITCH_STATEMENT,
+  _DUPLICATE_PREFIX,
+  _ENUM_IN_CLASS,
+  _EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
+  _EXTERNAL_TYPEDEF,
+  _EXTRANEOUS_MODIFIER,
+  _FACTORY_TOP_LEVEL_DECLARATION,
+  _FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR,
+  _FINAL_AND_COVARIANT,
 ];
 
 const ParserErrorCode _ABSTRACT_CLASS_MEMBER = const ParserErrorCode(
@@ -181,6 +191,25 @@
     'DUPLICATED_MODIFIER', r"The modifier '#lexeme' was already specified.",
     correction: "Try removing all but one occurance of the modifier.");
 
+const ParserErrorCode _DUPLICATE_DEFERRED = const ParserErrorCode(
+    'DUPLICATE_DEFERRED',
+    r"An import directive can only have one 'deferred' keyword.",
+    correction: "Try removing all but one 'deferred' keyword.");
+
+const ParserErrorCode _DUPLICATE_LABEL_IN_SWITCH_STATEMENT =
+    const ParserErrorCode('DUPLICATE_LABEL_IN_SWITCH_STATEMENT',
+        r"The label '#name' was already used in this switch statement.",
+        correction: "Try choosing a different name for this label.");
+
+const ParserErrorCode _DUPLICATE_PREFIX = const ParserErrorCode(
+    'DUPLICATE_PREFIX',
+    r"An import directive can only have one prefix ('as' clause).",
+    correction: "Try removing all but one prefix.");
+
+const ParserErrorCode _ENUM_IN_CLASS = const ParserErrorCode(
+    'ENUM_IN_CLASS', r"Enums can't be declared inside classes.",
+    correction: "Try moving the enum to the top-level.");
+
 const ParserErrorCode _EQUALITY_CANNOT_BE_EQUALITY_OPERAND = const ParserErrorCode(
     'EQUALITY_CANNOT_BE_EQUALITY_OPERAND',
     r"An equality expression can't be an operand of another equality expression.",
@@ -189,6 +218,12 @@
 const ParserErrorCode _EXPECTED_INSTEAD = const ParserErrorCode(
     'EXPECTED_INSTEAD', r"Expected '#string' instead of this.");
 
+const ParserErrorCode _EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
+    const ParserErrorCode('EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
+        r"Export directives must preceed part directives.",
+        correction:
+            "Try moving the export directives before the part directives.");
+
 const ParserErrorCode _EXTERNAL_AFTER_CONST = const ParserErrorCode(
     'EXTERNAL_AFTER_CONST',
     r"The modifier 'external' should be before the modifier 'const'.",
@@ -220,6 +255,29 @@
     'EXTERNAL_METHOD_WITH_BODY',
     r"An external or native method can't have a body.");
 
+const ParserErrorCode _EXTERNAL_TYPEDEF = const ParserErrorCode(
+    'EXTERNAL_TYPEDEF', r"Typedefs can't be declared to be 'external'.",
+    correction: "Try removing the keyword 'external'.");
+
+const ParserErrorCode _EXTRANEOUS_MODIFIER = const ParserErrorCode(
+    'EXTRANEOUS_MODIFIER', r"Can't have modifier '#lexeme' here.",
+    correction: "Try removing '#lexeme'.");
+
+const ParserErrorCode _FACTORY_TOP_LEVEL_DECLARATION = const ParserErrorCode(
+    'FACTORY_TOP_LEVEL_DECLARATION',
+    r"Top-level declarations can't be declared to be 'factory'.",
+    correction: "Try removing the keyword 'factory'.");
+
+const ParserErrorCode _FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR =
+    const ParserErrorCode('FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
+        r"Field formal parameters can only be used in a constructor.",
+        correction: "Try removing 'this.'.");
+
+const ParserErrorCode _FINAL_AND_COVARIANT = const ParserErrorCode(
+    'FINAL_AND_COVARIANT',
+    r"Members can't be declared to be both 'final' and 'covariant'.",
+    correction: "Try removing either the 'final' or 'covariant' keyword.");
+
 const ParserErrorCode _ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE =
     const ParserErrorCode('ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE',
         r"Illegal assignment to non-assignable expression.");
diff --git a/pkg/analyzer/lib/src/fasta/error_converter.dart b/pkg/analyzer/lib/src/fasta/error_converter.dart
index 56ab68c..e6b36f3 100644
--- a/pkg/analyzer/lib/src/fasta/error_converter.dart
+++ b/pkg/analyzer/lib/src/fasta/error_converter.dart
@@ -68,13 +68,6 @@
         errorReporter?.reportErrorForOffset(
             ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE, offset, length);
         return;
-      case "DUPLICATE_LABEL_IN_SWITCH_STATEMENT":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT,
-            offset,
-            length,
-            [arguments['name']]);
-        return;
       case "LABEL_UNDEFINED":
         errorReporter?.reportErrorForOffset(
             CompileTimeErrorCode.LABEL_UNDEFINED,
@@ -82,22 +75,10 @@
             length,
             [arguments['name']]);
         return;
-      case "DUPLICATE_DEFERRED":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.DUPLICATE_DEFERRED, offset, length);
-        return;
-      case "DUPLICATE_PREFIX":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.DUPLICATE_PREFIX, offset, length);
-        return;
       case "EMPTY_ENUM_BODY":
         errorReporter?.reportErrorForOffset(
             ParserErrorCode.EMPTY_ENUM_BODY, offset, length);
         return;
-      case "ENUM_IN_CLASS":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.ENUM_IN_CLASS, offset, length);
-        return;
       case "EXPECTED_CLASS_MEMBER":
         errorReporter?.reportErrorForOffset(
             ParserErrorCode.EXPECTED_CLASS_MEMBER, offset, length);
@@ -118,44 +99,16 @@
         errorReporter?.reportErrorForOffset(
             ParserErrorCode.EXPECTED_TYPE_NAME, offset, length);
         return;
-      case "EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
-            offset,
-            length);
-        return;
       case "EXTERNAL_CONSTRUCTOR_WITH_BODY":
         errorReporter?.reportErrorForOffset(
             ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, offset, length);
         return;
-      case "EXTERNAL_TYPEDEF":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.EXTERNAL_TYPEDEF, offset, length);
-        return;
-      case "EXTRANEOUS_MODIFIER":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.EXTRANEOUS_MODIFIER, offset, length, [lexeme()]);
-        return;
-      case "FACTORY_TOP_LEVEL_DECLARATION":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, offset, length);
-        return;
-      case "FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR,
-            offset,
-            length);
-        return;
       case "FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR":
         errorReporter?.reportErrorForOffset(
             CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR,
             offset,
             length);
         return;
-      case "FINAL_AND_COVARIANT":
-        errorReporter?.reportErrorForOffset(
-            ParserErrorCode.FINAL_AND_COVARIANT, offset, length);
-        return;
       case "FINAL_AND_VAR":
         errorReporter?.reportErrorForOffset(
             ParserErrorCode.FINAL_AND_VAR, offset, length);
diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
index e6e32f4..706a85d 100644
--- a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
+++ b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
@@ -2064,7 +2064,7 @@
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const MessageCode messageDuplicateDeferred = const MessageCode(
     "DuplicateDeferred",
-    analyzerCodes: <String>["DUPLICATE_DEFERRED"],
+    index: 71,
     message: r"""An import directive can only have one 'deferred' keyword.""",
     tip: r"""Try removing all but one 'deferred' keyword.""");
 
@@ -2081,7 +2081,7 @@
 const Code<Message Function(String name)> codeDuplicateLabelInSwitchStatement =
     const Code<Message Function(String name)>("DuplicateLabelInSwitchStatement",
         templateDuplicateLabelInSwitchStatement,
-        analyzerCodes: <String>["DUPLICATE_LABEL_IN_SWITCH_STATEMENT"]);
+        index: 72);
 
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 Message _withArgumentsDuplicateLabelInSwitchStatement(String name) {
@@ -2099,7 +2099,7 @@
 
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const MessageCode messageDuplicatePrefix = const MessageCode("DuplicatePrefix",
-    analyzerCodes: <String>["DUPLICATE_PREFIX"],
+    index: 73,
     message: r"""An import directive can only have one prefix ('as' clause).""",
     tip: r"""Try removing all but one prefix.""");
 
@@ -2594,7 +2594,7 @@
 
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const MessageCode messageEnumInClass = const MessageCode("EnumInClass",
-    analyzerCodes: <String>["ENUM_IN_CLASS"],
+    index: 74,
     message: r"""Enums can't be declared inside classes.""",
     tip: r"""Try moving the enum to the top-level.""");
 
@@ -2977,7 +2977,7 @@
 
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const MessageCode messageExportAfterPart = const MessageCode("ExportAfterPart",
-    analyzerCodes: <String>["EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE"],
+    index: 75,
     message: r"""Export directives must preceed part directives.""",
     tip: r"""Try moving the export directives before the part directives.""");
 
@@ -3182,7 +3182,7 @@
 
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const MessageCode messageExternalTypedef = const MessageCode("ExternalTypedef",
-    analyzerCodes: <String>["EXTERNAL_TYPEDEF"],
+    index: 76,
     message: r"""Typedefs can't be declared to be 'external'.""",
     tip: r"""Try removing the keyword 'external'.""");
 
@@ -3197,7 +3197,7 @@
 const Code<Message Function(Token token)> codeExtraneousModifier =
     const Code<Message Function(Token token)>(
         "ExtraneousModifier", templateExtraneousModifier,
-        analyzerCodes: <String>["EXTRANEOUS_MODIFIER"]);
+        index: 77);
 
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 Message _withArgumentsExtraneousModifier(Token token) {
@@ -3297,7 +3297,7 @@
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const MessageCode messageFactoryTopLevelDeclaration = const MessageCode(
     "FactoryTopLevelDeclaration",
-    analyzerCodes: <String>["FACTORY_TOP_LEVEL_DECLARATION"],
+    index: 78,
     message: r"""Top-level declarations can't be declared to be 'factory'.""",
     tip: r"""Try removing the keyword 'factory'.""");
 
@@ -3417,7 +3417,7 @@
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const MessageCode messageFieldInitializerOutsideConstructor = const MessageCode(
     "FieldInitializerOutsideConstructor",
-    analyzerCodes: <String>["FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR"],
+    index: 79,
     message: r"""Field formal parameters can only be used in a constructor.""",
     tip: r"""Try removing 'this.'.""");
 
@@ -3427,7 +3427,7 @@
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const MessageCode messageFinalAndCovariant = const MessageCode(
     "FinalAndCovariant",
-    analyzerCodes: <String>["FINAL_AND_COVARIANT"],
+    index: 80,
     message:
         r"""Members can't be declared to be both 'final' and 'covariant'.""",
     tip: r"""Try removing either the 'final' or 'covariant' keyword.""");
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index d8c6e49..5d3e0cf 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -464,9 +464,10 @@
     - "class C { class B {} }"
 
 EnumInClass:
+  index: 74
   template: "Enums can't be declared inside classes."
   tip: "Try moving the enum to the top-level."
-  analyzerCode: ENUM_IN_CLASS
+  analyzerCode: ParserErrorCode.ENUM_IN_CLASS
   script:
     - "class Foo { enum Bar { Bar1, Bar2, Bar3 } }"
 
@@ -707,9 +708,10 @@
   analyzerCode: CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER
 
 ExtraneousModifier:
+  index: 77
   template: "Can't have modifier '#lexeme' here."
   tip: "Try removing '#lexeme'."
-  analyzerCode: EXTRANEOUS_MODIFIER
+  analyzerCode: ParserErrorCode.EXTRANEOUS_MODIFIER
   script:
     - "var String foo; main(){}"
     - "var set foo; main(){}"
@@ -739,9 +741,10 @@
     - "static typedef foo();"
 
 FinalAndCovariant:
+  index: 80
   template: "Members can't be declared to be both 'final' and 'covariant'."
   tip: "Try removing either the 'final' or 'covariant' keyword."
-  analyzerCode: FINAL_AND_COVARIANT
+  analyzerCode: ParserErrorCode.FINAL_AND_COVARIANT
   script:
     - "class C { covariant final f = 5; }"
     - "class C { final covariant f = 5; }"
@@ -874,9 +877,10 @@
     - "main() { switch (x) {case 1: continue;} }"
 
 DuplicateLabelInSwitchStatement:
+  index: 72
   template: "The label '#name' was already used in this switch statement."
   tip: "Try choosing a different name for this label."
-  analyzerCode: DUPLICATE_LABEL_IN_SWITCH_STATEMENT
+  analyzerCode: ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT
   statement:
     - "switch (0) {l1: case 0: break; l1: case 1: break;}"
 
@@ -1290,9 +1294,10 @@
     - "class C { C.foo() : this.bar(); C.bar() : this.foo(); }"
 
 FieldInitializerOutsideConstructor:
+  index: 79
   template: "Field formal parameters can only be used in a constructor."
   tip: "Try removing 'this.'."
-  analyzerCode: FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
+  analyzerCode: ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
   script:
     - "class C { void m(this.x); }"
 
@@ -1675,9 +1680,10 @@
   analyzerCode: ParserErrorCode.DEFERRED_AFTER_PREFIX
 
 DuplicateDeferred:
+  index: 71
   template: "An import directive can only have one 'deferred' keyword."
   tip: "Try removing all but one 'deferred' keyword."
-  analyzerCode: DUPLICATE_DEFERRED
+  analyzerCode: ParserErrorCode.DUPLICATE_DEFERRED
 
 DeferredTypeAnnotation:
   template: "The type '#type' is deferred loaded via prefix '#name' and can't be used as a type annotation."
@@ -1686,9 +1692,10 @@
   analyzerCode: TYPE_ANNOTATION_DEFERRED_CLASS
 
 DuplicatePrefix:
+  index: 73
   template: "An import directive can only have one prefix ('as' clause)."
   tip: "Try removing all but one prefix."
-  analyzerCode: DUPLICATE_PREFIX
+  analyzerCode: ParserErrorCode.DUPLICATE_PREFIX
 
 PrefixAfterCombinator:
   index: 6
@@ -2034,9 +2041,10 @@
     - "class C {foo() native 'bar' {}}"
 
 ExternalTypedef:
+  index: 76
   template: "Typedefs can't be declared to be 'external'."
   tip: "Try removing the keyword 'external'."
-  analyzerCode: EXTERNAL_TYPEDEF
+  analyzerCode: ParserErrorCode.EXTERNAL_TYPEDEF
   script:
     - "external typedef F();"
 
@@ -2070,9 +2078,10 @@
     - "part 'foo.dart'; import 'bar.dart';"
 
 ExportAfterPart:
+  index: 75
   template: "Export directives must preceed part directives."
   tip: "Try moving the export directives before the part directives."
-  analyzerCode: EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE
+  analyzerCode: ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE
   script:
     - "part 'foo.dart'; export 'bar.dart';"
 
@@ -2138,9 +2147,10 @@
   severity: CONTEXT
 
 FactoryTopLevelDeclaration:
+  index: 78
   template: "Top-level declarations can't be declared to be 'factory'."
   tip: "Try removing the keyword 'factory'."
-  analyzerCode: FACTORY_TOP_LEVEL_DECLARATION
+  analyzerCode: ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION
   script:
     - "factory class C {}"