[messages] Move TransformSetErrorCodes into a new yaml file in package:analysis_server.

Since these error codes are generated into the analysis server, it
makes sense for their yaml source to be located inside the server too.

This paves the way for a CL that will remove information about the
particular diagnostic classes from the code generation logic; once
that happens the only way for the code generation to know where to put
the generated error codes will be to look at where their yaml source
is defined.

Change-Id: I6a6a6964418eb42bdabd129a1a19848a1fc22ebb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461982
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry
2025-11-14 12:37:11 -08:00
committed by Commit Queue
parent 1d326c0cf1
commit a2d7bb46bb
5 changed files with 142 additions and 117 deletions
+130
View File
@@ -0,0 +1,130 @@
# Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Run
#
# dart run pkg/analyzer/tool/messages/generate.dart
#
# to regenerate messages after having edited this file.
# See `pkg/analyzer/messages.yaml` for a description of the contents
# of this file.
TransformSetErrorCode:
conflicting_key:
parameters:
Object p0: the conflicting key
Object p1: the key that it conflicts with
problemMessage: "The key '#p0' can't be used when '#p1' is also used."
hasPublishedDocs: false
expected_primary:
parameters: none
problemMessage: "Expected either an identifier or a string literal."
hasPublishedDocs: false
incompatible_element_kind:
parameters:
Object p0: the old kind
Object p1: the new kind
problemMessage: "An element of kind '#p0' can't be replaced by an element of kind '#p1'."
hasPublishedDocs: false
invalid_change_for_kind:
parameters:
Object p0: the change kind that is invalid
Object p1: the element kind for the transform
problemMessage: "A change of type '#p0' can't be used for an element of kind '#p1'."
hasPublishedDocs: false
invalid_character:
parameters:
Object p0: the character that is invalid
problemMessage: "Invalid character '#p0'."
hasPublishedDocs: false
invalid_key:
parameters:
Object p0: the actual type of the key
problemMessage: "Keys must be of type 'String' but found the type '#p0'."
hasPublishedDocs: false
invalid_required_if:
parameters: none
problemMessage: "The key 'requiredIf' can only be used with optional named parameters."
hasPublishedDocs: false
invalid_value:
parameters:
Object p0: the key with which the value is associated
Object p1: the expected type of the value
Object p2: the actual type of the value
problemMessage: "The value of '#p0' should be of type '#p1' but is of type '#p2'."
hasPublishedDocs: false
invalid_parameter_style:
parameters:
Object p0: the list of valid parameter styles
problemMessage: "The parameter style must be one of the following: #p0."
hasPublishedDocs: false
invalid_value_one_of:
parameters:
Object p0: the key with which the value is associated
Object p1: the allowed values as a comma-separated list
problemMessage: "The value of '#p0' must be one of the following: '#p1'."
hasPublishedDocs: false
missing_key:
parameters:
Object p0: the missing key
problemMessage: "Missing the required key '#p0'."
hasPublishedDocs: false
missing_one_of_multiple_keys:
parameters:
Object p0: the list of valid keys
problemMessage: "Exactly one of the following keys must be provided: #p0."
hasPublishedDocs: false
missing_template_end:
parameters: none
problemMessage: "Missing the end brace for the template."
hasPublishedDocs: false
missing_token:
parameters:
Object p0: a description of the expected kinds of tokens
problemMessage: "Expected to find #p0."
hasPublishedDocs: false
missing_uri:
parameters: none
problemMessage: "At least one URI must be provided."
hasPublishedDocs: false
undefined_variable:
parameters:
Object p0: the missing key
problemMessage: "The variable '#p0' isn't defined."
hasPublishedDocs: false
unexpected_transform_set_token:
parameters:
Object p0: the token that was unexpectedly found
problemMessage: "Didn't expect to find #p0."
hasPublishedDocs: false
unknown_accessor:
parameters:
Object p0: a description of the expected kind of token
problemMessage: "The accessor '#p0' is invalid."
hasPublishedDocs: false
unsupported_key:
parameters:
Object p0: the unsupported key
problemMessage: "The key '#p0' isn't supported."
hasPublishedDocs: false
unsupported_static:
parameters: none
problemMessage: "The key 'static' is only supported for elements in a class, enum, extension, or mixin."
hasPublishedDocs: false
unsupported_version:
parameters: none
problemMessage: "Only version '1' is supported at this time."
hasPublishedDocs: false
wrong_token:
parameters:
Object p0: a description of the expected kind of token
Object p1: a description of the actual kind of token
problemMessage: "Expected to find #p0, but found #p1."
hasPublishedDocs: false
yaml_syntax_error:
parameters:
Object p0: the message produced by the YAML parser
problemMessage: "Parse error: #p0"
hasPublishedDocs: false
-117
View File
@@ -23302,123 +23302,6 @@ TodoCode:
hasPublishedDocs: false
comment: |-
A TODO comment marked as UNDONE.
TransformSetErrorCode:
conflicting_key:
parameters:
Object p0: the conflicting key
Object p1: the key that it conflicts with
problemMessage: "The key '#p0' can't be used when '#p1' is also used."
hasPublishedDocs: false
expected_primary:
parameters: none
problemMessage: "Expected either an identifier or a string literal."
hasPublishedDocs: false
incompatible_element_kind:
parameters:
Object p0: the old kind
Object p1: the new kind
problemMessage: "An element of kind '#p0' can't be replaced by an element of kind '#p1'."
hasPublishedDocs: false
invalid_change_for_kind:
parameters:
Object p0: the change kind that is invalid
Object p1: the element kind for the transform
problemMessage: "A change of type '#p0' can't be used for an element of kind '#p1'."
hasPublishedDocs: false
invalid_character:
parameters:
Object p0: the character that is invalid
problemMessage: "Invalid character '#p0'."
hasPublishedDocs: false
invalid_key:
parameters:
Object p0: the actual type of the key
problemMessage: "Keys must be of type 'String' but found the type '#p0'."
hasPublishedDocs: false
invalid_required_if:
parameters: none
problemMessage: "The key 'requiredIf' can only be used with optional named parameters."
hasPublishedDocs: false
invalid_value:
parameters:
Object p0: the key with which the value is associated
Object p1: the expected type of the value
Object p2: the actual type of the value
problemMessage: "The value of '#p0' should be of type '#p1' but is of type '#p2'."
hasPublishedDocs: false
invalid_parameter_style:
parameters:
Object p0: the list of valid parameter styles
problemMessage: "The parameter style must be one of the following: #p0."
hasPublishedDocs: false
invalid_value_one_of:
parameters:
Object p0: the key with which the value is associated
Object p1: the allowed values as a comma-separated list
problemMessage: "The value of '#p0' must be one of the following: '#p1'."
hasPublishedDocs: false
missing_key:
parameters:
Object p0: the missing key
problemMessage: "Missing the required key '#p0'."
hasPublishedDocs: false
missing_one_of_multiple_keys:
parameters:
Object p0: the list of valid keys
problemMessage: "Exactly one of the following keys must be provided: #p0."
hasPublishedDocs: false
missing_template_end:
parameters: none
problemMessage: "Missing the end brace for the template."
hasPublishedDocs: false
missing_token:
parameters:
Object p0: a description of the expected kinds of tokens
problemMessage: "Expected to find #p0."
hasPublishedDocs: false
missing_uri:
parameters: none
problemMessage: "At least one URI must be provided."
hasPublishedDocs: false
undefined_variable:
parameters:
Object p0: the missing key
problemMessage: "The variable '#p0' isn't defined."
hasPublishedDocs: false
unexpected_transform_set_token:
parameters:
Object p0: the token that was unexpectedly found
problemMessage: "Didn't expect to find #p0."
hasPublishedDocs: false
unknown_accessor:
parameters:
Object p0: a description of the expected kind of token
problemMessage: "The accessor '#p0' is invalid."
hasPublishedDocs: false
unsupported_key:
parameters:
Object p0: the unsupported key
problemMessage: "The key '#p0' isn't supported."
hasPublishedDocs: false
unsupported_static:
parameters: none
problemMessage: "The key 'static' is only supported for elements in a class, enum, extension, or mixin."
hasPublishedDocs: false
unsupported_version:
parameters: none
problemMessage: "Only version '1' is supported at this time."
hasPublishedDocs: false
wrong_token:
parameters:
Object p0: a description of the expected kind of token
Object p1: a description of the actual kind of token
problemMessage: "Expected to find #p0, but found #p1."
hasPublishedDocs: false
yaml_syntax_error:
parameters:
Object p0: the message produced by the YAML parser
problemMessage: "Parse error: #p0"
hasPublishedDocs: false
WarningCode:
ARGUMENT_TYPE_NOT_ASSIGNABLE_TO_ERROR_HANDLER:
parameters:
@@ -220,6 +220,7 @@ class DocumentationValidator {
Future<void> validate() async {
await _validateMessages(feAnalyzerSharedMessages);
await _validateMessages(analyzerMessages);
await _validateMessages(analysisServerMessages);
await _validateMessages(lintMessages);
if (buffer.isNotEmpty) {
fail(buffer.toString());
@@ -184,6 +184,16 @@ const transformSetErrorCodeFile = GeneratedDiagnosticFile(
package: AnalyzerDiagnosticPackage.analysisServer,
);
/// Decoded messages from the analysis server's `messages.yaml` file.
final List<AnalyzerMessage> analysisServerMessages = decodeAnalyzerMessagesYaml(
analysisServerPkgPath,
);
/// The path to the `analysis_server` package.
final String analysisServerPkgPath = normalize(
join(pkg_root.packageRoot, 'analysis_server'),
);
/// Decoded messages from the analyzer's `messages.yaml` file.
final List<AnalyzerMessage> analyzerMessages = decodeAnalyzerMessagesYaml(
analyzerPkgPath,
+1
View File
@@ -33,6 +33,7 @@ final DiagnosticTables diagnosticTables = DiagnosticTables._([
...frontEndMessages,
...feAnalyzerSharedMessages,
...analyzerMessages,
...analysisServerMessages,
...lintMessages,
]);