Skip to content

Commit 902a2bf

Browse files
stereotype441Commit Queue
authored andcommitted
[front_end] Allow "parameters" entries in messages.yaml.
A `parameters` entry in `pkg/front_end/messages.yaml` has the same meaning as a `parameters` entry in `pkg/analyzer/messages.yaml`. For now there are no `parameters` entries present. In follow-up CLs, I will add a script that adds `parameters` entries to `pkg/front_end/messages.yaml`, and then I will make the `parameters` entries required. After that, I will make it possible to choose arbitrary names for parameters; this will bring the front end's parameter functionality in line with the analyzer's. Change-Id: I6a6a6964c293f65c67a12739cab05c02ba3bb8e2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448234 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent bdd95fa commit 902a2bf

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

pkg/front_end/messages.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@
133133
#
134134
# `#num1%N.M`, `#num2%N.M`, `#num3%N.M`: numbers (doubles) formatted to minimum
135135
# width N and with M fraction digits.
136+
#
137+
# A message declaration may optionally include a map called
138+
# `parameters`; each map key is of the form `TYPE NAME`, and each map
139+
# value is a comment describing the parameter.
140+
#
141+
# If a diagnostic takes no parameters, it should have an entry of the
142+
# form `parameters: none`.
143+
#
144+
# In the future, the `parameters` entry will be required.
136145

137146
AsciiControlCharacter:
138147
problemMessage: "The control character #unicode can only be used in strings and comments."

pkg/front_end/test/messages_suite.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,25 @@ class MessageTestSuite extends ChainContext {
446446
}
447447
break;
448448

449+
case 'parameters':
450+
switch (value) {
451+
case 'none':
452+
break;
453+
case YamlMap():
454+
for (var parameterDoc in value.values) {
455+
if (parameterDoc is! String) {
456+
throw new ArgumentError(
457+
'parameter documentation should be a string: '
458+
'$parameterDoc',
459+
);
460+
}
461+
}
462+
default:
463+
throw new ArgumentError(
464+
'parameters should be a map or `none`: $value.',
465+
);
466+
}
467+
449468
default:
450469
unknownKeys.add(key);
451470
}

0 commit comments

Comments
 (0)