From 75deedf3f44d9f47604f08456408acd251ec92d6 Mon Sep 17 00:00:00 2001 From: Brian Wilkerson Date: Thu, 19 Jul 2018 20:45:48 +0000 Subject: [PATCH] Fix more error code mappings Change-Id: I01a340d9a6abac7c10c0a6431251694b04658e9d Reviewed-on: https://dart-review.googlesource.com/65785 Reviewed-by: Konstantin Shcheglov Commit-Queue: Brian Wilkerson --- pkg/analyzer/lib/error/error.dart | 1 + pkg/analyzer/lib/src/error/codes.dart | 3 ++ .../lib/src/fasta/fasta_codes_generated.dart | 29 +++++++++++++++++++ .../lib/src/fasta/kernel/body_builder.dart | 6 ++-- pkg/front_end/messages.status | 5 +--- pkg/front_end/messages.yaml | 14 +++++++++ 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart index 33976be77c6..3752f750361 100644 --- a/pkg/analyzer/lib/error/error.dart +++ b/pkg/analyzer/lib/error/error.dart @@ -173,6 +173,7 @@ const List errorCodeValues = const [ CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS, CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC, + CompileTimeErrorCode.INVALID_INITIALIZER, CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR, CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER, CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS, diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart index 465e9f0aa55..4963c4724aa 100644 --- a/pkg/analyzer/lib/src/error/codes.dart +++ b/pkg/analyzer/lib/src/error/codes.dart @@ -1480,6 +1480,9 @@ class CompileTimeErrorCode extends ErrorCode { correction: "Try using a different name, or " "remove the modifier on the function body."); + static const CompileTimeErrorCode INVALID_INITIALIZER = + const CompileTimeErrorCode.fromFasta('INVALID_INITIALIZER'); + /** * 9. Functions: It is a compile-time error if an async, async* or sync* * modifier is attached to the body of a setter or constructor. 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 cb8fe0f774f..7212a14cee4 100644 --- a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart +++ b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart @@ -812,6 +812,8 @@ const Template const Code codeConflictsWithSetterWarning = const Code( "ConflictsWithSetterWarning", templateConflictsWithSetterWarning, + analyzerCode: "CONFLICTS_WITH_MEMBER", + dart2jsCode: "*fatal*", severity: Severity.errorLegacyWarning); // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. @@ -3425,6 +3427,26 @@ const MessageCode messageInitializedVariableInForEach = const MessageCode( tip: r"""Try removing the initializer, or using a different kind of loop."""); +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Template + templateInitializerForStaticField = + const Template( + messageTemplate: r"""'#name' isn't an instance field of this class.""", + withArguments: _withArgumentsInitializerForStaticField); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code codeInitializerForStaticField = + const Code( + "InitializerForStaticField", templateInitializerForStaticField, + analyzerCode: "INITIALIZER_FOR_STATIC_FIELD", dart2jsCode: "*fatal*"); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +Message _withArgumentsInitializerForStaticField(String name) { + return new Message(codeInitializerForStaticField, + message: """'${name}' isn't an instance field of this class.""", + arguments: {'name': name}); +} + // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Template< Message Function( @@ -4285,6 +4307,9 @@ const Code codeInvalidInitializer = messageInvalidInitializer; // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const MessageCode messageInvalidInitializer = const MessageCode( "InvalidInitializer", + analyzerCode: "INVALID_INITIALIZER", + dart2jsCode: "*fatal*", + severity: Severity.error, message: r"""Not a valid initializer.""", tip: r"""To initialize a field, use the syntax 'name = value'."""); @@ -5565,6 +5590,8 @@ const Code codeOverrideTypeVariablesMismatch = const Code( "OverrideTypeVariablesMismatch", templateOverrideTypeVariablesMismatch, + analyzerCode: "INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS", + dart2jsCode: "*fatal*", severity: Severity.errorLegacyWarning); // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. @@ -5652,6 +5679,8 @@ const Code codePartOfTwoLibraries = messagePartOfTwoLibraries; // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const MessageCode messagePartOfTwoLibraries = const MessageCode( "PartOfTwoLibraries", + analyzerCode: "PART_OF_DIFFERENT_LIBRARY", + dart2jsCode: "*fatal*", severity: Severity.error, message: r"""A file can't be part of more than one library.""", tip: diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart index 9a2b65352cc..50371f8e6a7 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart @@ -4143,8 +4143,10 @@ abstract class BodyBuilder extends ScopeListener } } else { return buildInvalidInitializer( - deprecated_buildCompileTimeError( - "'$name' isn't an instance field of this class.", offset), + buildCompileTimeError( + fasta.templateInitializerForStaticField.withArguments(name), + offset, + name.length), offset); } } diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status index a979b35da32..ccda43cb269 100644 --- a/pkg/front_end/messages.status +++ b/pkg/front_end/messages.status @@ -43,7 +43,6 @@ ConflictsWithFactory/example: Fail ConflictsWithMember/example: Fail ConflictsWithMemberWarning/example: Fail ConflictsWithSetter/example: Fail -ConflictsWithSetterWarning/analyzerCode: Fail ConflictsWithSetterWarning/example: Fail ConflictsWithTypeVariable/example: Fail ConstAfterFactory/script1: Fail @@ -191,6 +190,7 @@ ImplementsBeforeExtends/script: Fail ImplementsBeforeWith/script: Fail ImplicitCallOfNonMethod/example: Fail ImportAfterPart/script1: Fail +InitializerForStaticField/example: Fail InitializerOutsideConstructor/example: Fail InputFileNotFound/analyzerCode: Fail InputFileNotFound/example: Fail @@ -203,7 +203,6 @@ InvalidCastLocalFunction/example: Fail InvalidCastNewExpr/example: Fail InvalidCastStaticMethod/example: Fail InvalidCastTopLevelFunction/example: Fail -InvalidInitializer/analyzerCode: Fail InvalidInitializer/example: Fail InvalidInlineFunctionType/analyzerCode: Fail InvalidPackageUri/analyzerCode: Fail @@ -264,14 +263,12 @@ OverrideMismatchNamedParameter/example: Fail OverrideMoreRequiredArguments/example: Fail OverrideTypeMismatchParameter/example: Fail OverrideTypeMismatchReturnType/example: Fail -OverrideTypeVariablesMismatch/analyzerCode: Fail OverrideTypeVariablesMismatch/example: Fail PackageNotFound/analyzerCode: Fail PackageNotFound/example: Fail PartOfLibraryNameMismatch/dart2jsCode: Fail PartOfLibraryNameMismatch/example: Fail PartOfSelf/dart2jsCode: Fail -PartOfTwoLibraries/analyzerCode: Fail # Issue 33227 PartOfUriMismatch/dart2jsCode: Fail PartOfUriMismatch/example: Fail PartOfUseUri/dart2jsCode: Fail diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml index 2e0bdcfecc8..5b2be3df626 100644 --- a/pkg/front_end/messages.yaml +++ b/pkg/front_end/messages.yaml @@ -630,6 +630,11 @@ ExternalField: script: - "class C { external var f; }" +InitializerForStaticField: + template: "'#name' isn't an instance field of this class." + analyzerCode: INITIALIZER_FOR_STATIC_FIELD + dart2jsCode: "*fatal*" + InitializerOutsideConstructor: template: "Only constructors can have initializers, and '#name' is not a constructor." analyzerCode: INITIALIZER_OUTSIDE_CONSTRUCTOR @@ -808,6 +813,9 @@ InvalidVoid: InvalidInitializer: template: "Not a valid initializer." tip: "To initialize a field, use the syntax 'name = value'." + severity: ERROR + analyzerCode: INVALID_INITIALIZER + dart2jsCode: "*fatal*" MissingExponent: template: "Numbers in exponential notation should always contain an exponent (an integer number with an optional sign)." @@ -1642,6 +1650,8 @@ ConflictsWithSetter: ConflictsWithSetterWarning: template: "Conflicts with setter '#name'." severity: ERROR_LEGACY_WARNING + analyzerCode: CONFLICTS_WITH_MEMBER + dart2jsCode: "*fatal*" ConflictsWithTypeVariable: template: "Conflicts with type variable '#name'." @@ -1737,6 +1747,8 @@ IllegalMixin: OverrideTypeVariablesMismatch: template: "Declared type variables of '#name' doesn't match those on overridden method '#name2'." severity: ERROR_LEGACY_WARNING + analyzerCode: INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS + dart2jsCode: "*fatal*" OverriddenMethodCause: template: "This is the overriden method ('#name')." @@ -1922,6 +1934,8 @@ PartOfTwoLibraries: template: "A file can't be part of more than one library." tip: "Try moving the shared declarations into the libraries, or into a new library." severity: ERROR + analyzerCode: PART_OF_DIFFERENT_LIBRARY + dart2jsCode: "*fatal*" script: main.dart: "library lib; import 'lib.dart'; part 'part.dart';" lib.dart: "library lib; part 'part.dart';"