mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:01:42 +00:00
Clean up documentation/comments handling for shared errors.
For errors that are shared between the front end and the analyzer, we move the `documentation` and `comment` fields from `pkg/analyzer/messages.yaml` to `pkg/front_end/messages.yaml` (where the rest of the information about the error is). This eliminates the need to have any entries at all for these shared errors in the `pkg/analyzer/messages.yaml` file, so we no longer need the boolean flag `copyFromCfe` in this file. This simplifies generation of analyzer error codes, so we go ahead and take this opportuntity to remove the old `syntactic_errors.g.dart` file, and instead code generate all the shared messages directly into `syntactic_errors.analyzer.g.dart`. In a follow-up CL I'll rename `syntactic_errors.analyzer.g.dart` back to `syntactic_errors.g.dart` to reduce confusion. Change-Id: I1e314e51c94ef595d9d6de8ba2b30e12a18382a8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215155 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
b6b81ebad1
commit
33f69b0ced
|
@ -85,7 +85,6 @@ void buildTestsForAnalyzer() {
|
|||
packagePath: 'analyzer',
|
||||
excludedPaths: [
|
||||
'lib/src/context/packages.dart',
|
||||
'lib/src/dart/error/syntactic_errors.g.dart',
|
||||
'lib/src/summary/format.dart',
|
||||
'test/generated/test_all.dart',
|
||||
],
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,851 +0,0 @@
|
|||
//
|
||||
// THIS FILE IS GENERATED. DO NOT EDIT.
|
||||
//
|
||||
// Instead modify 'pkg/front_end/messages.yaml' and run
|
||||
// 'dart pkg/analyzer/tool/messages/generate.dart' to update.
|
||||
|
||||
part of 'syntactic_errors.analyzer.g.dart';
|
||||
|
||||
final fastaAnalyzerErrorCodes = <ErrorCode?>[
|
||||
null,
|
||||
_EQUALITY_CANNOT_BE_EQUALITY_OPERAND,
|
||||
_CONTINUE_OUTSIDE_OF_LOOP,
|
||||
_EXTERNAL_CLASS,
|
||||
_STATIC_CONSTRUCTOR,
|
||||
_EXTERNAL_ENUM,
|
||||
_PREFIX_AFTER_COMBINATOR,
|
||||
_TYPEDEF_IN_CLASS,
|
||||
_EXPECTED_BODY,
|
||||
_INVALID_AWAIT_IN_FOR,
|
||||
_IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
|
||||
_WITH_BEFORE_EXTENDS,
|
||||
_VAR_RETURN_TYPE,
|
||||
_TYPE_ARGUMENTS_ON_TYPE_VARIABLE,
|
||||
_TOP_LEVEL_OPERATOR,
|
||||
_SWITCH_HAS_MULTIPLE_DEFAULT_CASES,
|
||||
_SWITCH_HAS_CASE_AFTER_DEFAULT_CASE,
|
||||
_STATIC_OPERATOR,
|
||||
_INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER,
|
||||
_STACK_OVERFLOW,
|
||||
_MISSING_CATCH_OR_FINALLY,
|
||||
_REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR,
|
||||
_REDIRECTING_CONSTRUCTOR_WITH_BODY,
|
||||
_NATIVE_CLAUSE_SHOULD_BE_ANNOTATION,
|
||||
_MULTIPLE_WITH_CLAUSES,
|
||||
_MULTIPLE_PART_OF_DIRECTIVES,
|
||||
_MULTIPLE_ON_CLAUSES,
|
||||
_MULTIPLE_LIBRARY_DIRECTIVES,
|
||||
_MULTIPLE_EXTENDS_CLAUSES,
|
||||
_MISSING_STATEMENT,
|
||||
_MISSING_PREFIX_IN_DEFERRED_IMPORT,
|
||||
_MISSING_KEYWORD_OPERATOR,
|
||||
_MISSING_EXPRESSION_IN_THROW,
|
||||
_MISSING_CONST_FINAL_VAR_OR_TYPE,
|
||||
_MISSING_ASSIGNMENT_IN_INITIALIZER,
|
||||
_MISSING_ASSIGNABLE_SELECTOR,
|
||||
_MISSING_INITIALIZER,
|
||||
_LIBRARY_DIRECTIVE_NOT_FIRST,
|
||||
_INVALID_UNICODE_ESCAPE,
|
||||
_INVALID_OPERATOR,
|
||||
_INVALID_HEX_ESCAPE,
|
||||
_EXPECTED_INSTEAD,
|
||||
_IMPLEMENTS_BEFORE_WITH,
|
||||
_IMPLEMENTS_BEFORE_ON,
|
||||
_IMPLEMENTS_BEFORE_EXTENDS,
|
||||
_ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE,
|
||||
_EXPECTED_ELSE_OR_COMMA,
|
||||
_INVALID_SUPER_IN_INITIALIZER,
|
||||
_EXPERIMENT_NOT_ENABLED,
|
||||
_EXTERNAL_METHOD_WITH_BODY,
|
||||
_EXTERNAL_FIELD,
|
||||
_ABSTRACT_CLASS_MEMBER,
|
||||
_BREAK_OUTSIDE_OF_LOOP,
|
||||
_CLASS_IN_CLASS,
|
||||
_COLON_IN_PLACE_OF_IN,
|
||||
_CONSTRUCTOR_WITH_RETURN_TYPE,
|
||||
_MODIFIER_OUT_OF_ORDER,
|
||||
_TYPE_BEFORE_FACTORY,
|
||||
_CONST_AND_FINAL,
|
||||
_CONFLICTING_MODIFIERS,
|
||||
_CONST_CLASS,
|
||||
_VAR_AS_TYPE_NAME,
|
||||
_CONST_FACTORY,
|
||||
_CONST_METHOD,
|
||||
_CONTINUE_WITHOUT_LABEL_IN_CASE,
|
||||
_INVALID_THIS_IN_INITIALIZER,
|
||||
_COVARIANT_AND_STATIC,
|
||||
_COVARIANT_MEMBER,
|
||||
_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,
|
||||
_FINAL_AND_VAR,
|
||||
_INITIALIZED_VARIABLE_IN_FOR_EACH,
|
||||
_CATCH_SYNTAX_EXTRA_PARAMETERS,
|
||||
_CATCH_SYNTAX,
|
||||
_EXTERNAL_FACTORY_REDIRECTION,
|
||||
_EXTERNAL_FACTORY_WITH_BODY,
|
||||
_EXTERNAL_CONSTRUCTOR_WITH_BODY,
|
||||
_FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS,
|
||||
_VAR_AND_TYPE,
|
||||
_INVALID_INITIALIZER,
|
||||
_ANNOTATION_WITH_TYPE_ARGUMENTS,
|
||||
_EXTENSION_DECLARES_CONSTRUCTOR,
|
||||
_EXTENSION_DECLARES_INSTANCE_FIELD,
|
||||
_EXTENSION_DECLARES_ABSTRACT_MEMBER,
|
||||
_MIXIN_DECLARES_CONSTRUCTOR,
|
||||
_NULL_AWARE_CASCADE_OUT_OF_ORDER,
|
||||
_MULTIPLE_VARIANCE_MODIFIERS,
|
||||
_INVALID_USE_OF_COVARIANT_IN_EXTENSION,
|
||||
_TYPE_PARAMETER_ON_CONSTRUCTOR,
|
||||
_VOID_WITH_TYPE_ARGUMENTS,
|
||||
_FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER,
|
||||
_INVALID_CONSTRUCTOR_NAME,
|
||||
_GETTER_CONSTRUCTOR,
|
||||
_SETTER_CONSTRUCTOR,
|
||||
_MEMBER_WITH_CLASS_NAME,
|
||||
_EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER,
|
||||
_ABSTRACT_STATIC_FIELD,
|
||||
_ABSTRACT_LATE_FIELD,
|
||||
_EXTERNAL_LATE_FIELD,
|
||||
_ABSTRACT_EXTERNAL_FIELD,
|
||||
_ANNOTATION_ON_TYPE_ARGUMENT,
|
||||
_BINARY_OPERATOR_WRITTEN_OUT,
|
||||
_EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD,
|
||||
_ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED,
|
||||
_LITERAL_WITH_CLASS_AND_NEW,
|
||||
_LITERAL_WITH_CLASS,
|
||||
_LITERAL_WITH_NEW,
|
||||
_CONSTRUCTOR_WITH_TYPE_ARGUMENTS,
|
||||
];
|
||||
|
||||
const ParserErrorCode _ABSTRACT_CLASS_MEMBER = ParserErrorCode(
|
||||
'ABSTRACT_CLASS_MEMBER',
|
||||
"Members of classes can't be declared to be 'abstract'.",
|
||||
correction:
|
||||
"Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _ABSTRACT_EXTERNAL_FIELD = ParserErrorCode(
|
||||
'ABSTRACT_EXTERNAL_FIELD',
|
||||
"Fields can't be declared both 'abstract' and 'external'.",
|
||||
correction: "Try removing the 'abstract' or 'external' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _ABSTRACT_LATE_FIELD = ParserErrorCode(
|
||||
'ABSTRACT_LATE_FIELD',
|
||||
"Abstract fields cannot be late.",
|
||||
correction: "Try removing the 'abstract' or 'late' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _ABSTRACT_STATIC_FIELD = ParserErrorCode(
|
||||
'ABSTRACT_STATIC_FIELD',
|
||||
"Static fields can't be declared 'abstract'.",
|
||||
correction: "Try removing the 'abstract' or 'static' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _ANNOTATION_ON_TYPE_ARGUMENT = ParserErrorCode(
|
||||
'ANNOTATION_ON_TYPE_ARGUMENT',
|
||||
"Type arguments can't have annotations because they aren't declarations.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _ANNOTATION_WITH_TYPE_ARGUMENTS = ParserErrorCode(
|
||||
'ANNOTATION_WITH_TYPE_ARGUMENTS',
|
||||
"An annotation can't use type arguments.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED =
|
||||
ParserErrorCode(
|
||||
'ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED',
|
||||
"An annotation with type arguments must be followed by an argument list.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _BINARY_OPERATOR_WRITTEN_OUT = ParserErrorCode(
|
||||
'BINARY_OPERATOR_WRITTEN_OUT',
|
||||
"Binary operator '{0}' is written as '{1}' instead of the written out word.",
|
||||
correction: "Try replacing '{0}' with '{1}'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _BREAK_OUTSIDE_OF_LOOP = ParserErrorCode(
|
||||
'BREAK_OUTSIDE_OF_LOOP',
|
||||
"A break statement can't be used outside of a loop or switch statement.",
|
||||
correction: "Try removing the break statement.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CATCH_SYNTAX = ParserErrorCode(
|
||||
'CATCH_SYNTAX',
|
||||
"'catch' must be followed by '(identifier)' or '(identifier, identifier)'.",
|
||||
correction:
|
||||
"No types are needed, the first is given by 'on', the second is always 'StackTrace'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CATCH_SYNTAX_EXTRA_PARAMETERS = ParserErrorCode(
|
||||
'CATCH_SYNTAX_EXTRA_PARAMETERS',
|
||||
"'catch' must be followed by '(identifier)' or '(identifier, identifier)'.",
|
||||
correction:
|
||||
"No types are needed, the first is given by 'on', the second is always 'StackTrace'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CLASS_IN_CLASS = ParserErrorCode(
|
||||
'CLASS_IN_CLASS',
|
||||
"Classes can't be declared inside other classes.",
|
||||
correction: "Try moving the class to the top-level.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _COLON_IN_PLACE_OF_IN = ParserErrorCode(
|
||||
'COLON_IN_PLACE_OF_IN',
|
||||
"For-in loops use 'in' rather than a colon.",
|
||||
correction: "Try replacing the colon with the keyword 'in'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CONFLICTING_MODIFIERS = ParserErrorCode(
|
||||
'CONFLICTING_MODIFIERS',
|
||||
"Members can't be declared to be both '{0}' and '{1}'.",
|
||||
correction: "Try removing one of the keywords.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CONSTRUCTOR_WITH_RETURN_TYPE = ParserErrorCode(
|
||||
'CONSTRUCTOR_WITH_RETURN_TYPE',
|
||||
"Constructors can't have a return type.",
|
||||
correction: "Try removing the return type.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CONSTRUCTOR_WITH_TYPE_ARGUMENTS = ParserErrorCode(
|
||||
'CONSTRUCTOR_WITH_TYPE_ARGUMENTS',
|
||||
"A constructor invocation can't have type arguments after the constructor name.",
|
||||
correction:
|
||||
"Try removing the type arguments or placing them after the class name.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CONST_AND_FINAL = ParserErrorCode(
|
||||
'CONST_AND_FINAL',
|
||||
"Members can't be declared to be both 'const' and 'final'.",
|
||||
correction: "Try removing either the 'const' or 'final' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CONST_CLASS = ParserErrorCode(
|
||||
'CONST_CLASS',
|
||||
"Classes can't be declared to be 'const'.",
|
||||
correction:
|
||||
"Try removing the 'const' keyword. If you're trying to indicate that instances of the class can be constants, place the 'const' keyword on the class' constructor(s).",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CONST_FACTORY = ParserErrorCode(
|
||||
'CONST_FACTORY',
|
||||
"Only redirecting factory constructors can be declared to be 'const'.",
|
||||
correction:
|
||||
"Try removing the 'const' keyword, or replacing the body with '=' followed by a valid target.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CONST_METHOD = ParserErrorCode(
|
||||
'CONST_METHOD',
|
||||
"Getters, setters and methods can't be declared to be 'const'.",
|
||||
correction: "Try removing the 'const' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CONTINUE_OUTSIDE_OF_LOOP = ParserErrorCode(
|
||||
'CONTINUE_OUTSIDE_OF_LOOP',
|
||||
"A continue statement can't be used outside of a loop or switch statement.",
|
||||
correction: "Try removing the continue statement.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _CONTINUE_WITHOUT_LABEL_IN_CASE = ParserErrorCode(
|
||||
'CONTINUE_WITHOUT_LABEL_IN_CASE',
|
||||
"A continue statement in a switch statement must have a label as a target.",
|
||||
correction:
|
||||
"Try adding a label associated with one of the case clauses to the continue statement.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _COVARIANT_AND_STATIC = ParserErrorCode(
|
||||
'COVARIANT_AND_STATIC',
|
||||
"Members can't be declared to be both 'covariant' and 'static'.",
|
||||
correction: "Try removing either the 'covariant' or 'static' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _COVARIANT_MEMBER = ParserErrorCode(
|
||||
'COVARIANT_MEMBER',
|
||||
"Getters, setters and methods can't be declared to be 'covariant'.",
|
||||
correction: "Try removing the 'covariant' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _DEFERRED_AFTER_PREFIX = ParserErrorCode(
|
||||
'DEFERRED_AFTER_PREFIX',
|
||||
"The deferred keyword should come immediately before the prefix ('as' clause).",
|
||||
correction: "Try moving the deferred keyword before the prefix.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _DIRECTIVE_AFTER_DECLARATION = ParserErrorCode(
|
||||
'DIRECTIVE_AFTER_DECLARATION',
|
||||
"Directives must appear before any declarations.",
|
||||
correction: "Try moving the directive before any declarations.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _DUPLICATED_MODIFIER = ParserErrorCode(
|
||||
'DUPLICATED_MODIFIER',
|
||||
"The modifier '{0}' was already specified.",
|
||||
correction: "Try removing all but one occurrence of the modifier.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _DUPLICATE_DEFERRED = ParserErrorCode(
|
||||
'DUPLICATE_DEFERRED',
|
||||
"An import directive can only have one 'deferred' keyword.",
|
||||
correction: "Try removing all but one 'deferred' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _DUPLICATE_LABEL_IN_SWITCH_STATEMENT = 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.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _DUPLICATE_PREFIX = ParserErrorCode(
|
||||
'DUPLICATE_PREFIX',
|
||||
"An import directive can only have one prefix ('as' clause).",
|
||||
correction: "Try removing all but one prefix.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _ENUM_IN_CLASS = ParserErrorCode(
|
||||
'ENUM_IN_CLASS',
|
||||
"Enums can't be declared inside classes.",
|
||||
correction: "Try moving the enum to the top-level.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EQUALITY_CANNOT_BE_EQUALITY_OPERAND = ParserErrorCode(
|
||||
'EQUALITY_CANNOT_BE_EQUALITY_OPERAND',
|
||||
"A comparison expression can't be an operand of another comparison expression.",
|
||||
correction: "Try putting parentheses around one of the comparisons.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXPECTED_BODY = ParserErrorCode(
|
||||
'EXPECTED_BODY',
|
||||
"A {0} must have a body, even if it is empty.",
|
||||
correction: "Try adding an empty body.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXPECTED_ELSE_OR_COMMA = ParserErrorCode(
|
||||
'EXPECTED_ELSE_OR_COMMA',
|
||||
"Expected 'else' or comma.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD = ParserErrorCode(
|
||||
'EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD',
|
||||
"'{0}' can't be used as an identifier because it's a keyword.",
|
||||
correction: "Try renaming this to be an identifier that isn't a keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXPECTED_INSTEAD = ParserErrorCode(
|
||||
'EXPECTED_INSTEAD',
|
||||
"Expected '{0}' instead of this.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXPERIMENT_NOT_ENABLED = ParserErrorCode(
|
||||
'EXPERIMENT_NOT_ENABLED',
|
||||
"This requires the '{0}' language feature to be enabled.",
|
||||
correction:
|
||||
"Try updating your pubspec.yaml to set the minimum SDK constraint to {1} or higher, and running 'pub get'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE = ParserErrorCode(
|
||||
'EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
|
||||
"Export directives must precede part directives.",
|
||||
correction: "Try moving the export directives before the part directives.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTENSION_DECLARES_ABSTRACT_MEMBER = ParserErrorCode(
|
||||
'EXTENSION_DECLARES_ABSTRACT_MEMBER',
|
||||
"Extensions can't declare abstract members.",
|
||||
correction: "Try providing an implementation for the member.",
|
||||
hasPublishedDocs: true,
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTENSION_DECLARES_CONSTRUCTOR = ParserErrorCode(
|
||||
'EXTENSION_DECLARES_CONSTRUCTOR',
|
||||
"Extensions can't declare constructors.",
|
||||
correction: "Try removing the constructor declaration.",
|
||||
hasPublishedDocs: true,
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTENSION_DECLARES_INSTANCE_FIELD = ParserErrorCode(
|
||||
'EXTENSION_DECLARES_INSTANCE_FIELD',
|
||||
"Extensions can't declare instance fields",
|
||||
correction: "Try removing the field declaration or making it a static field",
|
||||
hasPublishedDocs: true,
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_CLASS = ParserErrorCode(
|
||||
'EXTERNAL_CLASS',
|
||||
"Classes can't be declared to be 'external'.",
|
||||
correction: "Try removing the keyword 'external'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_CONSTRUCTOR_WITH_BODY = ParserErrorCode(
|
||||
'EXTERNAL_CONSTRUCTOR_WITH_BODY',
|
||||
"External constructors can't have a body.",
|
||||
correction:
|
||||
"Try removing the body of the constructor, or removing the keyword 'external'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER = ParserErrorCode(
|
||||
'EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER',
|
||||
"An external constructor can't have any initializers.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_ENUM = ParserErrorCode(
|
||||
'EXTERNAL_ENUM',
|
||||
"Enums can't be declared to be 'external'.",
|
||||
correction: "Try removing the keyword 'external'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_FACTORY_REDIRECTION = ParserErrorCode(
|
||||
'EXTERNAL_FACTORY_REDIRECTION',
|
||||
"A redirecting factory can't be external.",
|
||||
correction: "Try removing the 'external' modifier.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_FACTORY_WITH_BODY = ParserErrorCode(
|
||||
'EXTERNAL_FACTORY_WITH_BODY',
|
||||
"External factories can't have a body.",
|
||||
correction:
|
||||
"Try removing the body of the factory, or removing the keyword 'external'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_FIELD = ParserErrorCode(
|
||||
'EXTERNAL_FIELD',
|
||||
"Fields can't be declared to be 'external'.",
|
||||
correction:
|
||||
"Try removing the keyword 'external', or replacing the field by an external getter and/or setter.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_LATE_FIELD = ParserErrorCode(
|
||||
'EXTERNAL_LATE_FIELD',
|
||||
"External fields cannot be late.",
|
||||
correction: "Try removing the 'external' or 'late' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_METHOD_WITH_BODY = ParserErrorCode(
|
||||
'EXTERNAL_METHOD_WITH_BODY',
|
||||
"An external or native method can't have a body.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTERNAL_TYPEDEF = ParserErrorCode(
|
||||
'EXTERNAL_TYPEDEF',
|
||||
"Typedefs can't be declared to be 'external'.",
|
||||
correction: "Try removing the keyword 'external'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _EXTRANEOUS_MODIFIER = ParserErrorCode(
|
||||
'EXTRANEOUS_MODIFIER',
|
||||
"Can't have modifier '{0}' here.",
|
||||
correction: "Try removing '{0}'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _FACTORY_TOP_LEVEL_DECLARATION = ParserErrorCode(
|
||||
'FACTORY_TOP_LEVEL_DECLARATION',
|
||||
"Top-level declarations can't be declared to be 'factory'.",
|
||||
correction: "Try removing the keyword 'factory'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS =
|
||||
ParserErrorCode(
|
||||
'FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS',
|
||||
"A field can only be initialized in its declaring class",
|
||||
correction:
|
||||
"Try passing a value into the superclass constructor, or moving the initialization into the constructor body.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR = ParserErrorCode(
|
||||
'FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
|
||||
"Field formal parameters can only be used in a constructor.",
|
||||
correction: "Try removing 'this.'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _FINAL_AND_COVARIANT = ParserErrorCode(
|
||||
'FINAL_AND_COVARIANT',
|
||||
"Members can't be declared to be both 'final' and 'covariant'.",
|
||||
correction: "Try removing either the 'final' or 'covariant' keyword.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER =
|
||||
ParserErrorCode(
|
||||
'FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER',
|
||||
"Members marked 'late' with an initializer can't be declared to be both 'final' and 'covariant'.",
|
||||
correction:
|
||||
"Try removing either the 'final' or 'covariant' keyword, or removing the initializer.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _FINAL_AND_VAR = ParserErrorCode(
|
||||
'FINAL_AND_VAR',
|
||||
"Members can't be declared to be both 'final' and 'var'.",
|
||||
correction: "Try removing the keyword 'var'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _GETTER_CONSTRUCTOR = ParserErrorCode(
|
||||
'GETTER_CONSTRUCTOR',
|
||||
"Constructors can't be a getter.",
|
||||
correction: "Try removing 'get'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE = ParserErrorCode(
|
||||
'ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE',
|
||||
"Illegal assignment to non-assignable expression.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _IMPLEMENTS_BEFORE_EXTENDS = ParserErrorCode(
|
||||
'IMPLEMENTS_BEFORE_EXTENDS',
|
||||
"The extends clause must be before the implements clause.",
|
||||
correction: "Try moving the extends clause before the implements clause.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _IMPLEMENTS_BEFORE_ON = ParserErrorCode(
|
||||
'IMPLEMENTS_BEFORE_ON',
|
||||
"The on clause must be before the implements clause.",
|
||||
correction: "Try moving the on clause before the implements clause.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _IMPLEMENTS_BEFORE_WITH = ParserErrorCode(
|
||||
'IMPLEMENTS_BEFORE_WITH',
|
||||
"The with clause must be before the implements clause.",
|
||||
correction: "Try moving the with clause before the implements clause.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE = ParserErrorCode(
|
||||
'IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
|
||||
"Import directives must precede part directives.",
|
||||
correction: "Try moving the import directives before the part directives.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INITIALIZED_VARIABLE_IN_FOR_EACH = ParserErrorCode(
|
||||
'INITIALIZED_VARIABLE_IN_FOR_EACH',
|
||||
"The loop variable in a for-each loop can't be initialized.",
|
||||
correction:
|
||||
"Try removing the initializer, or using a different kind of loop.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_AWAIT_IN_FOR = ParserErrorCode(
|
||||
'INVALID_AWAIT_IN_FOR',
|
||||
"The keyword 'await' isn't allowed for a normal 'for' statement.",
|
||||
correction: "Try removing the keyword, or use a for-each statement.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_CONSTRUCTOR_NAME = ParserErrorCode(
|
||||
'INVALID_CONSTRUCTOR_NAME',
|
||||
"The name of a constructor must match the name of the enclosing class.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_HEX_ESCAPE = ParserErrorCode(
|
||||
'INVALID_HEX_ESCAPE',
|
||||
"An escape sequence starting with '\\x' must be followed by 2 hexadecimal digits.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_INITIALIZER = ParserErrorCode(
|
||||
'INVALID_INITIALIZER',
|
||||
"Not a valid initializer.",
|
||||
correction: "To initialize a field, use the syntax 'name = value'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_OPERATOR = ParserErrorCode(
|
||||
'INVALID_OPERATOR',
|
||||
"The string '{0}' isn't a user-definable operator.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER =
|
||||
ParserErrorCode(
|
||||
'INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER',
|
||||
"The operator '?.' cannot be used with 'super' because 'super' cannot be null.",
|
||||
correction: "Try replacing '?.' with '.'",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_SUPER_IN_INITIALIZER = ParserErrorCode(
|
||||
'INVALID_SUPER_IN_INITIALIZER',
|
||||
"Can only use 'super' in an initializer for calling the superclass constructor (e.g. 'super()' or 'super.namedConstructor()')",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_THIS_IN_INITIALIZER = ParserErrorCode(
|
||||
'INVALID_THIS_IN_INITIALIZER',
|
||||
"Can only use 'this' in an initializer for field initialization (e.g. 'this.x = something') and constructor redirection (e.g. 'this()' or 'this.namedConstructor())",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_UNICODE_ESCAPE = ParserErrorCode(
|
||||
'INVALID_UNICODE_ESCAPE',
|
||||
"An escape sequence starting with '\\u' must be followed by 4 hexadecimal digits or from 1 to 6 digits between '{' and '}'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _INVALID_USE_OF_COVARIANT_IN_EXTENSION = ParserErrorCode(
|
||||
'INVALID_USE_OF_COVARIANT_IN_EXTENSION',
|
||||
"Can't have modifier '{0}' in an extension.",
|
||||
correction: "Try removing '{0}'.",
|
||||
hasPublishedDocs: true,
|
||||
);
|
||||
|
||||
const ParserErrorCode _LIBRARY_DIRECTIVE_NOT_FIRST = ParserErrorCode(
|
||||
'LIBRARY_DIRECTIVE_NOT_FIRST',
|
||||
"The library directive must appear before all other directives.",
|
||||
correction: "Try moving the library directive before any other directives.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _LITERAL_WITH_CLASS = ParserErrorCode(
|
||||
'LITERAL_WITH_CLASS',
|
||||
"A {0} literal can't be prefixed by '{1}'.",
|
||||
correction: "Try removing '{1}'",
|
||||
);
|
||||
|
||||
const ParserErrorCode _LITERAL_WITH_CLASS_AND_NEW = ParserErrorCode(
|
||||
'LITERAL_WITH_CLASS_AND_NEW',
|
||||
"A {0} literal can't be prefixed by 'new {1}'.",
|
||||
correction: "Try removing 'new' and '{1}'",
|
||||
);
|
||||
|
||||
const ParserErrorCode _LITERAL_WITH_NEW = ParserErrorCode(
|
||||
'LITERAL_WITH_NEW',
|
||||
"A literal can't be prefixed by 'new'.",
|
||||
correction: "Try removing 'new'",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MEMBER_WITH_CLASS_NAME = ParserErrorCode(
|
||||
'MEMBER_WITH_CLASS_NAME',
|
||||
"A class member can't have the same name as the enclosing class.",
|
||||
correction: "Try renaming the member.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MISSING_ASSIGNABLE_SELECTOR = ParserErrorCode(
|
||||
'MISSING_ASSIGNABLE_SELECTOR',
|
||||
"Missing selector such as '.identifier' or '[0]'.",
|
||||
correction: "Try adding a selector.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MISSING_ASSIGNMENT_IN_INITIALIZER = ParserErrorCode(
|
||||
'MISSING_ASSIGNMENT_IN_INITIALIZER',
|
||||
"Expected an assignment after the field name.",
|
||||
correction: "To initialize a field, use the syntax 'name = value'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MISSING_CATCH_OR_FINALLY = ParserErrorCode(
|
||||
'MISSING_CATCH_OR_FINALLY',
|
||||
"A try block must be followed by an 'on', 'catch', or 'finally' clause.",
|
||||
correction:
|
||||
"Try adding either a catch or finally clause, or remove the try statement.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MISSING_CONST_FINAL_VAR_OR_TYPE = ParserErrorCode(
|
||||
'MISSING_CONST_FINAL_VAR_OR_TYPE',
|
||||
"Variables must be declared using the keywords 'const', 'final', 'var' or a type name.",
|
||||
correction:
|
||||
"Try adding the name of the type of the variable or the keyword 'var'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MISSING_EXPRESSION_IN_THROW = ParserErrorCode(
|
||||
'MISSING_EXPRESSION_IN_THROW',
|
||||
"Missing expression after 'throw'.",
|
||||
correction:
|
||||
"Add an expression after 'throw' or use 'rethrow' to throw a caught exception",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MISSING_INITIALIZER = ParserErrorCode(
|
||||
'MISSING_INITIALIZER',
|
||||
"Expected an initializer.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MISSING_KEYWORD_OPERATOR = ParserErrorCode(
|
||||
'MISSING_KEYWORD_OPERATOR',
|
||||
"Operator declarations must be preceded by the keyword 'operator'.",
|
||||
correction: "Try adding the keyword 'operator'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MISSING_PREFIX_IN_DEFERRED_IMPORT = ParserErrorCode(
|
||||
'MISSING_PREFIX_IN_DEFERRED_IMPORT',
|
||||
"Deferred imports should have a prefix.",
|
||||
correction: "Try adding a prefix to the import by adding an 'as' clause.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MISSING_STATEMENT = ParserErrorCode(
|
||||
'MISSING_STATEMENT',
|
||||
"Expected a statement.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MIXIN_DECLARES_CONSTRUCTOR = ParserErrorCode(
|
||||
'MIXIN_DECLARES_CONSTRUCTOR',
|
||||
"Mixins can't declare constructors.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MODIFIER_OUT_OF_ORDER = ParserErrorCode(
|
||||
'MODIFIER_OUT_OF_ORDER',
|
||||
"The modifier '{0}' should be before the modifier '{1}'.",
|
||||
correction: "Try re-ordering the modifiers.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MULTIPLE_EXTENDS_CLAUSES = ParserErrorCode(
|
||||
'MULTIPLE_EXTENDS_CLAUSES',
|
||||
"Each class definition can have at most one extends clause.",
|
||||
correction:
|
||||
"Try choosing one superclass and define your class to implement (or mix in) the others.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MULTIPLE_LIBRARY_DIRECTIVES = ParserErrorCode(
|
||||
'MULTIPLE_LIBRARY_DIRECTIVES',
|
||||
"Only one library directive may be declared in a file.",
|
||||
correction: "Try removing all but one of the library directives.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MULTIPLE_ON_CLAUSES = ParserErrorCode(
|
||||
'MULTIPLE_ON_CLAUSES',
|
||||
"Each mixin definition can have at most one on clause.",
|
||||
correction: "Try combining all of the on clauses into a single clause.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MULTIPLE_PART_OF_DIRECTIVES = ParserErrorCode(
|
||||
'MULTIPLE_PART_OF_DIRECTIVES',
|
||||
"Only one part-of directive may be declared in a file.",
|
||||
correction: "Try removing all but one of the part-of directives.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MULTIPLE_VARIANCE_MODIFIERS = ParserErrorCode(
|
||||
'MULTIPLE_VARIANCE_MODIFIERS',
|
||||
"Each type parameter can have at most one variance modifier.",
|
||||
correction: "Use at most one of the 'in', 'out', or 'inout' modifiers.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _MULTIPLE_WITH_CLAUSES = ParserErrorCode(
|
||||
'MULTIPLE_WITH_CLAUSES',
|
||||
"Each class definition can have at most one with clause.",
|
||||
correction: "Try combining all of the with clauses into a single clause.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _NATIVE_CLAUSE_SHOULD_BE_ANNOTATION = ParserErrorCode(
|
||||
'NATIVE_CLAUSE_SHOULD_BE_ANNOTATION',
|
||||
"Native clause in this form is deprecated.",
|
||||
correction:
|
||||
"Try removing this native clause and adding @native() or @native('native-name') before the declaration.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _NULL_AWARE_CASCADE_OUT_OF_ORDER = ParserErrorCode(
|
||||
'NULL_AWARE_CASCADE_OUT_OF_ORDER',
|
||||
"The '?..' cascade operator must be first in the cascade sequence.",
|
||||
correction:
|
||||
"Try moving the '?..' operator to be the first cascade operator in the sequence.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _PREFIX_AFTER_COMBINATOR = ParserErrorCode(
|
||||
'PREFIX_AFTER_COMBINATOR',
|
||||
"The prefix ('as' clause) should come before any show/hide combinators.",
|
||||
correction: "Try moving the prefix before the combinators.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _REDIRECTING_CONSTRUCTOR_WITH_BODY = ParserErrorCode(
|
||||
'REDIRECTING_CONSTRUCTOR_WITH_BODY',
|
||||
"Redirecting constructors can't have a body.",
|
||||
correction:
|
||||
"Try removing the body, or not making this a redirecting constructor.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR = ParserErrorCode(
|
||||
'REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR',
|
||||
"Only factory constructor can specify '=' redirection.",
|
||||
correction:
|
||||
"Try making this a factory constructor, or remove the redirection.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _SETTER_CONSTRUCTOR = ParserErrorCode(
|
||||
'SETTER_CONSTRUCTOR',
|
||||
"Constructors can't be a setter.",
|
||||
correction: "Try removing 'set'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _STACK_OVERFLOW = ParserErrorCode(
|
||||
'STACK_OVERFLOW',
|
||||
"The file has too many nested expressions or statements.",
|
||||
correction: "Try simplifying the code.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _STATIC_CONSTRUCTOR = ParserErrorCode(
|
||||
'STATIC_CONSTRUCTOR',
|
||||
"Constructors can't be static.",
|
||||
correction: "Try removing the keyword 'static'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _STATIC_OPERATOR = ParserErrorCode(
|
||||
'STATIC_OPERATOR',
|
||||
"Operators can't be static.",
|
||||
correction: "Try removing the keyword 'static'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _SWITCH_HAS_CASE_AFTER_DEFAULT_CASE = ParserErrorCode(
|
||||
'SWITCH_HAS_CASE_AFTER_DEFAULT_CASE',
|
||||
"The default case should be the last case in a switch statement.",
|
||||
correction: "Try moving the default case after the other case clauses.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _SWITCH_HAS_MULTIPLE_DEFAULT_CASES = ParserErrorCode(
|
||||
'SWITCH_HAS_MULTIPLE_DEFAULT_CASES',
|
||||
"The 'default' case can only be declared once.",
|
||||
correction: "Try removing all but one default case.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _TOP_LEVEL_OPERATOR = ParserErrorCode(
|
||||
'TOP_LEVEL_OPERATOR',
|
||||
"Operators must be declared within a class.",
|
||||
correction:
|
||||
"Try removing the operator, moving it to a class, or converting it to be a function.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _TYPEDEF_IN_CLASS = ParserErrorCode(
|
||||
'TYPEDEF_IN_CLASS',
|
||||
"Typedefs can't be declared inside classes.",
|
||||
correction: "Try moving the typedef to the top-level.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _TYPE_ARGUMENTS_ON_TYPE_VARIABLE = ParserErrorCode(
|
||||
'TYPE_ARGUMENTS_ON_TYPE_VARIABLE',
|
||||
"Can't use type arguments with type variable '{0}'.",
|
||||
correction: "Try removing the type arguments.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _TYPE_BEFORE_FACTORY = ParserErrorCode(
|
||||
'TYPE_BEFORE_FACTORY',
|
||||
"Factory constructors cannot have a return type.",
|
||||
correction: "Try removing the type appearing before 'factory'.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _TYPE_PARAMETER_ON_CONSTRUCTOR = ParserErrorCode(
|
||||
'TYPE_PARAMETER_ON_CONSTRUCTOR',
|
||||
"Constructors can't have type parameters.",
|
||||
correction: "Try removing the type parameters.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _VAR_AND_TYPE = ParserErrorCode(
|
||||
'VAR_AND_TYPE',
|
||||
"Variables can't be declared using both 'var' and a type name.",
|
||||
correction: "Try removing 'var.'",
|
||||
);
|
||||
|
||||
const ParserErrorCode _VAR_AS_TYPE_NAME = ParserErrorCode(
|
||||
'VAR_AS_TYPE_NAME',
|
||||
"The keyword 'var' can't be used as a type name.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _VAR_RETURN_TYPE = ParserErrorCode(
|
||||
'VAR_RETURN_TYPE',
|
||||
"The return type can't be 'var'.",
|
||||
correction:
|
||||
"Try removing the keyword 'var', or replacing it with the name of the return type.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _VOID_WITH_TYPE_ARGUMENTS = ParserErrorCode(
|
||||
'VOID_WITH_TYPE_ARGUMENTS',
|
||||
"Type 'void' can't have type arguments.",
|
||||
correction: "Try removing the type arguments.",
|
||||
);
|
||||
|
||||
const ParserErrorCode _WITH_BEFORE_EXTENDS = ParserErrorCode(
|
||||
'WITH_BEFORE_EXTENDS',
|
||||
"The extends clause must be before the with clause.",
|
||||
correction: "Try moving the extends clause before the with clause.",
|
||||
);
|
|
@ -17335,17 +17335,9 @@ ManifestWarningCode:
|
|||
A code indicating that a specified hardware feature is not supported on
|
||||
Chrome OS.
|
||||
ParserErrorCode:
|
||||
ABSTRACT_CLASS_MEMBER:
|
||||
copyFromCfe: true
|
||||
ABSTRACT_ENUM:
|
||||
problemMessage: "Enums can't be declared to be 'abstract'."
|
||||
correctionMessage: "Try removing the keyword 'abstract'."
|
||||
ABSTRACT_EXTERNAL_FIELD:
|
||||
copyFromCfe: true
|
||||
ABSTRACT_LATE_FIELD:
|
||||
copyFromCfe: true
|
||||
ABSTRACT_STATIC_FIELD:
|
||||
copyFromCfe: true
|
||||
ABSTRACT_STATIC_METHOD:
|
||||
problemMessage: "Static methods can't be declared to be 'abstract'."
|
||||
correctionMessage: "Try removing the keyword 'abstract'."
|
||||
|
@ -17358,64 +17350,24 @@ ParserErrorCode:
|
|||
ABSTRACT_TYPEDEF:
|
||||
problemMessage: "Typedefs can't be declared to be 'abstract'."
|
||||
correctionMessage: "Try removing the keyword 'abstract'."
|
||||
ANNOTATION_ON_TYPE_ARGUMENT:
|
||||
copyFromCfe: true
|
||||
ANNOTATION_WITH_TYPE_ARGUMENTS:
|
||||
copyFromCfe: true
|
||||
ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED:
|
||||
copyFromCfe: true
|
||||
ASYNC_KEYWORD_USED_AS_IDENTIFIER:
|
||||
problemMessage: "The keywords 'await' and 'yield' can't be used as identifiers in an asynchronous or generator function."
|
||||
comment: |-
|
||||
16.32 Identifier Reference: It is a compile-time error if any of the
|
||||
identifiers async, await, or yield is used as an identifier in a function
|
||||
body marked with either async, async, or sync.
|
||||
BINARY_OPERATOR_WRITTEN_OUT:
|
||||
copyFromCfe: true
|
||||
BREAK_OUTSIDE_OF_LOOP:
|
||||
copyFromCfe: true
|
||||
CATCH_SYNTAX:
|
||||
copyFromCfe: true
|
||||
CATCH_SYNTAX_EXTRA_PARAMETERS:
|
||||
copyFromCfe: true
|
||||
CLASS_IN_CLASS:
|
||||
copyFromCfe: true
|
||||
COLON_IN_PLACE_OF_IN:
|
||||
copyFromCfe: true
|
||||
CONFLICTING_MODIFIERS:
|
||||
copyFromCfe: true
|
||||
CONSTRUCTOR_WITH_RETURN_TYPE:
|
||||
copyFromCfe: true
|
||||
CONSTRUCTOR_WITH_TYPE_ARGUMENTS:
|
||||
copyFromCfe: true
|
||||
CONST_AND_FINAL:
|
||||
copyFromCfe: true
|
||||
CONST_CLASS:
|
||||
copyFromCfe: true
|
||||
CONST_CONSTRUCTOR_WITH_BODY:
|
||||
problemMessage: "Const constructors can't have a body."
|
||||
correctionMessage: "Try removing either the 'const' keyword or the body."
|
||||
CONST_ENUM:
|
||||
problemMessage: "Enums can't be declared to be 'const'."
|
||||
correctionMessage: "Try removing the 'const' keyword."
|
||||
CONST_FACTORY:
|
||||
copyFromCfe: true
|
||||
CONST_METHOD:
|
||||
copyFromCfe: true
|
||||
CONST_TYPEDEF:
|
||||
problemMessage: "Type aliases can't be declared to be 'const'."
|
||||
correctionMessage: "Try removing the 'const' keyword."
|
||||
CONTINUE_OUTSIDE_OF_LOOP:
|
||||
copyFromCfe: true
|
||||
CONTINUE_WITHOUT_LABEL_IN_CASE:
|
||||
copyFromCfe: true
|
||||
COVARIANT_AND_STATIC:
|
||||
copyFromCfe: true
|
||||
COVARIANT_CONSTRUCTOR:
|
||||
problemMessage: "A constructor can't be declared to be 'covariant'."
|
||||
correctionMessage: "Try removing the keyword 'covariant'."
|
||||
COVARIANT_MEMBER:
|
||||
copyFromCfe: true
|
||||
COVARIANT_TOP_LEVEL_DECLARATION:
|
||||
problemMessage: "Top-level declarations can't be declared to be covariant."
|
||||
correctionMessage: "Try removing the keyword 'covariant'."
|
||||
|
@ -17450,48 +17402,18 @@ ParserErrorCode:
|
|||
void f(void Function([int p]) g) {
|
||||
}
|
||||
```
|
||||
DEFERRED_AFTER_PREFIX:
|
||||
copyFromCfe: true
|
||||
DIRECTIVE_AFTER_DECLARATION:
|
||||
copyFromCfe: true
|
||||
DUPLICATED_MODIFIER:
|
||||
copyFromCfe: true
|
||||
comment: |-
|
||||
Parameters:
|
||||
0: the modifier that was duplicated
|
||||
DUPLICATE_DEFERRED:
|
||||
copyFromCfe: true
|
||||
DUPLICATE_LABEL_IN_SWITCH_STATEMENT:
|
||||
copyFromCfe: true
|
||||
comment: |-
|
||||
Parameters:
|
||||
0: the label that was duplicated
|
||||
DUPLICATE_PREFIX:
|
||||
copyFromCfe: true
|
||||
EMPTY_ENUM_BODY:
|
||||
problemMessage: An enum must declare at least one constant name.
|
||||
correctionMessage: Try declaring a constant.
|
||||
ENUM_IN_CLASS:
|
||||
copyFromCfe: true
|
||||
EQUALITY_CANNOT_BE_EQUALITY_OPERAND:
|
||||
copyFromCfe: true
|
||||
EXPECTED_BODY:
|
||||
copyFromCfe: true
|
||||
EXPECTED_CASE_OR_DEFAULT:
|
||||
problemMessage: "Expected 'case' or 'default'."
|
||||
correctionMessage: Try placing this code inside a case clause.
|
||||
EXPECTED_CLASS_MEMBER:
|
||||
problemMessage: Expected a class member.
|
||||
correctionMessage: Try placing this code inside a class member.
|
||||
EXPECTED_ELSE_OR_COMMA:
|
||||
copyFromCfe: true
|
||||
EXPECTED_EXECUTABLE:
|
||||
problemMessage: Expected a method, getter, setter or operator declaration.
|
||||
correctionMessage: This appears to be incomplete code. Try removing it or completing it.
|
||||
EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD:
|
||||
copyFromCfe: true
|
||||
EXPECTED_INSTEAD:
|
||||
copyFromCfe: true
|
||||
EXPECTED_LIST_OR_MAP_LITERAL:
|
||||
problemMessage: Expected a list or map literal.
|
||||
correctionMessage: Try inserting a list or map literal, or remove the type arguments.
|
||||
|
@ -17504,133 +17426,21 @@ ParserErrorCode:
|
|||
0: the token that was expected but not found
|
||||
EXPECTED_TYPE_NAME:
|
||||
problemMessage: Expected a type name.
|
||||
EXPERIMENT_NOT_ENABLED:
|
||||
copyFromCfe: true
|
||||
EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE:
|
||||
copyFromCfe: true
|
||||
EXTENSION_DECLARES_ABSTRACT_MEMBER:
|
||||
copyFromCfe: true
|
||||
comment: No parameters.
|
||||
documentation: |-
|
||||
#### Description
|
||||
|
||||
The analyzer produces this diagnostic when an abstract declaration is
|
||||
declared in an extension. Extensions can declare only concrete members.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code produces this diagnostic because the method `a` doesn't
|
||||
have a body:
|
||||
|
||||
```dart
|
||||
extension E on String {
|
||||
int [!a!]();
|
||||
}
|
||||
```
|
||||
|
||||
#### Common fixes
|
||||
|
||||
Either provide an implementation for the member or remove it.
|
||||
EXTENSION_DECLARES_CONSTRUCTOR:
|
||||
copyFromCfe: true
|
||||
comment: No parameters.
|
||||
documentation: |-
|
||||
#### Description
|
||||
|
||||
The analyzer produces this diagnostic when a constructor declaration is
|
||||
found in an extension. It isn't valid to define a constructor because
|
||||
extensions aren't classes, and it isn't possible to create an instance of
|
||||
an extension.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code produces this diagnostic because there is a constructor
|
||||
declaration in `E`:
|
||||
|
||||
```dart
|
||||
extension E on String {
|
||||
[!E!]() : super();
|
||||
}
|
||||
```
|
||||
|
||||
#### Common fixes
|
||||
|
||||
Remove the constructor or replace it with a static method.
|
||||
EXTENSION_DECLARES_INSTANCE_FIELD:
|
||||
copyFromCfe: true
|
||||
comment: No parameters.
|
||||
documentation: |-
|
||||
#### Description
|
||||
|
||||
The analyzer produces this diagnostic when an instance field declaration is
|
||||
found in an extension. It isn't valid to define an instance field because
|
||||
extensions can only add behavior, not state.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code produces this diagnostic because `s` is an instance
|
||||
field:
|
||||
|
||||
```dart
|
||||
%language=2.9
|
||||
extension E on String {
|
||||
String [!s!];
|
||||
}
|
||||
```
|
||||
|
||||
#### Common fixes
|
||||
|
||||
Remove the field, make it a static field, or convert it to be a getter,
|
||||
setter, or method.
|
||||
EXTERNAL_CLASS:
|
||||
copyFromCfe: true
|
||||
EXTERNAL_CONSTRUCTOR_WITH_BODY:
|
||||
copyFromCfe: true
|
||||
EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER:
|
||||
copyFromCfe: true
|
||||
EXTERNAL_ENUM:
|
||||
copyFromCfe: true
|
||||
EXTERNAL_FACTORY_REDIRECTION:
|
||||
copyFromCfe: true
|
||||
EXTERNAL_FACTORY_WITH_BODY:
|
||||
copyFromCfe: true
|
||||
EXTERNAL_FIELD:
|
||||
copyFromCfe: true
|
||||
EXTERNAL_GETTER_WITH_BODY:
|
||||
problemMessage: "External getters can't have a body."
|
||||
correctionMessage: "Try removing the body of the getter, or removing the keyword 'external'."
|
||||
EXTERNAL_LATE_FIELD:
|
||||
copyFromCfe: true
|
||||
EXTERNAL_METHOD_WITH_BODY:
|
||||
copyFromCfe: true
|
||||
EXTERNAL_OPERATOR_WITH_BODY:
|
||||
problemMessage: "External operators can't have a body."
|
||||
correctionMessage: "Try removing the body of the operator, or removing the keyword 'external'."
|
||||
EXTERNAL_SETTER_WITH_BODY:
|
||||
problemMessage: "External setters can't have a body."
|
||||
correctionMessage: "Try removing the body of the setter, or removing the keyword 'external'."
|
||||
EXTERNAL_TYPEDEF:
|
||||
copyFromCfe: true
|
||||
EXTRANEOUS_MODIFIER:
|
||||
copyFromCfe: true
|
||||
FACTORY_TOP_LEVEL_DECLARATION:
|
||||
copyFromCfe: true
|
||||
FACTORY_WITHOUT_BODY:
|
||||
problemMessage: "A non-redirecting 'factory' constructor must have a body."
|
||||
correctionMessage: Try adding a body to the constructor.
|
||||
FACTORY_WITH_INITIALIZERS:
|
||||
problemMessage: "A 'factory' constructor can't have initializers."
|
||||
correctionMessage: "Try removing the 'factory' keyword to make this a generative constructor, or removing the initializers."
|
||||
FIELD_INITIALIZED_OUTSIDE_DECLARING_CLASS:
|
||||
copyFromCfe: true
|
||||
FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR:
|
||||
copyFromCfe: true
|
||||
FINAL_AND_COVARIANT:
|
||||
copyFromCfe: true
|
||||
FINAL_AND_COVARIANT_LATE_WITH_INITIALIZER:
|
||||
copyFromCfe: true
|
||||
FINAL_AND_VAR:
|
||||
copyFromCfe: true
|
||||
FINAL_CLASS:
|
||||
problemMessage: "Classes can't be declared to be 'final'."
|
||||
correctionMessage: "Try removing the keyword 'final'."
|
||||
|
@ -17649,28 +17459,12 @@ ParserErrorCode:
|
|||
FUNCTION_TYPED_PARAMETER_VAR:
|
||||
problemMessage: "Function-typed parameters can't specify 'const', 'final' or 'var' in place of a return type."
|
||||
correctionMessage: Try replacing the keyword with a return type.
|
||||
GETTER_CONSTRUCTOR:
|
||||
copyFromCfe: true
|
||||
GETTER_IN_FUNCTION:
|
||||
problemMessage: "Getters can't be defined within methods or functions."
|
||||
correctionMessage: Try moving the getter outside the method or function, or converting the getter to a function.
|
||||
GETTER_WITH_PARAMETERS:
|
||||
problemMessage: Getters must be declared without a parameter list.
|
||||
correctionMessage: "Try removing the parameter list, or removing the keyword 'get' to define a method rather than a getter."
|
||||
ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE:
|
||||
copyFromCfe: true
|
||||
IMPLEMENTS_BEFORE_EXTENDS:
|
||||
copyFromCfe: true
|
||||
IMPLEMENTS_BEFORE_ON:
|
||||
copyFromCfe: true
|
||||
IMPLEMENTS_BEFORE_WITH:
|
||||
copyFromCfe: true
|
||||
IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE:
|
||||
copyFromCfe: true
|
||||
INITIALIZED_VARIABLE_IN_FOR_EACH:
|
||||
copyFromCfe: true
|
||||
INVALID_AWAIT_IN_FOR:
|
||||
copyFromCfe: true
|
||||
INVALID_CODE_POINT:
|
||||
problemMessage: "The escape sequence '{0}' isn't a valid code point."
|
||||
comment: |-
|
||||
|
@ -17678,23 +17472,12 @@ ParserErrorCode:
|
|||
0: the invalid escape sequence
|
||||
INVALID_COMMENT_REFERENCE:
|
||||
problemMessage: "Comment references should contain a possibly prefixed identifier and can start with 'new', but shouldn't contain anything else."
|
||||
INVALID_CONSTRUCTOR_NAME:
|
||||
copyFromCfe: true
|
||||
INVALID_GENERIC_FUNCTION_TYPE:
|
||||
problemMessage: Invalid generic function type.
|
||||
correctionMessage: "Try using a generic function type (returnType 'Function(' parameters ')')."
|
||||
INVALID_HEX_ESCAPE:
|
||||
copyFromCfe: true
|
||||
INVALID_INITIALIZER:
|
||||
copyFromCfe: true
|
||||
INVALID_LITERAL_IN_CONFIGURATION:
|
||||
problemMessage: "The literal in a configuration can't contain interpolation."
|
||||
correctionMessage: Try removing the interpolation expressions.
|
||||
INVALID_OPERATOR:
|
||||
copyFromCfe: true
|
||||
comment: |-
|
||||
Parameters:
|
||||
0: the operator that is invalid
|
||||
INVALID_OPERATOR_FOR_SUPER:
|
||||
problemMessage: "The operator '{0}' can't be used with 'super'."
|
||||
comment: |-
|
||||
|
@ -17703,83 +17486,24 @@ ParserErrorCode:
|
|||
|
||||
Only generated by the old parser.
|
||||
Replaced by INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER.
|
||||
INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER:
|
||||
copyFromCfe: true
|
||||
INVALID_STAR_AFTER_ASYNC:
|
||||
problemMessage: "The modifier 'async*' isn't allowed for an expression function body."
|
||||
correctionMessage: Try converting the body to a block.
|
||||
INVALID_SUPER_IN_INITIALIZER:
|
||||
copyFromCfe: true
|
||||
INVALID_SYNC:
|
||||
problemMessage: "The modifier 'sync' isn't allowed for an expression function body."
|
||||
correctionMessage: Try converting the body to a block.
|
||||
INVALID_THIS_IN_INITIALIZER:
|
||||
copyFromCfe: true
|
||||
INVALID_UNICODE_ESCAPE:
|
||||
copyFromCfe: true
|
||||
INVALID_USE_OF_COVARIANT_IN_EXTENSION:
|
||||
copyFromCfe: true
|
||||
comment: No parameters.
|
||||
documentation: |-
|
||||
#### Description
|
||||
|
||||
The analyzer produces this diagnostic when a member declared inside an
|
||||
extension uses the keyword `covariant` in the declaration of a parameter.
|
||||
Extensions aren't classes and don't have subclasses, so the keyword serves
|
||||
no purpose.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code produces this diagnostic because `i` is marked as being
|
||||
covariant:
|
||||
|
||||
```dart
|
||||
extension E on String {
|
||||
void a([!covariant!] int i) {}
|
||||
}
|
||||
```
|
||||
|
||||
#### Common fixes
|
||||
|
||||
Remove the `covariant` keyword:
|
||||
|
||||
```dart
|
||||
extension E on String {
|
||||
void a(int i) {}
|
||||
}
|
||||
```
|
||||
LIBRARY_DIRECTIVE_NOT_FIRST:
|
||||
copyFromCfe: true
|
||||
LITERAL_WITH_CLASS:
|
||||
copyFromCfe: true
|
||||
LITERAL_WITH_CLASS_AND_NEW:
|
||||
copyFromCfe: true
|
||||
LITERAL_WITH_NEW:
|
||||
copyFromCfe: true
|
||||
LOCAL_FUNCTION_DECLARATION_MODIFIER:
|
||||
problemMessage: "Local function declarations can't specify any modifiers."
|
||||
correctionMessage: Try removing the modifier.
|
||||
MEMBER_WITH_CLASS_NAME:
|
||||
copyFromCfe: true
|
||||
MISSING_ASSIGNABLE_SELECTOR:
|
||||
copyFromCfe: true
|
||||
MISSING_ASSIGNMENT_IN_INITIALIZER:
|
||||
copyFromCfe: true
|
||||
MISSING_CATCH_OR_FINALLY:
|
||||
copyFromCfe: true
|
||||
MISSING_CLOSING_PARENTHESIS:
|
||||
problemMessage: The closing parenthesis is missing.
|
||||
correctionMessage: Try adding the closing parenthesis.
|
||||
MISSING_CONST_FINAL_VAR_OR_TYPE:
|
||||
copyFromCfe: true
|
||||
MISSING_ENUM_BODY:
|
||||
problemMessage: An enum definition must have a body with at least one constant name.
|
||||
correctionMessage: Try adding a body and defining at least one constant.
|
||||
MISSING_EXPRESSION_IN_INITIALIZER:
|
||||
problemMessage: Expected an expression after the assignment operator.
|
||||
correctionMessage: Try adding the value to be assigned, or remove the assignment operator.
|
||||
MISSING_EXPRESSION_IN_THROW:
|
||||
copyFromCfe: true
|
||||
MISSING_FUNCTION_BODY:
|
||||
problemMessage: A function body must be provided.
|
||||
correctionMessage: Try adding a function body.
|
||||
|
@ -17794,10 +17518,6 @@ ParserErrorCode:
|
|||
correctionMessage: "Try adding the keyword 'get'."
|
||||
MISSING_IDENTIFIER:
|
||||
problemMessage: Expected an identifier.
|
||||
MISSING_INITIALIZER:
|
||||
copyFromCfe: true
|
||||
MISSING_KEYWORD_OPERATOR:
|
||||
copyFromCfe: true
|
||||
MISSING_METHOD_PARAMETERS:
|
||||
problemMessage: Methods must have an explicit list of parameters.
|
||||
correctionMessage: Try adding a parameter list.
|
||||
|
@ -17810,13 +17530,9 @@ ParserErrorCode:
|
|||
MISSING_NAME_IN_PART_OF_DIRECTIVE:
|
||||
problemMessage: Part-of directives must include a library name.
|
||||
correctionMessage: "Try adding a library name after the 'of'."
|
||||
MISSING_PREFIX_IN_DEFERRED_IMPORT:
|
||||
copyFromCfe: true
|
||||
MISSING_STAR_AFTER_SYNC:
|
||||
problemMessage: "The modifier 'sync' must be followed by a star ('*')."
|
||||
correctionMessage: Try removing the modifier, or add a star.
|
||||
MISSING_STATEMENT:
|
||||
copyFromCfe: true
|
||||
MISSING_TERMINATOR_FOR_PARAMETER_GROUP:
|
||||
problemMessage: "There is no '{0}' to close the parameter group."
|
||||
correctionMessage: "Try inserting a '{0}' at the end of the group."
|
||||
|
@ -17832,24 +17548,12 @@ ParserErrorCode:
|
|||
MIXED_PARAMETER_GROUPS:
|
||||
problemMessage: "Can't have both positional and named parameters in a single parameter list."
|
||||
correctionMessage: Try choosing a single style of optional parameters.
|
||||
MIXIN_DECLARES_CONSTRUCTOR:
|
||||
copyFromCfe: true
|
||||
MODIFIER_OUT_OF_ORDER:
|
||||
copyFromCfe: true
|
||||
MULTIPLE_EXTENDS_CLAUSES:
|
||||
copyFromCfe: true
|
||||
MULTIPLE_IMPLEMENTS_CLAUSES:
|
||||
problemMessage: Each class or mixin definition can have at most one implements clause.
|
||||
correctionMessage: Try combining all of the implements clauses into a single clause.
|
||||
MULTIPLE_LIBRARY_DIRECTIVES:
|
||||
copyFromCfe: true
|
||||
MULTIPLE_NAMED_PARAMETER_GROUPS:
|
||||
problemMessage: "Can't have multiple groups of named parameters in a single parameter list."
|
||||
correctionMessage: Try combining all of the groups into a single group.
|
||||
MULTIPLE_ON_CLAUSES:
|
||||
copyFromCfe: true
|
||||
MULTIPLE_PART_OF_DIRECTIVES:
|
||||
copyFromCfe: true
|
||||
MULTIPLE_POSITIONAL_PARAMETER_GROUPS:
|
||||
problemMessage: "Can't have multiple groups of positional parameters in a single parameter list."
|
||||
correctionMessage: Try combining all of the groups into a single group.
|
||||
|
@ -17859,10 +17563,6 @@ ParserErrorCode:
|
|||
comment: |-
|
||||
Parameters:
|
||||
0: the number of variables being declared
|
||||
MULTIPLE_VARIANCE_MODIFIERS:
|
||||
copyFromCfe: true
|
||||
MULTIPLE_WITH_CLAUSES:
|
||||
copyFromCfe: true
|
||||
NAMED_FUNCTION_EXPRESSION:
|
||||
problemMessage: "Function expressions can't be named."
|
||||
correctionMessage: Try removing the name, or moving the function expression to a function declaration statement.
|
||||
|
@ -17875,8 +17575,6 @@ ParserErrorCode:
|
|||
NATIVE_CLAUSE_IN_NON_SDK_CODE:
|
||||
problemMessage: Native clause can only be used in the SDK and code that is loaded through native extensions.
|
||||
correctionMessage: Try removing the native clause.
|
||||
NATIVE_CLAUSE_SHOULD_BE_ANNOTATION:
|
||||
copyFromCfe: true
|
||||
NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE:
|
||||
problemMessage: Native functions can only be declared in the SDK and code that is loaded through native extensions.
|
||||
correctionMessage: "Try removing the word 'native'."
|
||||
|
@ -17900,54 +17598,24 @@ ParserErrorCode:
|
|||
NORMAL_BEFORE_OPTIONAL_PARAMETERS:
|
||||
problemMessage: Normal parameters must occur before optional parameters.
|
||||
correctionMessage: Try moving all of the normal parameters before the optional parameters.
|
||||
NULL_AWARE_CASCADE_OUT_OF_ORDER:
|
||||
copyFromCfe: true
|
||||
POSITIONAL_AFTER_NAMED_ARGUMENT:
|
||||
problemMessage: Positional arguments must occur before named arguments.
|
||||
correctionMessage: Try moving all of the positional arguments before the named arguments.
|
||||
POSITIONAL_PARAMETER_OUTSIDE_GROUP:
|
||||
problemMessage: "Positional parameters must be enclosed in square brackets ('[' and ']')."
|
||||
correctionMessage: Try surrounding the positional parameters in square brackets.
|
||||
PREFIX_AFTER_COMBINATOR:
|
||||
copyFromCfe: true
|
||||
REDIRECTING_CONSTRUCTOR_WITH_BODY:
|
||||
copyFromCfe: true
|
||||
REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR:
|
||||
copyFromCfe: true
|
||||
SETTER_CONSTRUCTOR:
|
||||
copyFromCfe: true
|
||||
SETTER_IN_FUNCTION:
|
||||
problemMessage: "Setters can't be defined within methods or functions."
|
||||
correctionMessage: Try moving the setter outside the method or function.
|
||||
STACK_OVERFLOW:
|
||||
copyFromCfe: true
|
||||
STATIC_CONSTRUCTOR:
|
||||
copyFromCfe: true
|
||||
STATIC_GETTER_WITHOUT_BODY:
|
||||
problemMessage: "A 'static' getter must have a body."
|
||||
correctionMessage: "Try adding a body to the getter, or removing the keyword 'static'."
|
||||
STATIC_OPERATOR:
|
||||
copyFromCfe: true
|
||||
STATIC_SETTER_WITHOUT_BODY:
|
||||
problemMessage: "A 'static' setter must have a body."
|
||||
correctionMessage: "Try adding a body to the setter, or removing the keyword 'static'."
|
||||
STATIC_TOP_LEVEL_DECLARATION:
|
||||
problemMessage: "Top-level declarations can't be declared to be static."
|
||||
correctionMessage: "Try removing the keyword 'static'."
|
||||
SWITCH_HAS_CASE_AFTER_DEFAULT_CASE:
|
||||
copyFromCfe: true
|
||||
SWITCH_HAS_MULTIPLE_DEFAULT_CASES:
|
||||
copyFromCfe: true
|
||||
TOP_LEVEL_OPERATOR:
|
||||
copyFromCfe: true
|
||||
TYPEDEF_IN_CLASS:
|
||||
copyFromCfe: true
|
||||
TYPE_ARGUMENTS_ON_TYPE_VARIABLE:
|
||||
copyFromCfe: true
|
||||
TYPE_BEFORE_FACTORY:
|
||||
copyFromCfe: true
|
||||
TYPE_PARAMETER_ON_CONSTRUCTOR:
|
||||
copyFromCfe: true
|
||||
TYPE_PARAMETER_ON_OPERATOR:
|
||||
problemMessage: "Types parameters aren't allowed when defining an operator."
|
||||
correctionMessage: Try removing the type parameters.
|
||||
|
@ -17966,25 +17634,15 @@ ParserErrorCode:
|
|||
comment: |-
|
||||
Parameters:
|
||||
0: the unexpected text that was found
|
||||
VAR_AND_TYPE:
|
||||
copyFromCfe: true
|
||||
VAR_AS_TYPE_NAME:
|
||||
copyFromCfe: true
|
||||
VAR_CLASS:
|
||||
problemMessage: "Classes can't be declared to be 'var'."
|
||||
correctionMessage: "Try removing the keyword 'var'."
|
||||
VAR_ENUM:
|
||||
problemMessage: "Enums can't be declared to be 'var'."
|
||||
correctionMessage: "Try removing the keyword 'var'."
|
||||
VAR_RETURN_TYPE:
|
||||
copyFromCfe: true
|
||||
VAR_TYPEDEF:
|
||||
problemMessage: "Typedefs can't be declared to be 'var'."
|
||||
correctionMessage: "Try removing the keyword 'var', or replacing it with the name of the return type."
|
||||
VOID_WITH_TYPE_ARGUMENTS:
|
||||
copyFromCfe: true
|
||||
WITH_BEFORE_EXTENDS:
|
||||
copyFromCfe: true
|
||||
WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER:
|
||||
problemMessage: "The default value of a positional parameter should be preceded by '='."
|
||||
correctionMessage: "Try replacing the ':' with '='."
|
||||
|
|
|
@ -43,7 +43,7 @@ List<CodePath> computeCodePaths() {
|
|||
[analyzerPath, 'lib', 'src', 'pubspec', 'pubspec_warning_code.g.dart'],
|
||||
], [
|
||||
null,
|
||||
[analyzerPath, 'lib', 'src', 'dart', 'error', 'syntactic_errors.g.dart'],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
]);
|
||||
|
|
|
@ -128,13 +128,6 @@ class ErrorCodeInfo {
|
|||
/// error in code generated output.
|
||||
final String? comment;
|
||||
|
||||
/// `true` if this error should be copied from an error in the CFE. The
|
||||
/// purpose of this field is so that the documentation for the error can exist
|
||||
/// in the analyzer's messages.yaml file but the error text can come from the
|
||||
/// CFE's messages.yaml file. TODO(paulberry): add support for documentation
|
||||
/// to the CFE's messages.yaml file so that this isn't necessary.
|
||||
final bool copyFromCfe;
|
||||
|
||||
/// If the error code has an associated correctionMessage, the template for
|
||||
/// it.
|
||||
final String? correctionMessage;
|
||||
|
@ -153,9 +146,8 @@ class ErrorCodeInfo {
|
|||
/// Indicates whether this error is caused by an unresolved identifier.
|
||||
final bool isUnresolvedIdentifier;
|
||||
|
||||
/// The problemMessage for the error code, or `null` if [copyFromCfe] is
|
||||
/// `true`.
|
||||
final String? problemMessage;
|
||||
/// The problemMessage for the error code.
|
||||
final String problemMessage;
|
||||
|
||||
/// If present, indicates that this error code has a special name for
|
||||
/// presentation to the user, that is potentially shared with other error
|
||||
|
@ -165,40 +157,26 @@ class ErrorCodeInfo {
|
|||
ErrorCodeInfo(
|
||||
{this.analyzerCode = const [],
|
||||
this.comment,
|
||||
this.copyFromCfe = false,
|
||||
this.documentation,
|
||||
this.hasPublishedDocs = false,
|
||||
this.index,
|
||||
this.isUnresolvedIdentifier = false,
|
||||
this.sharedName,
|
||||
this.problemMessage,
|
||||
this.correctionMessage}) {
|
||||
if (copyFromCfe) {
|
||||
if (problemMessage != null) {
|
||||
throw "Error codes marked `copyFromCfe: true` can't have a "
|
||||
"problemMessage.";
|
||||
}
|
||||
} else {
|
||||
if (problemMessage == null) {
|
||||
throw 'Error codes must have a problemMessage unless they are marked '
|
||||
'`copyFromCfe: true`.';
|
||||
}
|
||||
}
|
||||
}
|
||||
required this.problemMessage,
|
||||
this.correctionMessage});
|
||||
|
||||
/// Decodes an [ErrorCodeInfo] object from its YAML representation.
|
||||
ErrorCodeInfo.fromYaml(Map<Object?, Object?> yaml)
|
||||
: this(
|
||||
analyzerCode: _decodeAnalyzerCode(yaml['analyzerCode']),
|
||||
comment: yaml['comment'] as String?,
|
||||
copyFromCfe: yaml['copyFromCfe'] as bool? ?? false,
|
||||
correctionMessage: yaml['correctionMessage'] as String?,
|
||||
documentation: yaml['documentation'] as String?,
|
||||
hasPublishedDocs: yaml['hasPublishedDocs'] as bool? ?? false,
|
||||
index: yaml['index'] as int?,
|
||||
isUnresolvedIdentifier:
|
||||
yaml['isUnresolvedIdentifier'] as bool? ?? false,
|
||||
problemMessage: yaml['problemMessage'] as String?,
|
||||
problemMessage: yaml['problemMessage'] as String,
|
||||
sharedName: yaml['sharedName'] as String?);
|
||||
|
||||
/// Generates a dart declaration for this error code, suitable for inclusion
|
||||
|
@ -210,7 +188,7 @@ class ErrorCodeInfo {
|
|||
out.writeln("'${sharedName ?? errorCode}',");
|
||||
final placeholderToIndexMap = _computePlaceholderToIndexMap();
|
||||
out.writeln(
|
||||
json.encode(_convertTemplate(placeholderToIndexMap, problemMessage!)) +
|
||||
json.encode(_convertTemplate(placeholderToIndexMap, problemMessage)) +
|
||||
',');
|
||||
final correctionMessage = this.correctionMessage;
|
||||
if (correctionMessage is String) {
|
||||
|
@ -254,11 +232,10 @@ class ErrorCodeInfo {
|
|||
|
||||
/// Encodes this object into a YAML representation.
|
||||
Map<Object?, Object?> toYaml() => {
|
||||
if (copyFromCfe) 'copyFromCfe': true,
|
||||
if (sharedName != null) 'sharedName': sharedName,
|
||||
if (analyzerCode.isNotEmpty)
|
||||
'analyzerCode': _encodeAnalyzerCode(analyzerCode),
|
||||
if (problemMessage != null) 'problemMessage': problemMessage,
|
||||
'problemMessage': problemMessage,
|
||||
if (correctionMessage != null) 'correctionMessage': correctionMessage,
|
||||
if (isUnresolvedIdentifier) 'isUnresolvedIdentifier': true,
|
||||
if (hasPublishedDocs) 'hasPublishedDocs': true,
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
// TODO(paulberry): once code generation is in place, remove this script.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer/dart/analysis/utilities.dart';
|
||||
|
@ -27,29 +26,14 @@ import 'error_code_info.dart';
|
|||
|
||||
main() {
|
||||
var errorDeclarations = _findErrorDeclarations();
|
||||
var generatedAnalyzerCodes = _computeGeneratedAnalyzerCodes();
|
||||
var errorCodesByClass = _findErrorCodesByClass();
|
||||
_generateYaml(errorCodesByClass, errorDeclarations, generatedAnalyzerCodes);
|
||||
_generateYaml(errorCodesByClass, errorDeclarations);
|
||||
}
|
||||
|
||||
/// The path to the `analyzer` package.
|
||||
final String _analyzerPkgPath =
|
||||
normalize(join(pkg_root.packageRoot, 'analyzer'));
|
||||
|
||||
/// The path to the `analyzer` package.
|
||||
final String _frontEndPkgPath =
|
||||
normalize(join(pkg_root.packageRoot, 'front_end'));
|
||||
|
||||
/// Computes the set of `ParserErrorCode`s that are generated based on
|
||||
/// `pkg/front_end/messages.yaml`.
|
||||
Set<String> _computeGeneratedAnalyzerCodes() {
|
||||
Map<dynamic, dynamic> messagesYaml = loadYaml(
|
||||
File(join(_frontEndPkgPath, 'messages.yaml')).readAsStringSync());
|
||||
var messages = decodeCfeMessagesYaml(messagesYaml);
|
||||
var tables = CfeToAnalyzerErrorCodeTables(messages);
|
||||
return tables.infoToAnalyzerCode.values.toSet();
|
||||
}
|
||||
|
||||
/// Encodes [yaml] into a string parseable as YAML.
|
||||
///
|
||||
/// YAML is complex and we are just trying to do a good enough job for a one
|
||||
|
@ -205,10 +189,8 @@ Map<String, Map<String, VariableDeclaration>> _findErrorDeclarations() {
|
|||
/// [_findErrorCodesByClass]) and [errorDeclarations] (obtained from
|
||||
/// [_findErrorDeclarations]) into a YAML representation of the errors, and
|
||||
/// prints the resulting YAML.
|
||||
void _generateYaml(
|
||||
Map<String, List<ErrorCode>> errorCodesByClass,
|
||||
Map<String, Map<String, VariableDeclaration>> errorDeclarations,
|
||||
Set<String> generatedAnalyzerCodes) {
|
||||
void _generateYaml(Map<String, List<ErrorCode>> errorCodesByClass,
|
||||
Map<String, Map<String, VariableDeclaration>> errorDeclarations) {
|
||||
var yaml = <String, Map<String, Object?>>{};
|
||||
for (var entry in errorCodesByClass.entries) {
|
||||
var yamlCodes = <String, Object?>{};
|
||||
|
@ -239,27 +221,15 @@ void _generateYaml(
|
|||
var commentInfo = _extractCommentInfo(fieldDeclaration);
|
||||
var documentationComment = commentInfo.documentationComment;
|
||||
var otherComment = commentInfo.otherComment;
|
||||
ErrorCodeInfo errorCodeInfo;
|
||||
if (className == 'ParserErrorCode' &&
|
||||
generatedAnalyzerCodes.contains(name)) {
|
||||
if (uniqueNameSuffix != name) {
|
||||
throw "Auto-generated parser error codes can't be aliased";
|
||||
}
|
||||
errorCodeInfo = ErrorCodeInfo(
|
||||
copyFromCfe: true,
|
||||
comment: documentationComment,
|
||||
documentation: otherComment);
|
||||
} else {
|
||||
errorCodeInfo = ErrorCodeInfo(
|
||||
sharedName: uniqueNameSuffix == name ? null : name,
|
||||
problemMessage: code.message,
|
||||
correctionMessage: code.correction,
|
||||
isUnresolvedIdentifier: code.isUnresolvedIdentifier,
|
||||
hasPublishedDocs: code.hasPublishedDocs,
|
||||
comment: documentationComment,
|
||||
documentation: otherComment);
|
||||
}
|
||||
yamlCodes[uniqueNameSuffix] = errorCodeInfo.toYaml();
|
||||
yamlCodes[uniqueNameSuffix] = ErrorCodeInfo(
|
||||
sharedName: uniqueNameSuffix == name ? null : name,
|
||||
problemMessage: code.message,
|
||||
correctionMessage: code.correction,
|
||||
isUnresolvedIdentifier: code.isUnresolvedIdentifier,
|
||||
hasPublishedDocs: code.hasPublishedDocs,
|
||||
comment: documentationComment,
|
||||
documentation: otherComment)
|
||||
.toYaml();
|
||||
}
|
||||
}
|
||||
String encodedYaml = _encodeYaml(yaml);
|
||||
|
|
|
@ -29,7 +29,6 @@ main() async {
|
|||
await GeneratedContent.generateAll(analyzerPkgPath, allTargets);
|
||||
|
||||
_SyntacticErrorGenerator()
|
||||
..generateFormatCode()
|
||||
..checkForManualChanges()
|
||||
..printSummary();
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ const List<_ErrorClassInfo> _errorClasses = [
|
|||
type: 'HINT',
|
||||
extraImports: ['package:analyzer/src/error/analyzer_error_code.dart']),
|
||||
_ErrorClassInfo(
|
||||
// TODO(paulberry): merge with `syntactic_errors.g.dart`.
|
||||
// TODO(paulberry): rename to `syntactic_errors.g.dart`.
|
||||
filePath: 'lib/src/dart/error/syntactic_errors.analyzer.g.dart',
|
||||
name: 'ParserErrorCode',
|
||||
type: 'SYNTACTIC_ERROR',
|
||||
|
@ -101,16 +100,7 @@ const List<_ErrorClassInfo> _errorClasses = [
|
|||
];
|
||||
|
||||
/// A list of all targets generated by this code generator.
|
||||
final List<GeneratedContent> allTargets = <GeneratedContent>[
|
||||
GeneratedFile('lib/src/dart/error/syntactic_errors.g.dart',
|
||||
(String pkgPath) async {
|
||||
final codeGenerator = _SyntacticErrorGenerator();
|
||||
|
||||
codeGenerator.generateFormatCode();
|
||||
return codeGenerator.out.toString();
|
||||
}),
|
||||
..._analyzerGeneratedFiles(),
|
||||
];
|
||||
final List<GeneratedContent> allTargets = _analyzerGeneratedFiles();
|
||||
|
||||
/// The path to the `analyzer` package.
|
||||
final String analyzerPkgPath =
|
||||
|
@ -124,6 +114,9 @@ final String frontEndPkgPath =
|
|||
final Map<String, Map<String, ErrorCodeInfo>> _analyzerMessages =
|
||||
_loadAnalyzerMessages();
|
||||
|
||||
/// Decoded messages from the front end's `messages.yaml` file.
|
||||
final Map<String, ErrorCodeInfo> _frontEndMessages = _loadFrontEndMessages();
|
||||
|
||||
/// Generates a list of [GeneratedContent] objects describing all the analyzer
|
||||
/// files that need to be generated.
|
||||
List<GeneratedContent> _analyzerGeneratedFiles() {
|
||||
|
@ -148,9 +141,18 @@ Map<String, Map<String, ErrorCodeInfo>> _loadAnalyzerMessages() {
|
|||
return decodeAnalyzerMessagesYaml(messagesYaml);
|
||||
}
|
||||
|
||||
/// Loads front end messages from the front end's `messages.yaml` file.
|
||||
Map<String, ErrorCodeInfo> _loadFrontEndMessages() {
|
||||
Map<dynamic, dynamic> messagesYaml =
|
||||
loadYaml(File(join(frontEndPkgPath, 'messages.yaml')).readAsStringSync());
|
||||
return decodeCfeMessagesYaml(messagesYaml);
|
||||
}
|
||||
|
||||
/// Code generator for analyzer error classes.
|
||||
class _AnalyzerErrorGenerator {
|
||||
final List<_ErrorClassInfo> errorClasses;
|
||||
final CfeToAnalyzerErrorCodeTables tables =
|
||||
CfeToAnalyzerErrorCodeTables(_frontEndMessages);
|
||||
final out = StringBuffer('''
|
||||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -166,45 +168,42 @@ class _AnalyzerErrorGenerator {
|
|||
|
||||
void generate() {
|
||||
var imports = {'package:analyzer/error/error.dart'};
|
||||
var parts = <String>{};
|
||||
bool shouldGenerateFastaAnalyzerErrorCodes = false;
|
||||
for (var errorClass in errorClasses) {
|
||||
imports.addAll(errorClass.extraImports);
|
||||
if (errorClass.includeCfeMessages) {
|
||||
parts.add('syntactic_errors.g.dart');
|
||||
shouldGenerateFastaAnalyzerErrorCodes = true;
|
||||
}
|
||||
}
|
||||
out.writeln();
|
||||
for (var importPath in imports.toList()..sort()) {
|
||||
out.writeln("import ${json.encode(importPath)};");
|
||||
}
|
||||
if (parts.isNotEmpty) {
|
||||
out.writeln();
|
||||
for (var partPath in parts.toList()..sort()) {
|
||||
out.writeln("part ${json.encode(partPath)};");
|
||||
}
|
||||
}
|
||||
out.writeln();
|
||||
out.writeln("// It is hard to visually separate each code's _doc comment_ "
|
||||
"from its published");
|
||||
out.writeln('// _documentation comment_ when each is written as an '
|
||||
'end-of-line comment.');
|
||||
out.writeln('// ignore_for_file: slash_for_doc_comments');
|
||||
if (shouldGenerateFastaAnalyzerErrorCodes) {
|
||||
out.writeln();
|
||||
_generateFastaAnalyzerErrorCodeList();
|
||||
}
|
||||
for (var errorClass in errorClasses.toList()
|
||||
..sort((a, b) => a.name.compareTo(b.name))) {
|
||||
out.writeln();
|
||||
out.write('class ${errorClass.name} extends ${errorClass.superclass} {');
|
||||
for (var entry in _analyzerMessages[errorClass.name]!.entries.toList()
|
||||
..sort((a, b) => a.key.compareTo(b.key))) {
|
||||
var entries = [
|
||||
..._analyzerMessages[errorClass.name]!.entries,
|
||||
if (errorClass.includeCfeMessages) ...tables.analyzerCodeToInfo.entries
|
||||
];
|
||||
for (var entry in entries..sort((a, b) => a.key.compareTo(b.key))) {
|
||||
var errorName = entry.key;
|
||||
var errorCodeInfo = entry.value;
|
||||
out.writeln();
|
||||
out.write(errorCodeInfo.toAnalyzerComments(indent: ' '));
|
||||
out.writeln(' static const ${errorClass.name} $errorName =');
|
||||
if (errorCodeInfo.copyFromCfe) {
|
||||
out.writeln(' _$errorName;');
|
||||
} else {
|
||||
out.writeln(errorCodeInfo.toAnalyzerCode(errorClass.name, errorName));
|
||||
}
|
||||
out.writeln(errorCodeInfo.toAnalyzerCode(errorClass.name, errorName));
|
||||
}
|
||||
out.writeln();
|
||||
out.writeln('/// Initialize a newly created error code to have the given '
|
||||
|
@ -232,6 +231,15 @@ class _AnalyzerErrorGenerator {
|
|||
out.writeln('}');
|
||||
}
|
||||
}
|
||||
|
||||
void _generateFastaAnalyzerErrorCodeList() {
|
||||
out.writeln('final fastaAnalyzerErrorCodes = <ErrorCode?>[');
|
||||
for (var entry in tables.indexToInfo) {
|
||||
var name = tables.infoToAnalyzerCode[entry];
|
||||
out.writeln('${name == null ? 'null' : 'ParserErrorCode.$name'},');
|
||||
}
|
||||
out.writeln('];');
|
||||
}
|
||||
}
|
||||
|
||||
class _ErrorClassInfo {
|
||||
|
@ -276,16 +284,6 @@ class _SyntacticErrorGenerator {
|
|||
final Map<String, Map<String, ErrorCodeInfo>> analyzerMessages;
|
||||
final String errorConverterSource;
|
||||
final String parserSource;
|
||||
final out = StringBuffer('''
|
||||
//
|
||||
// THIS FILE IS GENERATED. DO NOT EDIT.
|
||||
//
|
||||
// Instead modify 'pkg/front_end/messages.yaml' and run
|
||||
// 'dart pkg/analyzer/tool/messages/generate.dart' to update.
|
||||
|
||||
part of 'syntactic_errors.analyzer.g.dart';
|
||||
|
||||
''');
|
||||
|
||||
factory _SyntacticErrorGenerator() {
|
||||
String frontEndPkgPath = normalize(join(pkg_root.packageRoot, 'front_end'));
|
||||
|
@ -341,43 +339,17 @@ part of 'syntactic_errors.analyzer.g.dart';
|
|||
}
|
||||
}
|
||||
|
||||
void generateErrorCodes() {
|
||||
final entryMap = tables.analyzerCodeToInfo;
|
||||
for (var errorCode in entryMap.keys.toList()..sort()) {
|
||||
final entry = entryMap[errorCode]!;
|
||||
final className = 'ParserErrorCode';
|
||||
out.writeln();
|
||||
out.writeln('const $className _$errorCode =');
|
||||
out.writeln(entry.toAnalyzerCode(className, errorCode));
|
||||
}
|
||||
}
|
||||
|
||||
void generateFastaAnalyzerErrorCodeList() {
|
||||
out.writeln('final fastaAnalyzerErrorCodes = <ErrorCode?>[');
|
||||
for (var entry in tables.indexToInfo) {
|
||||
var name = tables.infoToAnalyzerCode[entry];
|
||||
out.writeln('${name == null ? 'null' : '_$name'},');
|
||||
}
|
||||
out.writeln('];');
|
||||
}
|
||||
|
||||
void generateFormatCode() {
|
||||
generateFastaAnalyzerErrorCodeList();
|
||||
generateErrorCodes();
|
||||
}
|
||||
|
||||
void printSummary() {
|
||||
// Build a map of error message to ParserErrorCode
|
||||
final messageToName = <String, String>{};
|
||||
for (var entry in analyzerMessages['ParserErrorCode']!.entries) {
|
||||
if (entry.value.copyFromCfe) continue;
|
||||
String message =
|
||||
entry.value.problemMessage!.replaceAll(RegExp(r'\{\d+\}'), '');
|
||||
entry.value.problemMessage.replaceAll(RegExp(r'\{\d+\}'), '');
|
||||
messageToName[message] = entry.key;
|
||||
}
|
||||
|
||||
String messageFromEntryTemplate(ErrorCodeInfo entry) {
|
||||
String problemMessage = entry.problemMessage!;
|
||||
String problemMessage = entry.problemMessage;
|
||||
String message = problemMessage.replaceAll(RegExp(r'#\w+'), '');
|
||||
return message;
|
||||
}
|
||||
|
@ -453,7 +425,7 @@ part of 'syntactic_errors.analyzer.g.dart';
|
|||
// TODO(paulberry): handle multiple analyzer codes
|
||||
if (entry.index == null && entry.analyzerCode.length == 1) {
|
||||
analyzerCode = entry.analyzerCode.single;
|
||||
problemMessage = entry.problemMessage!;
|
||||
problemMessage = entry.problemMessage;
|
||||
}
|
||||
}
|
||||
print(' ${fastaErrorCode.padRight(30)} --> $analyzerCode'
|
||||
|
|
|
@ -50,6 +50,12 @@
|
|||
# which will be used when generating code in Analyzer for translating
|
||||
# fasta error codes to Analyzer error codes.
|
||||
#
|
||||
# Errors with an `index` can also optionally contain user-facing documentation
|
||||
# for the problem (documentation), which will be extracted to
|
||||
# `pkg/analyzer/tool/diagnostics/diagnostics.md`, as well as internal
|
||||
# documentation (comment), which will be included in the code generated for the
|
||||
# analyzer.
|
||||
#
|
||||
# In some cases a message is internal to the frontend, and no meaningful
|
||||
# analyzer code can be provided. In such cases set `frontendInternal: true`.
|
||||
#
|
||||
|
@ -829,6 +835,9 @@ DuplicatedModifier:
|
|||
problemMessage: "The modifier '#lexeme' was already specified."
|
||||
correctionMessage: "Try removing all but one occurrence of the modifier."
|
||||
analyzerCode: ParserErrorCode.DUPLICATED_MODIFIER
|
||||
comment: |-
|
||||
Parameters:
|
||||
0: the modifier that was duplicated
|
||||
script:
|
||||
- "class C { const const m; }"
|
||||
- "class C { external external f(); }"
|
||||
|
@ -972,6 +981,35 @@ ExtraneousModifierInExtension:
|
|||
correctionMessage: "Try removing '#lexeme'."
|
||||
analyzerCode: ParserErrorCode.INVALID_USE_OF_COVARIANT_IN_EXTENSION
|
||||
hasPublishedDocs: true
|
||||
comment: No parameters.
|
||||
documentation: |-
|
||||
#### Description
|
||||
|
||||
The analyzer produces this diagnostic when a member declared inside an
|
||||
extension uses the keyword `covariant` in the declaration of a parameter.
|
||||
Extensions aren't classes and don't have subclasses, so the keyword serves
|
||||
no purpose.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code produces this diagnostic because `i` is marked as being
|
||||
covariant:
|
||||
|
||||
```dart
|
||||
extension E on String {
|
||||
void a([!covariant!] int i) {}
|
||||
}
|
||||
```
|
||||
|
||||
#### Common fixes
|
||||
|
||||
Remove the `covariant` keyword:
|
||||
|
||||
```dart
|
||||
extension E on String {
|
||||
void a(int i) {}
|
||||
}
|
||||
```
|
||||
script:
|
||||
- "extension on String { foo(covariant String child) {} }"
|
||||
|
||||
|
@ -1119,6 +1157,9 @@ DuplicateLabelInSwitchStatement:
|
|||
problemMessage: "The label '#name' was already used in this switch statement."
|
||||
correctionMessage: "Try choosing a different name for this label."
|
||||
analyzerCode: ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT
|
||||
comment: |-
|
||||
Parameters:
|
||||
0: the label that was duplicated
|
||||
statement:
|
||||
- "switch (0) {l1: case 0: break; l1: case 1: break;}"
|
||||
|
||||
|
@ -2191,6 +2232,27 @@ ExtensionDeclaresAbstractMember:
|
|||
problemMessage: "Extensions can't declare abstract members."
|
||||
correctionMessage: "Try providing an implementation for the member."
|
||||
analyzerCode: ParserErrorCode.EXTENSION_DECLARES_ABSTRACT_MEMBER
|
||||
comment: No parameters.
|
||||
documentation: |-
|
||||
#### Description
|
||||
|
||||
The analyzer produces this diagnostic when an abstract declaration is
|
||||
declared in an extension. Extensions can declare only concrete members.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code produces this diagnostic because the method `a` doesn't
|
||||
have a body:
|
||||
|
||||
```dart
|
||||
extension E on String {
|
||||
int [!a!]();
|
||||
}
|
||||
```
|
||||
|
||||
#### Common fixes
|
||||
|
||||
Either provide an implementation for the member or remove it.
|
||||
hasPublishedDocs: true
|
||||
|
||||
ExtensionDeclaresConstructor:
|
||||
|
@ -2198,6 +2260,29 @@ ExtensionDeclaresConstructor:
|
|||
problemMessage: "Extensions can't declare constructors."
|
||||
correctionMessage: "Try removing the constructor declaration."
|
||||
analyzerCode: ParserErrorCode.EXTENSION_DECLARES_CONSTRUCTOR
|
||||
comment: No parameters.
|
||||
documentation: |-
|
||||
#### Description
|
||||
|
||||
The analyzer produces this diagnostic when a constructor declaration is
|
||||
found in an extension. It isn't valid to define a constructor because
|
||||
extensions aren't classes, and it isn't possible to create an instance of
|
||||
an extension.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code produces this diagnostic because there is a constructor
|
||||
declaration in `E`:
|
||||
|
||||
```dart
|
||||
extension E on String {
|
||||
[!E!]() : super();
|
||||
}
|
||||
```
|
||||
|
||||
#### Common fixes
|
||||
|
||||
Remove the constructor or replace it with a static method.
|
||||
hasPublishedDocs: true
|
||||
|
||||
ExtensionDeclaresInstanceField:
|
||||
|
@ -2205,6 +2290,30 @@ ExtensionDeclaresInstanceField:
|
|||
problemMessage: "Extensions can't declare instance fields"
|
||||
correctionMessage: "Try removing the field declaration or making it a static field"
|
||||
analyzerCode: ParserErrorCode.EXTENSION_DECLARES_INSTANCE_FIELD
|
||||
comment: No parameters.
|
||||
documentation: |-
|
||||
#### Description
|
||||
|
||||
The analyzer produces this diagnostic when an instance field declaration is
|
||||
found in an extension. It isn't valid to define an instance field because
|
||||
extensions can only add behavior, not state.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code produces this diagnostic because `s` is an instance
|
||||
field:
|
||||
|
||||
```dart
|
||||
%language=2.9
|
||||
extension E on String {
|
||||
String [!s!];
|
||||
}
|
||||
```
|
||||
|
||||
#### Common fixes
|
||||
|
||||
Remove the field, make it a static field, or convert it to be a getter,
|
||||
setter, or method.
|
||||
hasPublishedDocs: true
|
||||
|
||||
ConflictsWithConstructor:
|
||||
|
@ -3019,6 +3128,9 @@ InvalidOperator:
|
|||
index: 39
|
||||
problemMessage: "The string '#lexeme' isn't a user-definable operator."
|
||||
analyzerCode: ParserErrorCode.INVALID_OPERATOR
|
||||
comment: |-
|
||||
Parameters:
|
||||
0: the operator that is invalid
|
||||
script:
|
||||
- "class C { void operator %=(x) {} }"
|
||||
|
||||
|
|
|
@ -386,6 +386,19 @@ class MessageTestSuite extends ChainContext {
|
|||
}
|
||||
break;
|
||||
|
||||
case "documentation":
|
||||
if (value is! String) {
|
||||
throw new ArgumentError(
|
||||
'documentation should be a string: $value.');
|
||||
}
|
||||
break;
|
||||
|
||||
case "comment":
|
||||
if (value is! String) {
|
||||
throw new ArgumentError('comment should be a string: $value.');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
unknownKeys.add(key);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue