Skip to content

Commit 6208eb0

Browse files
stereotype441Commit Queue
authored andcommitted
[messages] Add GeneratedDiagnosticClassInfo.package field.
Adds the field `GeneratedDiagnosticClassInfo.package`, and its associated enum type (`AnalyzerDiagnosticPackage`), which describes which package an analyzer diagnostic code is being generated for (analyzer, analysis_server, or linter). This field is used to determine which analyzer messages should be included in the `diagnosticCodeValues` list; the only messages that should be included are those generated for the `analyzer` package. Eventually each of these three packages will have its own `diagnsticCodeValues` list. With this change, the field `GeneratedDiagnosticClassInfo.includeInDiagnosticCodeValues` is no longer needed. Change-Id: I6a6a69641591d0f25029490ced3e772b90c056c2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458380 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 5a62d93 commit 6208eb0

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

pkg/analyzer/tool/messages/generate.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ part of ${json.encode(file.parentLibrary)};
132132

133133
LocatedError.wrap(span: message.keySpan, () {
134134
if (message is! AliasMessage &&
135-
diagnosticClass.includeInDiagnosticCodeValues) {
135+
diagnosticClass.package == AnalyzerDiagnosticPackage.analyzer) {
136136
generatedCodes.add(diagnosticCode);
137137
}
138138
message.toAnalyzerCode(

pkg/analyzer_utilities/lib/analyzer_messages.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const codesFile = GeneratedDiagnosticFile(
1616
parentLibrary: 'package:analyzer/src/error/codes.dart',
1717
);
1818

19+
/// Enum representing the packages into which analyzer diagnostics can be
20+
/// generated.
21+
enum AnalyzerDiagnosticPackage { analyzer, analysisServer, linter }
22+
1923
/// Information about all the classes derived from `DiagnosticCode` that are
2024
/// code-generated based on the contents of the analyzer and front end
2125
/// `messages.yaml` files.
@@ -104,7 +108,7 @@ or revisited.
104108
name: 'TransformSetErrorCode',
105109
type: 'COMPILE_TIME_ERROR',
106110
severity: 'ERROR',
107-
includeInDiagnosticCodeValues: false,
111+
package: AnalyzerDiagnosticPackage.analysisServer,
108112
comment: '''
109113
An error code representing a problem in a file containing an encoding of a
110114
transform set.
@@ -135,6 +139,7 @@ const linterLintCodeInfo = GeneratedDiagnosticClassInfo(
135139
file: lintCodesFile,
136140
name: 'LinterLintCode',
137141
type: 'LINT',
142+
package: AnalyzerDiagnosticPackage.linter,
138143
);
139144

140145
const manifestWarningCodeFile = GeneratedDiagnosticFile(

pkg/analyzer_utilities/lib/messages.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,8 @@ class GeneratedDiagnosticClassInfo extends DiagnosticClassInfo {
579579
/// deprecation notice) after migration to camel case diagnostic codes.
580580
final Set<String> deprecatedSnakeCaseNames;
581581

582-
/// If `true` (the default), diagnostic codes of this class will be included
583-
/// in the automatically-generated `diagnosticCodeValues` list.
584-
final bool includeInDiagnosticCodeValues;
582+
/// The package into which the diagnostic codes will be generated.
583+
final AnalyzerDiagnosticPackage package;
585584

586585
/// Documentation comment to generate for the diagnostic class.
587586
///
@@ -594,7 +593,7 @@ class GeneratedDiagnosticClassInfo extends DiagnosticClassInfo {
594593
this.severity,
595594
required this.type,
596595
this.deprecatedSnakeCaseNames = const {},
597-
this.includeInDiagnosticCodeValues = true,
596+
this.package = AnalyzerDiagnosticPackage.analyzer,
598597
this.comment = '',
599598
});
600599

0 commit comments

Comments
 (0)