Skip to content

Commit 7b2df64

Browse files
stereotype441Commit Queue
authored andcommitted
[messages] Mark some messages as "pseudoShared".
A `pseudoShared` message is a front-end message that is generated by code in the `_fe_analyzer_shared` package, and has a corresponding analyzer message, but the error messages are not truly shared; the analyzer message may have different text or parameters. In the long term I plan to fully share all of these messages. However, in the short term, this will allow the logic for front end error code generation to be cleaned up, so that only messages that are truly shared, or truly needed by `package:_fe_analyzer_shared` are emitted to `pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart`. Change-Id: I6a6a6964bbb146afd41c39ab73b4bc8bbcc5b81c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449607 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent b04639b commit 7b2df64

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed

pkg/analyzer_utilities/lib/messages.dart

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
/// @docImport 'package:analyzer/src/fasta/error_converter.dart';
6+
library;
7+
58
import 'dart:convert';
69
import 'dart:io';
710

@@ -800,7 +803,21 @@ enum ErrorCodeParameterType {
800803
/// In-memory representation of error code information obtained from the file
801804
/// `pkg/front_end/messages.yaml`.
802805
class FrontEndErrorCodeInfo extends CfeStyleErrorCodeInfo {
803-
FrontEndErrorCodeInfo.fromYaml(super.yaml) : super.fromYaml() {
806+
/// Whether the error code contains a `pseudoShared: true` property in
807+
/// `pkg/front_end/messages.yaml`.
808+
///
809+
/// Messages with this property set are not shared; they have separately
810+
/// declared analyzer and CFE codes. However, they are reported by code
811+
/// defined in `pkg/_fe_analyzer_shared` using the CFE error reporting
812+
/// mechanism. When running under the analyzer, they are then translated
813+
/// into the associated analyzer error using [FastaErrorReporter].
814+
// TODO(paulberry): migrate all pseudo-shared error codes to shared error
815+
// codes.
816+
final bool pseudoShared;
817+
818+
FrontEndErrorCodeInfo.fromYaml(super.yaml)
819+
: pseudoShared = (yaml['pseudoShared'] as bool?) ?? false,
820+
super.fromYaml() {
804821
if (index != null) {
805822
throw StateError('Non-shared messages must not have an index');
806823
}

0 commit comments

Comments
 (0)