Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/warnings.dart

Issue 20742002: Clean up error handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added documentation guide lines. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js; 5 part of dart2js;
6 6
7 /**
8 * The messages in this file should meet the following guide lines:
9 *
10 * 1. The message should start with exactly one of "Error", "Internal error",
Johnni Winther 2013/07/29 06:22:41 "Internal error" -> "Internal Error".
11 * "Warning", "Info", or "Hint" followed by a colon. It is crucial to users to
12 * be able to locate errors in the midst of warnings, but we are operating
13 * under the assumption that these messages will eventually be translated to
14 * other languages than English, and that it is therefor not possible to
ahe 2013/07/28 09:19:36 therefore
15 * automatically apply these prefixes.
16 *
17 * 2. After the colon, one space and a complete sentence starting with an
18 * uppercase letter, and ending with a period.
19 *
20 * 3. Reserved words and embedded identifiers should be in quotes (double
sra1 2013/07/30 21:28:20 We should be using single quotes. 1. Double quote
ahe 2013/07/31 15:58:38 ...
21 * quotes), so prefer single quotes for the complete message. For example,
22 * 'Error: The class "#{className}" cannot use "super".' Notice that the word
ahe 2013/07/30 14:31:36 Luke: Using "cannot", "must not", "shall not", et
23 * "class" in the preceding message is not quoted as it refers to the concept
24 * "class", not the reserved word. On the other hand, "super" refers to the
25 * reserved word. Do not quote "null" and numeric literals.
26 *
27 * 4. Do not try to compose messages, as it can make translating them hard.
kustermann 2013/07/29 06:26:40 I don't get this rule.
28 *
29 * 5. Try to keep the error messages short, but informative.
30 *
31 * 6. Use simple words and terminology, assume the reader of the message does
32 * not have an advanced degree in math, and that English is not the reader's
33 * native language. Do not assume any formal computer science training. For
34 * example, do not use Latin abbreviations (prefer "that is" over "i.e.", and
35 * "for example" over "e.g."). Also avoid phrases such as "if and only if" and
36 * "iff", that level of precision is unnecessary.
ahe 2013/07/28 09:19:36 is *often* unnecessary.
37 *
38 * 7. Do not use contractions, for example, prefer "cannot" over "can't". This
39 * is again to benefit readers to whom English is not their first language.
kustermann 2013/07/29 06:26:40 You could simplify to something like: "This is aga
40 *
41 * 8. Use common terminology, preferably from the Dart Language
42 * Specification. This increases the user's chance of finding a good
43 * explanation on the web.
44 *
45 * 9. Do not try to be cute or funny. It is extremely frustrating to work on a
46 * product that crashes with a "tongue-in-cheek" message, especially if you did
47 * not want to use this product to begin with with.
48 *
49 * 10. Do not lie, that is, do not write error messages containing phrases like
50 * "cannot happen". If the user ever saw this message, it would be a
51 * lie. Prefer messages like: 'Internal error: This function should not be
Johnni Winther 2013/07/29 06:22:41 'Internal error' -> 'Internal Error'.
52 * called when "x" is null.'.
53 */
kustermann 2013/07/29 06:26:40 Since the rules above apply to the whole file => n
7 class MessageKind { 54 class MessageKind {
8 final String template; 55 final String template;
9 const MessageKind(this.template); 56 const MessageKind(this.template);
10 57
11 static const GENERIC = const MessageKind('#{text}'); 58 /// Do not use this. It is here for legacy and debugging. It violates item 4
12 59 /// above.
13 static const NOT_ASSIGNABLE = const MessageKind( 60 static const MessageKind GENERIC = const MessageKind('#{text}');
14 '#{fromType} is not assignable to #{toType}'); 61
15 static const VOID_EXPRESSION = const MessageKind( 62 static const DualKind NOT_ASSIGNABLE = const DualKind(
16 'expression does not yield a value'); 63 error: const MessageKind(
17 static const VOID_VARIABLE = const MessageKind( 64 'Error: "#{fromType}" is not assignable to "#{toType}".'),
18 'variable cannot be of type void'); 65 warning: const MessageKind(
19 static const RETURN_VALUE_IN_VOID = const MessageKind( 66 'Warning: "#{fromType}" is not assignable to "#{toType}".'));
20 'cannot return value from void function'); 67
21 static const RETURN_NOTHING = const MessageKind( 68 static const MessageKind VOID_EXPRESSION = const MessageKind(
22 'value of type #{returnType} expected'); 69 'Warning: Expression does not yield a value.');
23 static const MISSING_ARGUMENT = const MessageKind( 70
24 'missing argument of type #{argumentType}'); 71 static const MessageKind VOID_VARIABLE = const MessageKind(
25 static const ADDITIONAL_ARGUMENT = const MessageKind( 72 'Warning: Variable cannot be of type void.');
26 'additional argument'); 73
27 static const NAMED_ARGUMENT_NOT_FOUND = const MessageKind( 74 static const MessageKind RETURN_VALUE_IN_VOID = const MessageKind(
28 "no named argument '#{argumentName}' found on method"); 75 'Warning: Cannot return value from void function.');
29 static const MEMBER_NOT_FOUND = const MessageKind( 76
30 'no member named #{memberName} in class #{className}'); 77 static const MessageKind RETURN_NOTHING = const MessageKind(
31 static const METHOD_NOT_FOUND = const MessageKind( 78 'Warning: Value of type "#{returnType}" expected.');
32 'no method named #{memberName} in class #{className}'); 79
33 static const OPERATOR_NOT_FOUND = const MessageKind( 80 static const MessageKind MISSING_ARGUMENT = const MessageKind(
34 'no operator #{memberName} in class #{className}'); 81 'Warning: Missing argument of type "#{argumentType}".');
35 static const PROPERTY_NOT_FOUND = const MessageKind( 82
36 'no property named #{memberName} in class #{className}'); 83 static const MessageKind ADDITIONAL_ARGUMENT = const MessageKind(
37 static const NOT_CALLABLE = const MessageKind( 84 'Warning: Additional argument.');
38 "'#{elementName}' is not callable"); 85
39 static const MEMBER_NOT_STATIC = const MessageKind( 86 static const MessageKind NAMED_ARGUMENT_NOT_FOUND = const MessageKind(
40 '#{className}.#{memberName} is not static'); 87 'Warning: No named argument "#{argumentName}" found on method.');
41 static const NO_INSTANCE_AVAILABLE = const MessageKind( 88
42 '#{name} is only available in instance methods'); 89 static const DualKind MEMBER_NOT_FOUND = const DualKind(
43 static const PRIVATE_ACCESS = const MessageKind( 90 error: const MessageKind(
44 "'#{name}' is declared private within library #{libraryName} and " 91 'Error: No member named "#{memberName}" in class "#{className}".'),
45 "is therefore not accessible."); 92 warning: const MessageKind(
46 93 'Warning: No member named "#{memberName}" in class "#{className}".'));
47 static const THIS_IS_THE_METHOD = const MessageKind( 94
48 "This is the method declaration."); 95 static const MessageKind METHOD_NOT_FOUND = const MessageKind(
49 96 'Warning: No method named "#{memberName}" in class "#{className}".');
50 static const UNREACHABLE_CODE = const MessageKind( 97
51 'unreachable code'); 98 static const MessageKind OPERATOR_NOT_FOUND = const MessageKind(
52 static const MISSING_RETURN = const MessageKind( 99 'Warning: No operator "#{memberName}" in class "#{className}".');
53 'missing return'); 100
54 static const MAYBE_MISSING_RETURN = const MessageKind( 101 static const MessageKind PROPERTY_NOT_FOUND = const MessageKind(
55 'not all paths lead to a return or throw statement'); 102 'Warning: No property named "#{memberName}" in class "#{className}".');
56 103
57 static const CANNOT_RESOLVE = const MessageKind( 104 static const MessageKind NOT_CALLABLE = const MessageKind(
58 'cannot resolve #{name}'); 105 'Warning: "#{elementName}" is not callable.');
59 static const CANNOT_RESOLVE_CONSTRUCTOR = const MessageKind( 106
60 'cannot resolve constructor #{constructorName}'); 107 static const DualKind MEMBER_NOT_STATIC = const DualKind(
61 static const CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT = const MessageKind( 108 error: const MessageKind(
62 'cannot resolve constructor #{constructorName} for implicit super call'); 109 'Error: "#{className}.#{memberName}" is not static.'),
63 static const INVALID_UNNAMED_CONSTRUCTOR_NAME = const MessageKind( 110 warning: const MessageKind(
64 'Error: Unnamed constructor name must be #{name}.'); 111 'Warning: "#{className}.#{memberName}" is not static.'));
65 static const INVALID_CONSTRUCTOR_NAME = const MessageKind( 112
66 'Error: Constructor name must start with #{name}.'); 113 static const MessageKind NO_INSTANCE_AVAILABLE = const MessageKind(
67 static const CANNOT_RESOLVE_TYPE = const MessageKind( 114 'Error: "#{name}" is only available in instance methods.');
68 'cannot resolve type #{typeName}'); 115
69 static const DUPLICATE_DEFINITION = const MessageKind( 116 static const MessageKind PRIVATE_ACCESS = const MessageKind(
70 "Error: Duplicate definition of '#{name}'."); 117 'Warning: "#{name}" is declared private within library '
71 static const EXISTING_DEFINITION = const MessageKind( 118 '"#{libraryName}".');
72 "Info: Existing definition of '#{name}'."); 119
73 static const DUPLICATE_IMPORT = const MessageKind( 120 static const MessageKind THIS_IS_THE_METHOD = const MessageKind(
74 'duplicate import of #{name}'); 121 'Info: This is the method declaration.');
75 static const DUPLICATE_EXPORT = const MessageKind( 122
76 'duplicate export of #{name}'); 123 static const MessageKind UNREACHABLE_CODE = const MessageKind(
77 static const NOT_A_TYPE = const MessageKind( 124 'Warning: Unreachable code.');
78 '#{node} is not a type'); 125
79 static const NOT_A_PREFIX = const MessageKind( 126 static const MessageKind MISSING_RETURN = const MessageKind(
80 '#{node} is not a prefix'); 127 'Warning: Missing return.');
81 static const NO_SUPER_IN_OBJECT = const MessageKind( 128
82 "'Object' does not have a superclass"); 129 static const MessageKind MAYBE_MISSING_RETURN = const MessageKind(
83 static const CANNOT_FIND_CONSTRUCTOR = const MessageKind( 130 'Warning: Not all paths lead to a return or throw statement.');
84 'cannot find constructor #{constructorName}'); 131
85 static const CYCLIC_CLASS_HIERARCHY = const MessageKind( 132 static const DualKind CANNOT_RESOLVE = const DualKind(
86 '#{className} creates a cycle in the class hierarchy'); 133 error: const MessageKind('Error: Cannot resolve "#{name}".'),
87 static const INVALID_RECEIVER_IN_INITIALIZER = const MessageKind( 134 warning: const MessageKind('Warning: Cannot resolve "#{name}".'));
88 'field initializer expected'); 135
89 static const NO_SUPER_IN_STATIC = const MessageKind( 136 static const MessageKind CANNOT_RESOLVE_CONSTRUCTOR = const MessageKind(
90 "'super' is only available in instance methods"); 137 'Error: Cannot resolve constructor "#{constructorName}".');
91 static const DUPLICATE_INITIALIZER = const MessageKind( 138
92 'field #{fieldName} is initialized more than once'); 139 static const MessageKind CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT =
93 static const ALREADY_INITIALIZED = const MessageKind( 140 const MessageKind(
94 '#{fieldName} was already initialized here'); 141 'Error: cannot resolve constructor "#{constructorName}" for implicit'
95 static const INIT_STATIC_FIELD = const MessageKind( 142 'super call.');
96 'cannot initialize static field #{fieldName}'); 143
97 static const NOT_A_FIELD = const MessageKind( 144 static const MessageKind INVALID_UNNAMED_CONSTRUCTOR_NAME = const MessageKind(
98 '#{fieldName} is not a field'); 145 'Error: Unnamed constructor name must be "#{name}".');
99 static const CONSTRUCTOR_CALL_EXPECTED = const MessageKind( 146
100 "only call to 'this' or 'super' constructor allowed"); 147 static const MessageKind INVALID_CONSTRUCTOR_NAME = const MessageKind(
101 static const INVALID_FOR_IN = const MessageKind( 148 'Error: Constructor name must start with "#{name}".');
102 'invalid for-in variable declaration.'); 149
103 static const INVALID_INITIALIZER = const MessageKind( 150 static const DualKind CANNOT_RESOLVE_TYPE = const DualKind(
104 'invalid initializer'); 151 error: const MessageKind('Error: Cannot resolve type "#{typeName}".'),
105 static const FUNCTION_WITH_INITIALIZER = const MessageKind( 152 warning: const MessageKind(
106 'only constructors can have initializers'); 153 'Warning: Cannot resolve type "#{typeName}".'));
107 static const REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind( 154
108 'cyclic constructor redirection'); 155 static const MessageKind DUPLICATE_DEFINITION = const MessageKind(
109 static const REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind( 156 'Error: Duplicate definition of "#{name}".');
110 'redirecting constructor cannot have a body'); 157
111 static const REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER = const MessageKind( 158 static const MessageKind EXISTING_DEFINITION = const MessageKind(
112 'redirecting constructor cannot have other initializers'); 159 'Info: Existing definition of "#{name}".');
113 static const SUPER_INITIALIZER_IN_OBJECT = const MessageKind( 160
114 "'Object' cannot have a super initializer"); 161 static const DualKind DUPLICATE_IMPORT = const DualKind(
115 static const DUPLICATE_SUPER_INITIALIZER = const MessageKind( 162 error: const MessageKind('Error: Duplicate import of "#{name}".'),
116 'cannot have more than one super initializer'); 163 warning: const MessageKind('Warning: Duplicate import of "#{name}".'));
117 static const INVALID_ARGUMENTS = const MessageKind( 164
118 "arguments do not match the expected parameters of #{methodName}"); 165 static const MessageKind DUPLICATE_EXPORT = const MessageKind(
119 static const NO_MATCHING_CONSTRUCTOR = const MessageKind( 166 'Error: Duplicate export of "#{name}".');
120 "super call arguments and constructor parameters don't match"); 167
121 static const NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT = const MessageKind( 168 static const DualKind NOT_A_TYPE = const DualKind(
122 "implicit super call arguments and constructor parameters don't match"); 169 error: const MessageKind('Error: "#{node}" is not a type.'),
123 static const CONST_CALLS_NON_CONST = const MessageKind( 170 warning: const MessageKind('Warning: "#{node}" is not a type.'));
124 "const constructor cannot call a non-const constructor"); 171
125 static const INITIALIZING_FORMAL_NOT_ALLOWED = const MessageKind( 172 static const MessageKind NOT_A_PREFIX = const MessageKind(
126 'an initializing formal parameter is only allowed in ' 173 'Error: "#{node}" is not a prefix.');
127 'non-redirecting generative constructors'); 174
128 static const INVALID_PARAMETER = const MessageKind( 175 static const DualKind CANNOT_FIND_CONSTRUCTOR = const DualKind(
129 "cannot resolve parameter"); 176 error: const MessageKind(
130 static const NOT_INSTANCE_FIELD = const MessageKind( 177 'Error: Cannot find constructor "#{constructorName}".'),
131 '#{fieldName} is not an instance field'); 178 warning: const MessageKind(
132 static const NO_CATCH_NOR_FINALLY = const MessageKind( 179 'Warning: Cannot find constructor "#{constructorName}".'));
133 "expected 'catch' or 'finally'"); 180
134 static const EMPTY_CATCH_DECLARATION = const MessageKind( 181 static const MessageKind CYCLIC_CLASS_HIERARCHY = const MessageKind(
135 'expected an identifier in catch declaration'); 182 'Error: "#{className}" creates a cycle in the class hierarchy.');
136 static const EXTRA_CATCH_DECLARATION = const MessageKind( 183
137 'extra parameter in catch declaration'); 184 static const MessageKind INVALID_RECEIVER_IN_INITIALIZER = const MessageKind(
138 static const PARAMETER_WITH_TYPE_IN_CATCH = const MessageKind( 185 'Error: Field initializer expected.');
139 'cannot use type annotations in catch'); 186
140 static const PARAMETER_WITH_MODIFIER_IN_CATCH = const MessageKind( 187 static const MessageKind NO_SUPER_IN_STATIC = const MessageKind(
141 'cannot use modifiers in catch'); 188 'Error: "super" is only available in instance methods.');
142 static const OPTIONAL_PARAMETER_IN_CATCH = const MessageKind( 189
143 'cannot use optional parameters in catch'); 190 static const MessageKind DUPLICATE_INITIALIZER = const MessageKind(
144 static const THROW_WITHOUT_EXPRESSION = const MessageKind( 191 'Error: Field "#{fieldName}" is initialized more than once.');
145 'cannot use re-throw outside of catch block (expression expected after ' 192
146 '"throw")'); 193 static const MessageKind ALREADY_INITIALIZED = const MessageKind(
147 static const UNBOUND_LABEL = const MessageKind( 194 'Info: "#{fieldName}" was already initialized here.');
148 'cannot resolve label #{labelName}'); 195
149 static const NO_BREAK_TARGET = const MessageKind( 196 static const MessageKind INIT_STATIC_FIELD = const MessageKind(
150 'break statement not inside switch or loop'); 197 'Error: Cannot initialize static field "#{fieldName}".');
151 static const NO_CONTINUE_TARGET = const MessageKind( 198
152 'continue statement not inside loop'); 199 static const MessageKind NOT_A_FIELD = const MessageKind(
153 static const EXISTING_LABEL = const MessageKind( 200 'Error: "#{fieldName}" is not a field.');
154 'original declaration of duplicate label #{labelName}'); 201
155 static const DUPLICATE_LABEL = const MessageKind( 202 static const MessageKind CONSTRUCTOR_CALL_EXPECTED = const MessageKind(
156 'duplicate declaration of label #{labelName}'); 203 'Error: only call to "this" or "super" constructor allowed.');
157 static const UNUSED_LABEL = const MessageKind( 204
158 'unused label #{labelName}'); 205 static const MessageKind INVALID_FOR_IN = const MessageKind(
159 static const INVALID_CONTINUE = const MessageKind( 206 'Error: Invalid for-in variable declaration.');
160 'target of continue is not a loop or switch case'); 207
161 static const INVALID_BREAK = const MessageKind( 208 static const MessageKind INVALID_INITIALIZER = const MessageKind(
162 'target of break is not a statement'); 209 'Error: Invalid initializer.');
163 210
164 static const TYPE_VARIABLE_AS_CONSTRUCTOR = const MessageKind( 211 static const MessageKind FUNCTION_WITH_INITIALIZER = const MessageKind(
165 'cannot use type variable as constructor'); 212 'Error: Only constructors can have initializers.');
166 static const DUPLICATE_TYPE_VARIABLE_NAME = const MessageKind( 213
167 'type variable #{typeVariableName} already declared'); 214 static const MessageKind REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind(
168 static const TYPE_VARIABLE_WITHIN_STATIC_MEMBER = const MessageKind( 215 'Error: Cyclic constructor redirection.');
169 'cannot refer to type variable #{typeVariableName} ' 216
170 'within a static member'); 217 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind(
171 static const TYPE_VARIABLE_IN_CONSTANT = const MessageKind( 218 'Error: Redirecting constructor cannot have a body.');
172 'Error: cannot refer to type variable in constant'); 219
173 220 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER =
174 static const INVALID_USE_OF_SUPER = const MessageKind( 221 const MessageKind(
175 'super not allowed here'); 222 'Error: Redirecting constructor cannot have other initializers.');
176 static const INVALID_CASE_DEFAULT = const MessageKind( 223
177 'default only allowed on last case of a switch'); 224 static const MessageKind SUPER_INITIALIZER_IN_OBJECT = const MessageKind(
178 225 'Error: "Object" cannot have a super initializer.');
179 static const SWITCH_CASE_TYPES_NOT_EQUAL = const MessageKind( 226
180 "case expressions don't all have the same type."); 227 static const MessageKind DUPLICATE_SUPER_INITIALIZER = const MessageKind(
181 static const SWITCH_CASE_VALUE_OVERRIDES_EQUALS = const MessageKind( 228 'Error: Cannot have more than one super initializer.');
182 "case expression value overrides 'operator=='."); 229
183 static const SWITCH_INVALID = const MessageKind( 230 static const DualKind INVALID_ARGUMENTS = const DualKind(
184 "switch cases contain invalid expressions."); 231 error: const MessageKind(
185 232 'Error: Arguments do not match the expected parameters of '
186 static const INVALID_ARGUMENT_AFTER_NAMED = const MessageKind( 233 '"#{methodName}".'),
187 'non-named argument after named argument'); 234 warning: const MessageKind(
188 235 'Warning: Arguments do not match the expected parameters of '
189 static const NOT_A_COMPILE_TIME_CONSTANT = const MessageKind( 236 '"#{methodName}".'));
190 'not a compile-time constant'); 237
191 static const CYCLIC_COMPILE_TIME_CONSTANTS = const MessageKind( 238 static const MessageKind NO_MATCHING_CONSTRUCTOR = const MessageKind(
192 'cycle in the compile-time constant computation'); 239 'Error: "super" call arguments and constructor parameters do not match.');
193 static const CONSTRUCTOR_IS_NOT_CONST = const MessageKind( 240
194 'constructor is not a const constructor'); 241 static const MessageKind NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT =
195 242 const MessageKind(
196 static const KEY_NOT_A_STRING_LITERAL = const MessageKind( 243 'Error: Implicit "super" call arguments and constructor parameters '
197 'map-literal key not a string literal'); 244 'do not match.');
198 245
199 static const NO_SUCH_LIBRARY_MEMBER = const MessageKind( 246 static const MessageKind CONST_CALLS_NON_CONST = const MessageKind(
200 '#{libraryName} has no member named #{memberName}'); 247 'Error: "const" constructor cannot call a non-const constructor.');
201 248
202 static const CANNOT_INSTANTIATE_TYPEDEF = const MessageKind( 249 static const MessageKind INITIALIZING_FORMAL_NOT_ALLOWED = const MessageKind(
203 "cannot instantiate typedef '#{typedefName}'"); 250 'Error: Initializing formal parameter only allowed in generative '
204 251 'constructor.');
205 static const CANNOT_INSTANTIATE_TYPE_VARIABLE = const MessageKind( 252
206 "cannot instantiate type variable '#{typeVariableName}'"); 253 static const MessageKind INVALID_PARAMETER = const MessageKind(
207 254 'Error: Cannot resolve parameter.');
208 static const NO_DEFAULT_CLASS = const MessageKind( 255
209 "no default class on enclosing interface '#{interfaceName}'"); 256 static const MessageKind NOT_INSTANCE_FIELD = const MessageKind(
210 257 'Error: "#{fieldName}" is not an instance field.');
211 static const CYCLIC_TYPE_VARIABLE = const MessageKind( 258
212 "type variable #{typeVariableName} is a supertype of itself"); 259 static const MessageKind NO_CATCH_NOR_FINALLY = const MessageKind(
213 260 'Error: Expected "catch" or "finally".');
214 static const CLASS_NAME_EXPECTED = const MessageKind( 261
215 "class name expected"); 262 static const MessageKind EMPTY_CATCH_DECLARATION = const MessageKind(
216 263 'Error: Expected an identifier in catch declaration.');
217 static const INTERFACE_TYPE_EXPECTED = const MessageKind( 264
218 "interface type expected"); 265 static const MessageKind EXTRA_CATCH_DECLARATION = const MessageKind(
219 266 'Error: Extra parameter in catch declaration.');
220 static const CANNOT_EXTEND = const MessageKind( 267
221 "#{type} cannot be extended"); 268 static const MessageKind PARAMETER_WITH_TYPE_IN_CATCH = const MessageKind(
222 269 'Error: Cannot use type annotations in catch.');
223 static const CANNOT_IMPLEMENT = const MessageKind( 270
224 "#{type} cannot be implemented"); 271 static const MessageKind PARAMETER_WITH_MODIFIER_IN_CATCH = const MessageKind(
225 272 'Error: Cannot use modifiers in catch.');
226 static const DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind( 273
227 "Error: #{type} can not be both extended and implemented."); 274 static const MessageKind OPTIONAL_PARAMETER_IN_CATCH = const MessageKind(
228 275 'Error: Cannot use optional parameters in catch.');
229 static const DUPLICATE_IMPLEMENTS = const MessageKind( 276
230 "Error: #{type} must not occur more than once " 277 static const MessageKind THROW_WITHOUT_EXPRESSION = const MessageKind(
231 "in the implements clause."); 278 'Error: Cannot use re-throw outside of catch block '
232 279 '(expression expected after "throw").');
233 static const ILLEGAL_SUPER_SEND = const MessageKind( 280
234 "#{name} cannot be called on super"); 281 static const MessageKind UNBOUND_LABEL = const MessageKind(
235 282 'Error: Cannot resolve label "#{labelName}".');
236 static const NO_SUCH_SUPER_MEMBER = const MessageKind( 283
237 "Cannot resolve #{memberName} in a superclass of #{className}"); 284 static const MessageKind NO_BREAK_TARGET = const MessageKind(
238 285 'Error: "break" statement not inside switch or loop.');
239 static const ADDITIONAL_TYPE_ARGUMENT = const MessageKind( 286
240 "additional type argument"); 287 static const MessageKind NO_CONTINUE_TARGET = const MessageKind(
241 288 'Error: "continue" statement not inside loop.');
242 static const MISSING_TYPE_ARGUMENT = const MessageKind( 289
243 "missing type argument"); 290 static const MessageKind EXISTING_LABEL = const MessageKind(
291 'Info: Original declaration of duplicate label "#{labelName}".');
292
293 static const DualKind DUPLICATE_LABEL = const DualKind(
294 error: const MessageKind(
295 'Error: Duplicate declaration of label "#{labelName}".'),
296 warning: const MessageKind(
297 'Warning: Duplicate declaration of label "#{labelName}".'));
298
299 static const MessageKind UNUSED_LABEL = const MessageKind(
300 'Warning: Unused label "#{labelName}".');
301
302 static const MessageKind INVALID_CONTINUE = const MessageKind(
303 'Error: Target of continue is not a loop or switch case.');
304
305 static const MessageKind INVALID_BREAK = const MessageKind(
306 'Error: Target of break is not a statement.');
307
308 static const MessageKind DUPLICATE_TYPE_VARIABLE_NAME = const MessageKind(
309 'Error: Type variable "#{typeVariableName}" already declared.');
310
311 static const DualKind TYPE_VARIABLE_WITHIN_STATIC_MEMBER = const DualKind(
312 error: const MessageKind(
313 'Error: Cannot refer to type variable "#{typeVariableName}" '
314 'within a static member.'),
315 warning: const MessageKind(
316 'Warning: Cannot refer to type variable "#{typeVariableName}" '
317 'within a static member.'));
318
319 static const MessageKind TYPE_VARIABLE_IN_CONSTANT = const MessageKind(
320 'Error: Cannot refer to type variable in constant.');
321
322 static const MessageKind INVALID_USE_OF_SUPER = const MessageKind(
323 'Error: "super" not allowed here.');
324
325 static const MessageKind INVALID_CASE_DEFAULT = const MessageKind(
326 'Error: "default" only allowed on last case of a switch.');
327
328 static const MessageKind SWITCH_CASE_TYPES_NOT_EQUAL = const MessageKind(
329 'Error: "case" expressions do not all have the same type.');
330
331 static const MessageKind SWITCH_CASE_VALUE_OVERRIDES_EQUALS =
332 const MessageKind(
333 'Error: "case" expression value overrides "operator==".');
334
335 static const MessageKind INVALID_ARGUMENT_AFTER_NAMED = const MessageKind(
336 'Error: Unnamed argument after named argument.');
337
338 static const MessageKind NOT_A_COMPILE_TIME_CONSTANT = const MessageKind(
339 'Error: Not a compile-time constant.');
340
341 static const MessageKind CYCLIC_COMPILE_TIME_CONSTANTS = const MessageKind(
342 'Error: Cycle in the compile-time constant computation.');
343
344 static const MessageKind CONSTRUCTOR_IS_NOT_CONST = const MessageKind(
345 'Error: Constructor is not a "const" constructor.');
346
347 static const MessageKind KEY_NOT_A_STRING_LITERAL = const MessageKind(
348 'Error: Map-literal key not a string literal.');
349
350 static const DualKind NO_SUCH_LIBRARY_MEMBER = const DualKind(
351 error: const MessageKind(
352 'Error: "#{libraryName}" has no member named "#{memberName}".'),
353 warning: const MessageKind(
354 'Warning: "#{libraryName}" has no member named "#{memberName}".'));
355
356 static const MessageKind CANNOT_INSTANTIATE_TYPEDEF = const MessageKind(
357 'Error: Cannot instantiate typedef "#{typedefName}".');
358
359 static const MessageKind CANNOT_INSTANTIATE_TYPE_VARIABLE = const MessageKind(
360 'Error: Cannot instantiate type variable "#{typeVariableName}".');
361
362 static const MessageKind CYCLIC_TYPE_VARIABLE = const MessageKind(
363 'Warning: Type variable "#{typeVariableName}" is a supertype of itself.');
364
365 static const MessageKind CLASS_NAME_EXPECTED = const MessageKind(
366 'Error: Class name expected.');
367
368 static const MessageKind CANNOT_EXTEND = const MessageKind(
369 'Error: "#{type}" cannot be extended.');
370
371 static const MessageKind CANNOT_IMPLEMENT = const MessageKind(
372 'Error: "#{type}" cannot be implemented.');
373
374 static const MessageKind DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind(
375 'Error: "#{type}" can not be both extended and implemented.');
376
377 static const MessageKind DUPLICATE_IMPLEMENTS = const MessageKind(
378 'Error: "#{type}" must not occur more than once '
379 'in the implements clause.');
380
381 static const MessageKind ILLEGAL_SUPER_SEND = const MessageKind(
382 'Error: "#{name}" cannot be called on super.');
383
384 static const DualKind NO_SUCH_SUPER_MEMBER = const DualKind(
385 error: const MessageKind(
386 'Error: Cannot resolve "#{memberName}" in a superclass of '
387 '"#{className}".'),
388 warning: const MessageKind(
389 'Warning: Cannot resolve "#{memberName}" in a superclass of '
390 '"#{className}".'));
391
392 static const DualKind ADDITIONAL_TYPE_ARGUMENT = const DualKind(
393 error: const MessageKind('Error: Additional type argument.'),
394 warning: const MessageKind('Warning: Additional type argument.'));
395
396 static const DualKind MISSING_TYPE_ARGUMENT = const DualKind(
397 error: const MessageKind('Error: Missing type argument.'),
398 warning: const MessageKind('Warning: Missing type argument.'));
244 399
245 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or MISSING_TYPE_ARGUMENT 400 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or MISSING_TYPE_ARGUMENT
246 // instead. 401 // instead.
247 static const TYPE_ARGUMENT_COUNT_MISMATCH = const MessageKind( 402 static const MessageKind TYPE_ARGUMENT_COUNT_MISMATCH = const MessageKind(
248 "incorrect number of type arguments on #{type}"); 403 'Error: Incorrect number of type arguments on "#{type}".');
249 404
250 static const MISSING_ARGUMENTS_TO_ASSERT = const MessageKind( 405 static const MessageKind GETTER_MISMATCH = const MessageKind(
251 "missing arguments to assert"); 406 'Error: Setter disagrees on: "#{modifiers}".');
252 407
253 static const GETTER_MISMATCH = const MessageKind( 408 static const MessageKind SETTER_MISMATCH = const MessageKind(
254 "Error: setter disagrees on: #{modifiers}."); 409 'Error: Getter disagrees on: "#{modifiers}".');
255 410
256 static const SETTER_MISMATCH = const MessageKind( 411 static const MessageKind ILLEGAL_SETTER_FORMALS = const MessageKind(
257 "Error: getter disagrees on: #{modifiers}."); 412 'Error: A setter must have exactly one argument.');
258 413
259 static const ILLEGAL_SETTER_FORMALS = const MessageKind( 414 static const MessageKind NO_STATIC_OVERRIDE = const MessageKind(
260 "Error: a setter must have exactly one argument."); 415 'Error: Static member cannot override instance member "#{memberName}" of '
261 416 '"#{className}".');
262 static const NO_STATIC_OVERRIDE = const MessageKind( 417
263 "Error: static member cannot override instance member '#{memberName}' of " 418 static const MessageKind NO_STATIC_OVERRIDE_CONT = const MessageKind(
264 "'#{className}'."); 419 'Info: This is the instance member that cannot be overridden '
265 420 'by a static member.');
266 static const NO_STATIC_OVERRIDE_CONT = const MessageKind( 421
267 "Info: this is the instance member that cannot be overridden " 422 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD =
268 "by a static member."); 423 const MessageKind(
269 424 'Error: Method cannot override field "#{memberName}" of '
270 static const CANNOT_OVERRIDE_FIELD_WITH_METHOD = const MessageKind( 425 '"#{className}".');
271 "Error: method cannot override field '#{memberName}' of '#{className}'."); 426
272 427 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT =
273 static const CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT = const MessageKind( 428 const MessageKind(
274 "Info: this is the field that cannot be overridden by a method."); 429 'Info: This is the field that cannot be overridden by a method.');
275 430
276 static const CANNOT_OVERRIDE_METHOD_WITH_FIELD = const MessageKind( 431 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD =
277 "Error: field cannot override method '#{memberName}' of '#{className}'."); 432 const MessageKind(
278 433 'Error: Field cannot override method "#{memberName}" of '
279 static const CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT = const MessageKind( 434 '"#{className}".');
280 "Info: this is the method that cannot be overridden by a field."); 435
281 436 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT =
282 static const BAD_ARITY_OVERRIDE = const MessageKind( 437 const MessageKind(
283 "Error: cannot override method '#{memberName}' in '#{className}'; " 438 'Info: This is the method that cannot be overridden by a field.');
284 "the parameters do not match."); 439
285 440 static const MessageKind BAD_ARITY_OVERRIDE = const MessageKind(
286 static const BAD_ARITY_OVERRIDE_CONT = const MessageKind( 441 'Error: Cannot override method "#{memberName}" in "#{className}"; '
287 "Info: this is the method whose parameters do not match."); 442 'the parameters do not match.');
288 443
289 static const MISSING_FORMALS = const MessageKind( 444 static const MessageKind BAD_ARITY_OVERRIDE_CONT = const MessageKind(
290 "Error: Formal parameters are missing."); 445 'Info: This is the method whose parameters do not match.');
291 446
292 static const EXTRA_FORMALS = const MessageKind( 447 static const MessageKind MISSING_FORMALS = const MessageKind(
293 "Error: Formal parameters are not allowed here."); 448 'Error: Formal parameters are missing.');
294 449
295 static const UNARY_OPERATOR_BAD_ARITY = const MessageKind( 450 static const MessageKind EXTRA_FORMALS = const MessageKind(
296 "Error: Operator #{operatorName} must have no parameters."); 451 'Error: Formal parameters are not allowed here.');
297 452
298 static const MINUS_OPERATOR_BAD_ARITY = const MessageKind( 453 static const MessageKind UNARY_OPERATOR_BAD_ARITY = const MessageKind(
299 "Error: Operator - must have 0 or 1 parameters."); 454 'Error: Operator "#{operatorName}" must have no parameters.');
300 455
301 static const BINARY_OPERATOR_BAD_ARITY = const MessageKind( 456 static const MessageKind MINUS_OPERATOR_BAD_ARITY = const MessageKind(
302 "Error: Operator #{operatorName} must have exactly 1 parameter."); 457 'Error: Operator "-" must have 0 or 1 parameters.');
303 458
304 static const TERNARY_OPERATOR_BAD_ARITY = const MessageKind( 459 static const MessageKind BINARY_OPERATOR_BAD_ARITY = const MessageKind(
305 "Error: Operator #{operatorName} must have exactly 2 parameters."); 460 'Error: Operator "#{operatorName}" must have exactly 1 parameter.');
306 461
307 static const OPERATOR_OPTIONAL_PARAMETERS = const MessageKind( 462 static const MessageKind TERNARY_OPERATOR_BAD_ARITY = const MessageKind(
308 "Error: Operator #{operatorName} cannot have optional parameters."); 463 'Error: Operator "#{operatorName}" must have exactly 2 parameters.');
309 464
310 static const OPERATOR_NAMED_PARAMETERS = const MessageKind( 465 static const MessageKind OPERATOR_OPTIONAL_PARAMETERS = const MessageKind(
311 "Error: Operator #{operatorName} cannot have named parameters."); 466 'Error: Operator "#{operatorName}" cannot have optional parameters.');
467
468 static const MessageKind OPERATOR_NAMED_PARAMETERS = const MessageKind(
469 'Error: Operator "#{operatorName}" cannot have named parameters.');
312 470
313 // TODO(ahe): This message is hard to localize. This is acceptable, 471 // TODO(ahe): This message is hard to localize. This is acceptable,
314 // as it will be removed when we ship Dart version 1.0. 472 // as it will be removed when we ship Dart version 1.0.
315 static const DEPRECATED_FEATURE_WARNING = const MessageKind( 473 static const MessageKind DEPRECATED_FEATURE_WARNING = const MessageKind(
316 "Warning: deprecated language feature, #{featureName}, " 474 'Warning: Deprecated language feature, #{featureName}, '
317 "will be removed in a future Dart milestone."); 475 'will be removed in a future Dart milestone.');
318 476
319 // TODO(ahe): This message is hard to localize. This is acceptable, 477 // TODO(ahe): This message is hard to localize. This is acceptable,
320 // as it will be removed when we ship Dart version 1.0. 478 // as it will be removed when we ship Dart version 1.0.
321 static const DEPRECATED_FEATURE_ERROR = const MessageKind( 479 static const MessageKind DEPRECATED_FEATURE_ERROR = const MessageKind(
322 "Error: #{featureName} are not legal " 480 'Error: #{featureName} are not legal '
323 "due to option --reject-deprecated-language-features."); 481 'due to option --reject-deprecated-language-features.');
324 482
325 static const CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind( 483 static const MessageKind CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind(
326 "Error: cannot have return type for constructor."); 484 'Error: Cannot have return type for constructor.');
327 485
328 static const ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind( 486 static const MessageKind ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind(
329 "Error: cannot have final modifier on method."); 487 'Error: Cannot have final modifier on method.');
330 488
331 static const ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind( 489 static const MessageKind ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind(
332 "Error: illegal constructor modifiers: #{modifiers}."); 490 'Error: Illegal constructor modifiers: "#{modifiers}".');
333 491
334 static const ILLEGAL_MIXIN_APPLICATION_MODIFIERS = const MessageKind( 492 static const MessageKind ILLEGAL_MIXIN_APPLICATION_MODIFIERS =
335 "Error: illegal mixin application modifiers: #{modifiers}."); 493 const MessageKind(
336 494 'Error: Illegal mixin application modifiers: "#{modifiers}".');
337 static const ILLEGAL_MIXIN_SUPERCLASS = const MessageKind( 495
338 "Error: class used as mixin must have Object as superclass."); 496 static const MessageKind ILLEGAL_MIXIN_SUPERCLASS = const MessageKind(
339 497 'Error: Class used as mixin must have Object as superclass.');
340 static const ILLEGAL_MIXIN_OBJECT = const MessageKind( 498
341 "Error: cannot use Object as mixin."); 499 static const MessageKind ILLEGAL_MIXIN_OBJECT = const MessageKind(
342 500 'Error: Cannot use Object as mixin.');
343 static const ILLEGAL_MIXIN_CONSTRUCTOR = const MessageKind( 501
344 "Error: class used as mixin cannot have non-factory constructor."); 502 static const MessageKind ILLEGAL_MIXIN_CONSTRUCTOR = const MessageKind(
345 503 'Error: Class used as mixin cannot have non-factory constructor.');
346 static const ILLEGAL_MIXIN_CYCLE = const MessageKind( 504
347 "Error: class used as mixin introduces mixin cycle: " 505 static const MessageKind ILLEGAL_MIXIN_CYCLE = const MessageKind(
348 "#{mixinName1} <-> #{mixinName2}."); 506 'Error: Class used as mixin introduces mixin cycle: '
349 507 '"#{mixinName1}" <-> "#{mixinName2}".');
350 static const ILLEGAL_MIXIN_WITH_SUPER = const MessageKind( 508
351 "Error: cannot use class #{className} as a mixin because it uses super."); 509 static const MessageKind ILLEGAL_MIXIN_WITH_SUPER = const MessageKind(
352 510 'Error: Cannot use class "#{className}" as a mixin because it uses '
353 static const ILLEGAL_MIXIN_SUPER_USE = const MessageKind( 511 '"super".');
354 "Use of super in class used as mixin."); 512
355 513 static const MessageKind ILLEGAL_MIXIN_SUPER_USE = const MessageKind(
356 static const PARAMETER_NAME_EXPECTED = const MessageKind( 514 'Info: Use of "super" in class used as mixin.');
357 "Error: parameter name expected."); 515
358 516 static const MessageKind PARAMETER_NAME_EXPECTED = const MessageKind(
359 static const CANNOT_RESOLVE_GETTER = const MessageKind( 517 'Error: parameter name expected.');
360 'cannot resolve getter.'); 518
361 519 static const DualKind CANNOT_RESOLVE_GETTER = const DualKind(
362 static const CANNOT_RESOLVE_SETTER = const MessageKind( 520 error: const MessageKind('Error: Cannot resolve getter.'),
363 'cannot resolve setter.'); 521 warning: const MessageKind('Warning: Cannot resolve getter.'));
364 522
365 static const CANNOT_RESOLVE_INDEX = const MessageKind( 523 static const DualKind CANNOT_RESOLVE_SETTER = const DualKind(
366 'cannot resolve [] member.'); 524 error: const MessageKind('Error: Cannot resolve setter.'),
367 525 warning: const MessageKind('Warning: Cannot resolve setter.'));
368 static const VOID_NOT_ALLOWED = const MessageKind( 526
369 'type void is only allowed in a return type.'); 527 static const MessageKind VOID_NOT_ALLOWED = const MessageKind(
370 528 'Error: Type "void" is only allowed in a return type.');
371 static const BEFORE_TOP_LEVEL = const MessageKind( 529
372 'Error: part header must come before top-level definitions.'); 530 static const MessageKind BEFORE_TOP_LEVEL = const MessageKind(
373 531 'Error: Part header must come before top-level definitions.');
374 static const LIBRARY_NAME_MISMATCH = const MessageKind( 532
375 'Warning: expected part of library name "#{libraryName}".'); 533 static const MessageKind LIBRARY_NAME_MISMATCH = const MessageKind(
376 534 'Warning: Expected part of library name "#{libraryName}".');
377 static const MISSING_PART_OF_TAG = const MessageKind( 535
536 static const MessageKind MISSING_PART_OF_TAG = const MessageKind(
378 'Note: This file has no part-of tag, but it is being used as a part.'); 537 'Note: This file has no part-of tag, but it is being used as a part.');
379 538
380 static const DUPLICATED_PART_OF = const MessageKind( 539 static const MessageKind DUPLICATED_PART_OF = const MessageKind(
381 'Error: duplicated part-of directive.'); 540 'Error: Duplicated part-of directive.');
382 541
383 static const ILLEGAL_DIRECTIVE = const MessageKind( 542 static const MessageKind ILLEGAL_DIRECTIVE = const MessageKind(
384 'Error: directive not allowed here.'); 543 'Error: Directive not allowed here.');
385 544
386 static const DUPLICATED_LIBRARY_NAME = const MessageKind( 545 static const MessageKind DUPLICATED_LIBRARY_NAME = const MessageKind(
387 'Warning: duplicated library name "#{libraryName}".'); 546 'Warning: Duplicated library name "#{libraryName}".');
388 547
389 static const INVALID_SOURCE_FILE_LOCATION = const MessageKind(''' 548 // This is used as an exception.
549 static const MessageKind INVALID_SOURCE_FILE_LOCATION = const MessageKind('''
390 Invalid offset (#{offset}) in source map. 550 Invalid offset (#{offset}) in source map.
391 File: #{fileName} 551 File: #{fileName}
392 Length: #{length}'''); 552 Length: #{length}''');
393 553
394 static const TOP_LEVEL_VARIABLE_DECLARED_STATIC = const MessageKind( 554 static const MessageKind TOP_LEVEL_VARIABLE_DECLARED_STATIC =
395 "Top-level variable cannot be declared static."); 555 const MessageKind(
396 556 'Error: Top-level variable cannot be declared static.');
397 static const WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT = const MessageKind( 557
398 "Wrong number of arguments to assert. Should be 1, but given " 558 static const MessageKind WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT =
399 "#{argumentCount}."); 559 const MessageKind(
400 560 'Error: Wrong number of arguments to assert. Should be 1, but given '
401 static const ASSERT_IS_GIVEN_NAMED_ARGUMENTS = const MessageKind( 561 '#{argumentCount}.');
402 "assert takes no named arguments, but given #{argumentCount}."); 562
403 563 static const MessageKind ASSERT_IS_GIVEN_NAMED_ARGUMENTS = const MessageKind(
404 static const FACTORY_REDIRECTION_IN_NON_FACTORY = const MessageKind( 564 'Error: "assert" takes no named arguments, but given #{argumentCount}.');
405 "Error: Factory redirection only allowed in factories."); 565
406 566 static const MessageKind FACTORY_REDIRECTION_IN_NON_FACTORY =
407 static const MISSING_FACTORY_KEYWORD = const MessageKind( 567 const MessageKind(
408 "Did you forget a factory keyword here?"); 568 'Error: Factory redirection only allowed in factories.');
409 569
410 static const DEFERRED_LIBRARY_NAME_MISMATCH = const MessageKind( 570 static const MessageKind MISSING_FACTORY_KEYWORD = const MessageKind(
411 'Error: Library name mismatch "#{expectedName}" != "#{actualName}".'); 571 'Hint: Did you forget a factory keyword here?');
412 572
413 static const ILLEGAL_STATIC = const MessageKind( 573 static const MessageKind DEFERRED_LIBRARY_NAME_MISMATCH =
414 "Error: Modifier static is only allowed on functions declared in" 574 const MessageKind(
415 " a class."); 575 'Error: Library name mismatch "#{expectedName}" != "#{actualName}".');
416 576
417 static const STATIC_FUNCTION_BLOAT = const MessageKind( 577 static const MessageKind ILLEGAL_STATIC = const MessageKind(
578 'Error: Modifier static is only allowed on functions declared in '
579 'a class.');
580
581 static const MessageKind STATIC_FUNCTION_BLOAT = const MessageKind(
418 'Hint: Using "#{class}.#{name}" may result in larger output.'); 582 'Hint: Using "#{class}.#{name}" may result in larger output.');
419 583
420 static const NON_CONST_BLOAT = const MessageKind(''' 584 static const MessageKind NON_CONST_BLOAT = const MessageKind('''
421 Hint: Using "new #{name}" may result in larger output. 585 Hint: Using "new #{name}" may result in larger output.
422 Use "const #{name}" if possible.'''); 586 Use "const #{name}" if possible.''');
423 587
424 static const STRING_EXPECTED = const MessageKind( 588 static const MessageKind STRING_EXPECTED = const MessageKind(
425 'Error: Expected a "String", but got an instance of "#{type}".'); 589 'Error: Expected a "String", but got an instance of "#{type}".');
426 590
427 static const PRIVATE_IDENTIFIER = const MessageKind( 591 static const MessageKind PRIVATE_IDENTIFIER = const MessageKind(
428 'Error: "#{value}" is not a valid Symbol name because it starts with ' 592 'Error: "#{value}" is not a valid Symbol name because it starts with '
429 '"_".'); 593 '"_".');
430 594
431 static const INVALID_SYMBOL = const MessageKind(''' 595 static const MessageKind INVALID_SYMBOL = const MessageKind('''
432 Error: "#{value}" is not a valid Symbol name because is not: 596 Error: "#{value}" is not a valid Symbol name because is not:
433 * an empty String, 597 * an empty String,
434 * a user defined operator, 598 * a user defined operator,
435 * a qualified non-private identifier optionally followed by "=", or 599 * a qualified non-private identifier optionally followed by "=", or
436 * a qualified non-private identifier followed by "." and a user-defined operato r.'''); 600 * a qualified non-private identifier followed by "." and a user-defined '''
437 601 'operator.');
438 static const AMBIGUOUS_REEXPORT = const MessageKind( 602
603 static const MessageKind AMBIGUOUS_REEXPORT = const MessageKind(
439 'Info: "#{element}" is (re)exported by multiple libraries.'); 604 'Info: "#{element}" is (re)exported by multiple libraries.');
440 605
441 static const AMBIGUOUS_LOCATION = const MessageKind( 606 static const MessageKind AMBIGUOUS_LOCATION = const MessageKind(
442 'Info: "#{element}" is defined here.'); 607 'Info: "#{element}" is defined here.');
443 608
444 static const IMPORTED_HERE = const MessageKind( 609 static const MessageKind IMPORTED_HERE = const MessageKind(
445 'Info: "#{element}" is imported here.'); 610 'Info: "#{element}" is imported here.');
446 611
447 static const OVERRIDE_EQUALS_NOT_HASH_CODE = const MessageKind( 612 static const MessageKind OVERRIDE_EQUALS_NOT_HASH_CODE = const MessageKind(
448 'Hint: The class "#{class}" overrides "operator==", ' 613 'Hint: The class "#{class}" overrides "operator==", '
449 'but not "get hashCode".'); 614 'but not "get hashCode".');
450 615
451 static const PACKAGE_ROOT_NOT_SET = const MessageKind( 616 static const MessageKind PACKAGE_ROOT_NOT_SET = const MessageKind(
452 "Error: Cannot resolve '#{uri}'. Package root has not been set."); 617 'Error: Cannot resolve "#{uri}". Package root has not been set.');
453 618
454 static const COMPILER_CRASHED = const MessageKind( 619 static const MessageKind COMPILER_CRASHED = const MessageKind(
455 "Error: The compiler crashed when compiling this element."); 620 'Error: The compiler crashed when compiling this element.');
456 621
457 static const PLEASE_REPORT_THE_CRASH = const MessageKind(''' 622 static const MessageKind PLEASE_REPORT_THE_CRASH = const MessageKind('''
458 The compiler is broken. 623 The compiler is broken.
459 624
460 When compiling the above element, the compiler crashed. It is not 625 When compiling the above element, the compiler crashed. It is not
461 possible to tell if this is caused by a problem in your program or 626 possible to tell if this is caused by a problem in your program or
462 not. Regardless, the compiler should not crash. 627 not. Regardless, the compiler should not crash.
463 628
464 The Dart team would greatly appreciate if you would take a moment to 629 The Dart team would greatly appreciate if you would take a moment to
465 report this problem at http://dartbug.com/new. 630 report this problem at http://dartbug.com/new.
466 631
467 Please include the following information: 632 Please include the following information:
468 633
469 * the name and version of your operating system, 634 * the name and version of your operating system,
470 635
471 * the Dart SDK build number (#{buildId}), and 636 * the Dart SDK build number (#{buildId}), and
472 637
473 * the entire message you see here (including the full stack trace 638 * the entire message you see here (including the full stack trace
474 below as well as the source location above). 639 below as well as the source location above).
475 '''); 640 ''');
476 641
477 642
478 ////////////////////////////////////////////////////////////////////////////// 643 //////////////////////////////////////////////////////////////////////////////
479 // Patch errors start. 644 // Patch errors start.
480 ////////////////////////////////////////////////////////////////////////////// 645 //////////////////////////////////////////////////////////////////////////////
481 646
482 static const PATCH_RETURN_TYPE_MISMATCH = const MessageKind( 647 static const MessageKind PATCH_RETURN_TYPE_MISMATCH = const MessageKind(
483 "Patch return type '#{patchReturnType}' doesn't match " 648 'Error: Patch return type "#{patchReturnType}" does not match '
484 "'#{originReturnType}' on origin method '#{methodName}'."); 649 '"#{originReturnType}" on origin method "#{methodName}".');
485 650
486 static const PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH = const MessageKind( 651 static const MessageKind PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH =
487 "Required parameter count of patch method (#{patchParameterCount}) " 652 const MessageKind(
488 "doesn't match parameter count on origin method '#{methodName}' " 653 'Error: Required parameter count of patch method '
489 "(#{originParameterCount})."); 654 '(#{patchParameterCount}) does not match parameter count on origin '
655 'method "#{methodName}" (#{originParameterCount}).');
490 656
491 static const PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH = const MessageKind( 657 static const MessageKind PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH =
492 "Optional parameter count of patch method (#{patchParameterCount}) " 658 const MessageKind(
493 "doesn't match parameter count on origin method '#{methodName}' " 659 'Error: Optional parameter count of patch method '
494 "(#{originParameterCount})."); 660 '(#{patchParameterCount}) does not match parameter count on origin '
661 'method "#{methodName}" (#{originParameterCount}).');
495 662
496 static const PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH = const MessageKind( 663 static const MessageKind PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH =
497 "Optional parameters of origin and patch method '#{methodName}' must " 664 const MessageKind(
498 "both be either named or positional."); 665 'Error: Optional parameters of origin and patch method '
666 '"#{methodName}" must both be either named or positional.');
499 667
500 static const PATCH_PARAMETER_MISMATCH = const MessageKind( 668 static const MessageKind PATCH_PARAMETER_MISMATCH = const MessageKind(
501 "Patch method parameter '#{patchParameter}' doesn't match " 669 'Error: Patch method parameter "#{patchParameter}" does not match '
502 "'#{originParameter}' on origin method #{methodName}."); 670 '"#{originParameter}" on origin method "#{methodName}".');
503 671
504 static const PATCH_PARAMETER_TYPE_MISMATCH = const MessageKind( 672 static const MessageKind PATCH_PARAMETER_TYPE_MISMATCH = const MessageKind(
505 "Patch method parameter '#{parameterName}' type #{patchParameterType} " 673 'Error: Patch method parameter "#{parameterName}" type '
506 "doesn't match #{originParameterType} on origin method #{methodName}."); 674 '"#{patchParameterType}" does not match "#{originParameterType}" on '
675 'origin method "#{methodName}".');
507 676
508 static const PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION = const MessageKind( 677 static const MessageKind PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION =
509 "External method without an implementation."); 678 const MessageKind('Error: External method without an implementation.');
510 679
511 static const PATCH_POINT_TO_FUNCTION = const MessageKind( 680 static const MessageKind PATCH_POINT_TO_FUNCTION = const MessageKind(
512 "Info: This is the function patch '#{functionName}'."); 681 'Info: This is the function patch "#{functionName}".');
513 682
514 static const PATCH_POINT_TO_CLASS = const MessageKind( 683 static const MessageKind PATCH_POINT_TO_CLASS = const MessageKind(
515 "Info: This is the class patch '#{className}'."); 684 'Info: This is the class patch "#{className}".');
516 685
517 static const PATCH_POINT_TO_GETTER = const MessageKind( 686 static const MessageKind PATCH_POINT_TO_GETTER = const MessageKind(
518 "Info: This is the getter patch '#{getterName}'."); 687 'Info: This is the getter patch "#{getterName}".');
519 688
520 static const PATCH_POINT_TO_SETTER = const MessageKind( 689 static const MessageKind PATCH_POINT_TO_SETTER = const MessageKind(
521 "Info: This is the setter patch '#{setterName}'."); 690 'Info: This is the setter patch "#{setterName}".');
522 691
523 static const PATCH_POINT_TO_CONSTRUCTOR = const MessageKind( 692 static const MessageKind PATCH_POINT_TO_CONSTRUCTOR = const MessageKind(
524 "Info: This is the constructor patch '#{constructorName}'."); 693 'Info: This is the constructor patch "#{constructorName}".');
525 694
526 static const PATCH_POINT_TO_PARAMETER = const MessageKind( 695 static const MessageKind PATCH_POINT_TO_PARAMETER = const MessageKind(
527 "Info: This is the patch parameter '#{parameterName}'."); 696 'Info: This is the patch parameter "#{parameterName}".');
528 697
529 static const PATCH_NON_EXISTING = const MessageKind( 698 static const MessageKind PATCH_NON_EXISTING = const MessageKind(
530 "Error: Origin does not exist for patch '#{name}'."); 699 'Error: Origin does not exist for patch "#{name}".');
531 700
532 static const PATCH_NONPATCHABLE = const MessageKind( 701 static const MessageKind PATCH_NONPATCHABLE = const MessageKind(
533 "Error: Only classes and functions can be patched."); 702 'Error: Only classes and functions can be patched.');
534 703
535 static const PATCH_NON_EXTERNAL = const MessageKind( 704 static const MessageKind PATCH_NON_EXTERNAL = const MessageKind(
536 "Error: Only external functions can be patched."); 705 'Error: Only external functions can be patched.');
537 706
538 static const PATCH_NON_CLASS = const MessageKind( 707 static const MessageKind PATCH_NON_CLASS = const MessageKind(
539 "Error: Patching non-class with class patch '#{className}'."); 708 'Error: Patching non-class with class patch "#{className}".');
540 709
541 static const PATCH_NON_GETTER = const MessageKind( 710 static const MessageKind PATCH_NON_GETTER = const MessageKind(
542 "Error: Cannot patch non-getter '#{name}' with getter patch."); 711 'Error: Cannot patch non-getter "#{name}" with getter patch.');
543 712
544 static const PATCH_NO_GETTER = const MessageKind( 713 static const MessageKind PATCH_NO_GETTER = const MessageKind(
545 "Error: No getter found for getter patch '#{getterName}'."); 714 'Error: No getter found for getter patch "#{getterName}".');
546 715
547 static const PATCH_NON_SETTER = const MessageKind( 716 static const MessageKind PATCH_NON_SETTER = const MessageKind(
548 "Error: Cannot patch non-setter '#{name}' with setter patch."); 717 'Error: Cannot patch non-setter "#{name}" with setter patch.');
549 718
550 static const PATCH_NO_SETTER = const MessageKind( 719 static const MessageKind PATCH_NO_SETTER = const MessageKind(
551 "Error: No setter found for setter patch '#{setterName}'."); 720 'Error: No setter found for setter patch "#{setterName}".');
552 721
553 static const PATCH_NON_CONSTRUCTOR = const MessageKind( 722 static const MessageKind PATCH_NON_CONSTRUCTOR = const MessageKind(
554 "Error: Cannot patch non-constructor with constructor patch " 723 'Error: Cannot patch non-constructor with constructor patch '
555 "'#{constructorName}'."); 724 '"#{constructorName}".');
556 725
557 static const PATCH_NON_FUNCTION = const MessageKind( 726 static const MessageKind PATCH_NON_FUNCTION = const MessageKind(
558 "Error: Cannot patch non-function with function patch " 727 'Error: Cannot patch non-function with function patch '
559 "'#{functionName}'."); 728 '"#{functionName}".');
560 729
561 ////////////////////////////////////////////////////////////////////////////// 730 //////////////////////////////////////////////////////////////////////////////
562 // Patch errors end. 731 // Patch errors end.
563 ////////////////////////////////////////////////////////////////////////////// 732 //////////////////////////////////////////////////////////////////////////////
564 733
565 toString() => template; 734 toString() => template;
566 735
567 Message message([Map arguments = const {}]) { 736 Message message([Map arguments = const {}]) {
568 return new Message(this, arguments); 737 return new Message(this, arguments);
569 } 738 }
570 739
571 CompilationError error([Map arguments = const {}]) { 740 CompilationError error([Map arguments = const {}]) {
572 return new CompilationError(this, arguments); 741 return new CompilationError(this, arguments);
573 } 742 }
574 } 743 }
575 744
745 class DualKind {
746 final MessageKind error;
747 final MessageKind warning;
748
749 const DualKind({this.error, this.warning});
750 }
751
576 class Message { 752 class Message {
577 final kind; 753 final kind;
578 final Map arguments; 754 final Map arguments;
579 String message; 755 String message;
580 756
581 Message(this.kind, this.arguments) { 757 Message(this.kind, this.arguments) {
582 assert(() { computeMessage(); return true; }); 758 assert(() { computeMessage(); return true; });
583 } 759 }
584 760
585 String computeMessage() { 761 String computeMessage() {
586 if (message == null) { 762 if (message == null) {
587 message = kind.template; 763 message = kind.template;
588 arguments.forEach((key, value) { 764 arguments.forEach((key, value) {
589 String string = slowToString(value); 765 String string = slowToString(value);
590 message = message.replaceAll('#{${key}}', string); 766 message = message.replaceAll('#{${key}}', string);
591 }); 767 });
592 assert(invariant( 768 assert(invariant(
593 CURRENT_ELEMENT_SPANNABLE, 769 CURRENT_ELEMENT_SPANNABLE,
594 !message.contains(new RegExp(r"#\{.+\}")), 770 !message.contains(new RegExp(r'#\{.+\}')),
595 message: 'Missing arguments in error message: "$message"')); 771 message: 'Missing arguments in error message: "$message"'));
596 } 772 }
597 return message; 773 return message;
598 } 774 }
599 775
600 String toString() { 776 String toString() {
601 return computeMessage(); 777 return computeMessage();
602 } 778 }
603 779
604 bool operator==(other) { 780 bool operator==(other) {
(...skipping 17 matching lines...) Expand all
622 Diagnostic(MessageKind kind, [Map arguments = const {}]) 798 Diagnostic(MessageKind kind, [Map arguments = const {}])
623 : message = new Message(kind, arguments); 799 : message = new Message(kind, arguments);
624 String toString() => message.toString(); 800 String toString() => message.toString();
625 } 801 }
626 802
627 class TypeWarning extends Diagnostic { 803 class TypeWarning extends Diagnostic {
628 TypeWarning(MessageKind kind, [Map arguments = const {}]) 804 TypeWarning(MessageKind kind, [Map arguments = const {}])
629 : super(kind, arguments); 805 : super(kind, arguments);
630 } 806 }
631 807
632 class ResolutionError extends Diagnostic {
633 ResolutionError(MessageKind kind, [Map arguments = const {}])
634 : super(kind, arguments);
635 }
636
637 class ResolutionWarning extends Diagnostic { 808 class ResolutionWarning extends Diagnostic {
638 ResolutionWarning(MessageKind kind, [Map arguments = const {}]) 809 ResolutionWarning(MessageKind kind, [Map arguments = const {}])
639 : super(kind, arguments); 810 : super(kind, arguments);
640 } 811 }
641 812
642 class CompileTimeConstantError extends Diagnostic { 813 class CompileTimeConstantError extends Diagnostic {
643 CompileTimeConstantError(MessageKind kind, [Map arguments = const {}]) 814 CompileTimeConstantError(MessageKind kind, [Map arguments = const {}])
644 : super(kind, arguments); 815 : super(kind, arguments);
645 } 816 }
646 817
647 class CompilationError extends Diagnostic { 818 class CompilationError extends Diagnostic {
648 CompilationError(MessageKind kind, [Map arguments = const {}]) 819 CompilationError(MessageKind kind, [Map arguments = const {}])
649 : super(kind, arguments); 820 : super(kind, arguments);
650 } 821 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698