Skip to content

Commit 446346a

Browse files
stereotype441Commit Queue
authored andcommitted
[front end] Add args to Template class.
This is part of a series of CLs that will standardize CFE error reporting to always use `codeFoo.withArguments(...)` when reporting errors that take arguments and `codeFoo` when reporting errors that don't take arguments, rather than `templateFoo.withArguments(...)` when reporting errors that take arguments and `messageFoo` when reporting errors that don't take arguments. This change will have two advantages: - It will lend greater consistency to the CFE codebase, by allowing the same `code...` objects to be used both to name error codes (e.g., in test expectations) and to report errors. This will allow everything associated with a certain error code to be found using a single invocation of "Find References" in the editor, rather than having to search separately for uses of the code and the message or template. - It should hopefully make the experience of writing code that reports errors more pleasant, since it will no longer be necessary to look up an error to see whether it takes arguments before using it; instead, the developer will be able to type the name of the message `code...` declaration, and then use autocompletion to see whether `.withArguments(...)` is required. In this CL, the arguments `index`, `analyzerCodes`, and `severity` are added to the `Template` constructor, and those arguments are supplied by the generated code. But the arguments are not used yet. In follow up CLs, I will change the `Template` class so that it extends `Code` and passes these arguments along to the `Code` constructor. This in turn will allow the `Template` objects to serve the dual role of being either a template or an error code, in much the same way that for errors that don't take arguments, the `MessageCode` objects serve the dual role of being either an error code or an error message. Change-Id: Id8d7afab0845048db96d57f68ca91259a6dbaf5e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443001 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 2bd2785 commit 446346a

File tree

4 files changed

+297
-0
lines changed

4 files changed

+297
-0
lines changed

pkg/_fe_analyzer_shared/lib/src/messages/codes.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ class Template<T> {
118118
this.correctionMessageTemplate,
119119
required this.problemMessageTemplate,
120120
required this.withArguments,
121+
int index = -1,
122+
List<String>? analyzerCodes,
123+
CfeSeverity severity = CfeSeverity.error,
121124
});
122125

123126
@override

0 commit comments

Comments
 (0)