From a2d7bb46bb674ff1ddeedac924f2e5f6b2d2c7a1 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Fri, 14 Nov 2025 12:37:11 -0800 Subject: [PATCH] [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 Reviewed-by: Konstantin Shcheglov Commit-Queue: Paul Berry --- pkg/analysis_server/messages.yaml | 130 ++++++++++++++++++ pkg/analyzer/messages.yaml | 117 ---------------- .../test/verify_diagnostics_test.dart | 1 + .../lib/analyzer_messages.dart | 10 ++ pkg/analyzer_utilities/lib/messages.dart | 1 + 5 files changed, 142 insertions(+), 117 deletions(-) create mode 100644 pkg/analysis_server/messages.yaml diff --git a/pkg/analysis_server/messages.yaml b/pkg/analysis_server/messages.yaml new file mode 100644 index 00000000000..c2299f486cd --- /dev/null +++ b/pkg/analysis_server/messages.yaml @@ -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 diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml index caa5d0a4741..254626b6109 100644 --- a/pkg/analyzer/messages.yaml +++ b/pkg/analyzer/messages.yaml @@ -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: diff --git a/pkg/analyzer/test/verify_diagnostics_test.dart b/pkg/analyzer/test/verify_diagnostics_test.dart index 447334a83c7..b27d7918c0e 100644 --- a/pkg/analyzer/test/verify_diagnostics_test.dart +++ b/pkg/analyzer/test/verify_diagnostics_test.dart @@ -220,6 +220,7 @@ class DocumentationValidator { Future validate() async { await _validateMessages(feAnalyzerSharedMessages); await _validateMessages(analyzerMessages); + await _validateMessages(analysisServerMessages); await _validateMessages(lintMessages); if (buffer.isNotEmpty) { fail(buffer.toString()); diff --git a/pkg/analyzer_utilities/lib/analyzer_messages.dart b/pkg/analyzer_utilities/lib/analyzer_messages.dart index 6e1ca1ac551..4f6488d169c 100644 --- a/pkg/analyzer_utilities/lib/analyzer_messages.dart +++ b/pkg/analyzer_utilities/lib/analyzer_messages.dart @@ -184,6 +184,16 @@ const transformSetErrorCodeFile = GeneratedDiagnosticFile( package: AnalyzerDiagnosticPackage.analysisServer, ); +/// Decoded messages from the analysis server's `messages.yaml` file. +final List 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 analyzerMessages = decodeAnalyzerMessagesYaml( analyzerPkgPath, diff --git a/pkg/analyzer_utilities/lib/messages.dart b/pkg/analyzer_utilities/lib/messages.dart index b12c7ed0066..bed7c6bd08c 100644 --- a/pkg/analyzer_utilities/lib/messages.dart +++ b/pkg/analyzer_utilities/lib/messages.dart @@ -33,6 +33,7 @@ final DiagnosticTables diagnosticTables = DiagnosticTables._([ ...frontEndMessages, ...feAnalyzerSharedMessages, ...analyzerMessages, + ...analysisServerMessages, ...lintMessages, ]);