Skip to content

Commit 7edd29a

Browse files
stereotype441Commit Queue
authored andcommitted
[front_end] Convert an error message to use named arguments.
Modifies the scanner logic that reports the `AsciiControlCharacter` error message so that it invokes it using `withArguments` (which accepts named arguments) rather than the old `withArgumentsOld` (which accepts positional arguments). The name of the parameter accepted by this error message has been changed to `character`, to reflect its usage, and parameter documentation has been added. This is an exercise to verify that the front end's new `withArguments` error reporting infrastructure is fully functional. In follow-up CLs, I plan to introduce some tools to partially automate the process of updating front end code to use `withArguments` rather than `withArgumentsOld`. However, if anyone wishes to start migrating error reporting to the new scheme before that, they are welcome to do so. Change-Id: I6a6a6964fc87d6bf551ec4891c56e6106dd9c098 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448239 Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 918fb7c commit 7edd29a

File tree

5 files changed

+297
-297
lines changed

5 files changed

+297
-297
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,32 +211,32 @@ const MessageCode codeAnonymousContinueTargetOutsideFunction =
211211

212212
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
213213
const Template<
214-
Message Function(int unicode),
215-
Message Function({required int unicode})
214+
Message Function(int character),
215+
Message Function({required int character})
216216
>
217217
codeAsciiControlCharacter = const Template(
218218
"AsciiControlCharacter",
219219
problemMessageTemplate:
220-
r"""The control character #unicode can only be used in strings and comments.""",
220+
r"""The control character #character can only be used in strings and comments.""",
221221
withArgumentsOld: _withArgumentsOldAsciiControlCharacter,
222222
withArguments: _withArgumentsAsciiControlCharacter,
223223
analyzerCodes: <String>["ILLEGAL_CHARACTER"],
224224
);
225225

226226
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
227-
Message _withArgumentsAsciiControlCharacter({required int unicode}) {
228-
var unicode_0 = conversions.codePointToUnicode(unicode);
227+
Message _withArgumentsAsciiControlCharacter({required int character}) {
228+
var character_0 = conversions.codePointToUnicode(character);
229229
return new Message(
230230
codeAsciiControlCharacter,
231231
problemMessage:
232-
"""The control character ${unicode_0} can only be used in strings and comments.""",
233-
arguments: {'unicode': unicode},
232+
"""The control character ${character_0} can only be used in strings and comments.""",
233+
arguments: {'character': character},
234234
);
235235
}
236236

237237
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
238-
Message _withArgumentsOldAsciiControlCharacter(int unicode) =>
239-
_withArgumentsAsciiControlCharacter(unicode: unicode);
238+
Message _withArgumentsOldAsciiControlCharacter(int character) =>
239+
_withArgumentsAsciiControlCharacter(character: character);
240240

241241
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
242242
const MessageCode codeAssertAsExpression = const MessageCode(

pkg/_fe_analyzer_shared/lib/src/scanner/error_token.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class AsciiControlCharacterToken extends ErrorToken {
160160

161161
@override
162162
Message get assertionMessage =>
163-
codeAsciiControlCharacter.withArgumentsOld(character);
163+
codeAsciiControlCharacter.withArguments(character: character);
164164
}
165165

166166
/// Denotes an operator that is not supported in the Dart language.

pkg/front_end/messages.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@
146146

147147
AsciiControlCharacter:
148148
parameters:
149-
Unicode unicode: undocumented
150-
problemMessage: "The control character #unicode can only be used in strings and comments."
149+
Unicode character: the unexpected control character.
150+
problemMessage: "The control character #character can only be used in strings and comments."
151151
analyzerCode: ILLEGAL_CHARACTER
152152
expression: "\x1b 1"
153153

Binary file not shown.

0 commit comments

Comments
 (0)