Commit 918fb7c
[front_end] Allow messages to have arbitrary parameter names.
Changes `ParsedPlaceholder.fromMatch` so that it no longer computes
the parameter's type by looking it up in a hardcoded table. Instead,
the parameter's type is instead obtained by looking it up by name in
the `ErrorCodeInfo.parameters` map.
This allows messages to have arbitrary parameter names. The hardcoded
table, `_templateParameterNameToType`, is removed since it is no
longer needed.
This also enabled some clean-up of the template compiler. I've split
it into three methods:
- `compile`, which compiles the entire template.
- `computeInterpolator`, which figures out the correct interpolation
expression for a single parameter substitution.
- `interpolate`, which converts either the `problemMessage` or the
`correctionMessage` into an interpolation string.
There is a small change to the generated code: in messages that use a
`TypeLabeler`, the `TypeLabeler` is declared and initialized just
before its first use, rather than at the top of the `withArguments`
method. This change makes the generation of the `withArguments` method
a little more straightforward, since it allows the body of
`withArguments` to be computed via a single scan through all the
placeholders. This change shouldn't have any user-visible effect.
Change-Id: I6a6a69647a9af5f32c3102b78d54431e290e0591
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448237
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Paul Berry <[email protected]>1 parent 6f6c20d commit 918fb7c
File tree
4 files changed
+153
-190
lines changed- pkg
- analyzer_utilities/lib
- front_end
- lib/src/codes
- tool
4 files changed
+153
-190
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | 23 | | |
61 | 24 | | |
62 | 25 | | |
| |||
928 | 891 | | |
929 | 892 | | |
930 | 893 | | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
936 | 898 | | |
937 | 899 | | |
938 | 900 | | |
939 | 901 | | |
940 | 902 | | |
941 | 903 | | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | 904 | | |
948 | 905 | | |
949 | | - | |
950 | | - | |
951 | | - | |
| 906 | + | |
952 | 907 | | |
953 | 908 | | |
954 | 909 | | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
| 910 | + | |
960 | 911 | | |
961 | 912 | | |
962 | | - | |
| 913 | + | |
963 | 914 | | |
964 | 915 | | |
965 | 916 | | |
966 | 917 | | |
967 | 918 | | |
968 | | - | |
969 | | - | |
| 919 | + | |
970 | 920 | | |
971 | 921 | | |
972 | 922 | | |
| |||
0 commit comments