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

Side by Side Diff: pkg/compiler/lib/src/warnings.dart

Issue 1248483008: Split MessageKind into a MessageKind key and a MessageTemplate. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | tests/compiler/dart2js/analyze_only_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
6
7 const DONT_KNOW_HOW_TO_FIX = "Computer says no!";
8 5
9 /** 6 /**
10 * The messages in this file should meet the following guide lines: 7 * The messages in this file should meet the following guide lines:
11 * 8 *
12 * 1. The message should be a complete sentence starting with an uppercase 9 * 1. The message should be a complete sentence starting with an uppercase
13 * letter, and ending with a period. 10 * letter, and ending with a period.
14 * 11 *
15 * 2. Reserved words and embedded identifiers should be in single quotes, so 12 * 2. Reserved words and embedded identifiers should be in single quotes, so
16 * prefer double quotes for the complete message. For example, "The 13 * prefer double quotes for the complete message. For example, "The
17 * class '#{className}' can't use 'super'." Notice that the word 'class' in the 14 * class '#{className}' can't use 'super'." Notice that the word 'class' in the
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 * An INFO message should always be preceded by a non-INFO message, and the 53 * An INFO message should always be preceded by a non-INFO message, and the
57 * INFO messages are additional details about the preceding non-INFO 54 * INFO messages are additional details about the preceding non-INFO
58 * message. For example, consider duplicated elements. First report a WARNING 55 * message. For example, consider duplicated elements. First report a WARNING
59 * or ERROR about the duplicated element, and then report an INFO about the 56 * or ERROR about the duplicated element, and then report an INFO about the
60 * location of the existing element. 57 * location of the existing element.
61 * 58 *
62 * Generally, we want to provide messages that consists of three sentences: 59 * Generally, we want to provide messages that consists of three sentences:
63 * 1. what is wrong, 2. why is it wrong, 3. how do I fix it. However, we 60 * 1. what is wrong, 2. why is it wrong, 3. how do I fix it. However, we
64 * combine the first two in [template] and the last in [howToFix]. 61 * combine the first two in [template] and the last in [howToFix].
65 */ 62 */
63
64 library dart2js.messages;
65
66 import 'dart2jslib.dart';
67 import 'scanner/scannerlib.dart';
68
69 const DONT_KNOW_HOW_TO_FIX = "Computer says no!";
70
71 /// Keys for the [MessageTemplate]s.
72 enum MessageKind {
73 ABSTRACT_CLASS_INSTANTIATION,
74 ABSTRACT_GETTER,
75 ABSTRACT_METHOD,
76 ABSTRACT_SETTER,
77 ACCESSED_IN_CLOSURE,
78 ACCESSED_IN_CLOSURE_HERE,
79 ADDITIONAL_ARGUMENT,
80 ADDITIONAL_TYPE_ARGUMENT,
81 ALREADY_INITIALIZED,
82 AMBIGUOUS_LOCATION,
83 AMBIGUOUS_REEXPORT,
84 ASSERT_IS_GIVEN_NAMED_ARGUMENTS,
85 ASSIGNING_METHOD,
86 ASSIGNING_METHOD_IN_SUPER,
87 ASSIGNING_TYPE,
88 ASYNC_KEYWORD_AS_IDENTIFIER,
89 ASYNC_MODIFIER_ON_ABSTRACT_METHOD,
90 ASYNC_MODIFIER_ON_CONSTRUCTOR,
91 ASYNC_MODIFIER_ON_SETTER,
92 AWAIT_MEMBER_NOT_FOUND,
93 AWAIT_MEMBER_NOT_FOUND_IN_CLOSURE,
94 BAD_INPUT_CHARACTER,
95 BEFORE_TOP_LEVEL,
96 BINARY_OPERATOR_BAD_ARITY,
97 BODY_EXPECTED,
98 CALL_NOT_SUPPORTED_ON_NATIVE_CLASS,
99 CANNOT_EXTEND,
100 CANNOT_EXTEND_ENUM,
101 CANNOT_EXTEND_MALFORMED,
102 CANNOT_FIND_CONSTRUCTOR,
103 CANNOT_IMPLEMENT,
104 CANNOT_IMPLEMENT_ENUM,
105 CANNOT_IMPLEMENT_MALFORMED,
106 CANNOT_INSTANTIATE_ENUM,
107 CANNOT_INSTANTIATE_TYPE_VARIABLE,
108 CANNOT_INSTANTIATE_TYPEDEF,
109 CANNOT_MIXIN,
110 CANNOT_MIXIN_ENUM,
111 CANNOT_MIXIN_MALFORMED,
112 CANNOT_OVERRIDE_FIELD_WITH_METHOD,
113 CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT,
114 CANNOT_OVERRIDE_GETTER_WITH_METHOD,
115 CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT,
116 CANNOT_OVERRIDE_METHOD_WITH_FIELD,
117 CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT,
118 CANNOT_OVERRIDE_METHOD_WITH_GETTER,
119 CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT,
120 CANNOT_RESOLVE,
121 CANNOT_RESOLVE_AWAIT,
122 CANNOT_RESOLVE_AWAIT_IN_CLOSURE,
123 CANNOT_RESOLVE_CONSTRUCTOR,
124 CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT,
125 CANNOT_RESOLVE_GETTER,
126 CANNOT_RESOLVE_IN_INITIALIZER,
127 CANNOT_RESOLVE_SETTER,
128 CANNOT_RESOLVE_TYPE,
129 CANNOT_RETURN_FROM_CONSTRUCTOR,
130 CLASS_NAME_EXPECTED,
131 COMPILER_CRASHED,
132 COMPLEX_RETURNING_NSM,
133 COMPLEX_THROWING_NSM,
134 CONSIDER_ANALYZE_ALL,
135 CONST_CALLS_NON_CONST,
136 CONST_CALLS_NON_CONST_FOR_IMPLICIT,
137 CONST_CONSTRUCTOR_HAS_BODY,
138 CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS,
139 CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
140 CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD,
141 CONST_MAP_KEY_OVERRIDES_EQUALS,
142 CONST_WITHOUT_INITIALIZER,
143 CONSTRUCTOR_CALL_EXPECTED,
144 CONSTRUCTOR_IS_NOT_CONST,
145 CONSTRUCTOR_WITH_RETURN_TYPE,
146 CYCLIC_CLASS_HIERARCHY,
147 CYCLIC_COMPILE_TIME_CONSTANTS,
148 CYCLIC_REDIRECTING_FACTORY,
149 CYCLIC_TYPE_VARIABLE,
150 CYCLIC_TYPEDEF,
151 CYCLIC_TYPEDEF_ONE,
152 DART_EXT_NOT_SUPPORTED,
153 DEFERRED_COMPILE_TIME_CONSTANT,
154 DEFERRED_COMPILE_TIME_CONSTANT_CONSTRUCTION,
155 DEFERRED_LIBRARY_DART_2_DART,
156 DEFERRED_LIBRARY_DUPLICATE_PREFIX,
157 DEFERRED_LIBRARY_WITHOUT_PREFIX,
158 DEFERRED_OLD_SYNTAX,
159 DEFERRED_TYPE_ANNOTATION,
160 DEPRECATED_TYPEDEF_MIXIN_SYNTAX,
161 DIRECTLY_THROWING_NSM,
162 DUPLICATE_DEFINITION,
163 DUPLICATE_EXPORT,
164 DUPLICATE_EXPORT_CONT,
165 DUPLICATE_EXPORT_DECL,
166 DUPLICATE_EXTENDS_IMPLEMENTS,
167 DUPLICATE_IMPLEMENTS,
168 DUPLICATE_IMPORT,
169 DUPLICATE_INITIALIZER,
170 DUPLICATE_LABEL,
171 DUPLICATE_SUPER_INITIALIZER,
172 DUPLICATE_TYPE_VARIABLE_NAME,
173 DUPLICATED_LIBRARY_NAME,
174 DUPLICATED_LIBRARY_RESOURCE,
175 DUPLICATED_PART_OF,
176 DUPLICATED_RESOURCE,
177 EMPTY_CATCH_DECLARATION,
178 EMPTY_ENUM_DECLARATION,
179 EQUAL_MAP_ENTRY_KEY,
180 EXISTING_DEFINITION,
181 EXISTING_LABEL,
182 EXPECTED_IDENTIFIER_NOT_RESERVED_WORD,
183 EXPONENT_MISSING,
184 EXPORT_BEFORE_PARTS,
185 EXTERNAL_WITH_BODY,
186 EXTRA_CATCH_DECLARATION,
187 EXTRA_FORMALS,
188 EXTRANEOUS_MODIFIER,
189 EXTRANEOUS_MODIFIER_REPLACE,
190 FACTORY_REDIRECTION_IN_NON_FACTORY,
191 FINAL_FUNCTION_TYPE_PARAMETER,
192 FINAL_WITHOUT_INITIALIZER,
193 FORMAL_DECLARED_CONST,
194 FORMAL_DECLARED_STATIC,
195 FUNCTION_TYPE_FORMAL_WITH_DEFAULT,
196 FUNCTION_WITH_INITIALIZER,
197 GENERIC,
198 GETTER_MISMATCH,
199 GETTER_NOT_FOUND,
200 HEX_DIGIT_EXPECTED,
201 HIDDEN_HINTS,
202 HIDDEN_IMPLICIT_IMPORT,
203 HIDDEN_IMPORT,
204 HIDDEN_WARNINGS,
205 HIDDEN_WARNINGS_HINTS,
206 IF_NULL_ASSIGNING_TYPE,
207 ILLEGAL_CONST_FIELD_MODIFIER,
208 ILLEGAL_CONSTRUCTOR_MODIFIERS,
209 ILLEGAL_FINAL_METHOD_MODIFIER,
210 ILLEGAL_MIXIN_APPLICATION_MODIFIERS,
211 ILLEGAL_MIXIN_CONSTRUCTOR,
212 ILLEGAL_MIXIN_CYCLE,
213 ILLEGAL_MIXIN_OBJECT,
214 ILLEGAL_MIXIN_SUPER_USE,
215 ILLEGAL_MIXIN_SUPERCLASS,
216 ILLEGAL_MIXIN_WITH_SUPER,
217 ILLEGAL_SETTER_FORMALS,
218 ILLEGAL_STATIC,
219 ILLEGAL_SUPER_SEND,
220 IMPORT_BEFORE_PARTS,
221 IMPORT_EXPERIMENTAL_MIRRORS,
222 IMPORT_PART_OF,
223 IMPORTED_HERE,
224 INHERIT_GETTER_AND_METHOD,
225 INHERITED_EXPLICIT_GETTER,
226 INHERITED_IMPLICIT_GETTER,
227 INHERITED_METHOD,
228 INIT_STATIC_FIELD,
229 INITIALIZING_FORMAL_NOT_ALLOWED,
230 INSTANCE_STATIC_SAME_NAME,
231 INSTANCE_STATIC_SAME_NAME_CONT,
232 INTERNAL_LIBRARY,
233 INTERNAL_LIBRARY_FROM,
234 INVALID_ARGUMENT_AFTER_NAMED,
235 INVALID_AWAIT_FOR,
236 INVALID_BREAK,
237 INVALID_CASE_DEFAULT,
238 INVALID_CONSTRUCTOR_ARGUMENTS,
239 INVALID_CONSTRUCTOR_NAME,
240 INVALID_CONTINUE,
241 INVALID_FOR_IN,
242 INVALID_INITIALIZER,
243 INVALID_OVERRIDDEN_FIELD,
244 INVALID_OVERRIDDEN_GETTER,
245 INVALID_OVERRIDDEN_METHOD,
246 INVALID_OVERRIDDEN_SETTER,
247 INVALID_OVERRIDE_FIELD,
248 INVALID_OVERRIDE_FIELD_WITH_GETTER,
249 INVALID_OVERRIDE_FIELD_WITH_SETTER,
250 INVALID_OVERRIDE_GETTER,
251 INVALID_OVERRIDE_GETTER_WITH_FIELD,
252 INVALID_OVERRIDE_METHOD,
253 INVALID_OVERRIDE_SETTER,
254 INVALID_OVERRIDE_SETTER_WITH_FIELD,
255 INVALID_PACKAGE_URI,
256 INVALID_PARAMETER,
257 INVALID_RECEIVER_IN_INITIALIZER,
258 INVALID_SOURCE_FILE_LOCATION,
259 INVALID_SYMBOL,
260 INVALID_SYNC_MODIFIER,
261 INVALID_TYPE_VARIABLE_BOUND,
262 INVALID_UNNAMED_CONSTRUCTOR_NAME,
263 INVALID_URI,
264 INVALID_USE_OF_SUPER,
265 LIBRARY_NAME_MISMATCH,
266 LIBRARY_NOT_FOUND,
267 LIBRARY_TAG_MUST_BE_FIRST,
268 MAIN_NOT_A_FUNCTION,
269 MAIN_WITH_EXTRA_PARAMETER,
270 MALFORMED_STRING_LITERAL,
271 MEMBER_NOT_FOUND,
272 MEMBER_NOT_STATIC,
273 MEMBER_USES_CLASS_NAME,
274 METHOD_NOT_FOUND,
275 MINUS_OPERATOR_BAD_ARITY,
276 MIRROR_BLOAT,
277 MIRROR_IMPORT,
278 MIRROR_IMPORT_NO_USAGE,
279 MIRRORS_CANNOT_FIND_IN_ELEMENT,
280 MIRRORS_CANNOT_RESOLVE_IN_CURRENT_LIBRARY,
281 MIRRORS_CANNOT_RESOLVE_IN_LIBRARY,
282 MIRRORS_EXPECTED_STRING,
283 MIRRORS_EXPECTED_STRING_OR_LIST,
284 MIRRORS_EXPECTED_STRING_OR_TYPE,
285 MIRRORS_EXPECTED_STRING_TYPE_OR_LIST,
286 MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND,
287 MISSING_ARGUMENT,
288 MISSING_ENUM_CASES,
289 MISSING_FACTORY_KEYWORD,
290 MISSING_FORMALS,
291 MISSING_LIBRARY_NAME,
292 MISSING_MAIN,
293 MISSING_PART_OF_TAG,
294 MISSING_TOKEN_AFTER_THIS,
295 MISSING_TOKEN_BEFORE_THIS,
296 MISSING_TYPE_ARGUMENT,
297 MULTI_INHERITANCE,
298 NAMED_ARGUMENT_NOT_FOUND,
299 NAMED_FUNCTION_EXPRESSION,
300 NAMED_PARAMETER_WITH_EQUALS,
301 NATIVE_NOT_SUPPORTED,
302 NO_BREAK_TARGET,
303 NO_CATCH_NOR_FINALLY,
304 NO_CONTINUE_TARGET,
305 NO_INSTANCE_AVAILABLE,
306 NO_MATCHING_CONSTRUCTOR,
307 NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT,
308 NO_STATIC_OVERRIDE,
309 NO_STATIC_OVERRIDE_CONT,
310 NO_SUCH_LIBRARY_MEMBER,
311 NO_SUCH_METHOD_IN_NATIVE,
312 NO_SUCH_SUPER_MEMBER,
313 NO_SUPER_IN_STATIC,
314 NO_THIS_AVAILABLE,
315 NON_CONST_BLOAT,
316 NOT_A_COMPILE_TIME_CONSTANT,
317 NOT_A_FIELD,
318 NOT_A_PREFIX,
319 NOT_A_TYPE,
320 NOT_ASSIGNABLE,
321 NOT_CALLABLE,
322 NOT_INSTANCE_FIELD,
323 NOT_MORE_SPECIFIC,
324 NOT_MORE_SPECIFIC_SUBTYPE,
325 NOT_MORE_SPECIFIC_SUGGESTION,
326 NULL_NOT_ALLOWED,
327 ONLY_ONE_LIBRARY_TAG,
328 OPERATOR_NAMED_PARAMETERS,
329 OPERATOR_NOT_FOUND,
330 OPERATOR_OPTIONAL_PARAMETERS,
331 OPTIONAL_PARAMETER_IN_CATCH,
332 OVERRIDE_EQUALS_NOT_HASH_CODE,
333 PARAMETER_NAME_EXPECTED,
334 PARAMETER_WITH_MODIFIER_IN_CATCH,
335 PARAMETER_WITH_TYPE_IN_CATCH,
336 PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION,
337 PATCH_NO_GETTER,
338 PATCH_NO_SETTER,
339 PATCH_NON_CLASS,
340 PATCH_NON_CONSTRUCTOR,
341 PATCH_NON_EXISTING,
342 PATCH_NON_EXTERNAL,
343 PATCH_NON_FUNCTION,
344 PATCH_NON_GETTER,
345 PATCH_NON_SETTER,
346 PATCH_NONPATCHABLE,
347 PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH,
348 PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH,
349 PATCH_PARAMETER_MISMATCH,
350 PATCH_PARAMETER_TYPE_MISMATCH,
351 PATCH_POINT_TO_CLASS,
352 PATCH_POINT_TO_CONSTRUCTOR,
353 PATCH_POINT_TO_FUNCTION,
354 PATCH_POINT_TO_GETTER,
355 PATCH_POINT_TO_PARAMETER,
356 PATCH_POINT_TO_SETTER,
357 PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH,
358 PATCH_RETURN_TYPE_MISMATCH,
359 PLEASE_REPORT_THE_CRASH,
360 POSITIONAL_PARAMETER_WITH_EQUALS,
361 POTENTIAL_MUTATION,
362 POTENTIAL_MUTATION_HERE,
363 POTENTIAL_MUTATION_IN_CLOSURE,
364 POTENTIAL_MUTATION_IN_CLOSURE_HERE,
365 PREAMBLE,
366 PREFIX_AS_EXPRESSION,
367 PRIVATE_ACCESS,
368 PRIVATE_IDENTIFIER,
369 PRIVATE_NAMED_PARAMETER,
370 READ_SCRIPT_ERROR,
371 READ_SELF_ERROR,
372 REDIRECTING_CONSTRUCTOR_CYCLE,
373 REDIRECTING_CONSTRUCTOR_HAS_BODY,
374 REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER,
375 REDIRECTING_FACTORY_WITH_DEFAULT,
376 REFERENCE_IN_INITIALIZATION,
377 REQUIRED_PARAMETER_WITH_DEFAULT,
378 RETURN_IN_GENERATOR,
379 RETURN_NOTHING,
380 RETURN_VALUE_IN_VOID,
381 SETTER_MISMATCH,
382 SETTER_NOT_FOUND,
383 SETTER_NOT_FOUND_IN_SUPER,
384 STATIC_FUNCTION_BLOAT,
385 STRING_EXPECTED,
386 SUPER_INITIALIZER_IN_OBJECT,
387 SWITCH_CASE_FORBIDDEN,
388 SWITCH_CASE_TYPES_NOT_EQUAL,
389 SWITCH_CASE_TYPES_NOT_EQUAL_CASE,
390 SWITCH_CASE_VALUE_OVERRIDES_EQUALS,
391 TERNARY_OPERATOR_BAD_ARITY,
392 THIS_IS_THE_DECLARATION,
393 THIS_IS_THE_METHOD,
394 THIS_IS_THE_PART_OF_TAG,
395 THIS_PROPERTY,
396 THROW_WITHOUT_EXPRESSION,
397 TOP_LEVEL_VARIABLE_DECLARED_STATIC,
398 TYPE_ARGUMENT_COUNT_MISMATCH,
399 TYPE_VARIABLE_IN_CONSTANT,
400 TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
401 TYPEDEF_FORMAL_WITH_DEFAULT,
402 UNARY_OPERATOR_BAD_ARITY,
403 UNBOUND_LABEL,
404 UNIMPLEMENTED_EXPLICIT_GETTER,
405 UNIMPLEMENTED_EXPLICIT_SETTER,
406 UNIMPLEMENTED_GETTER,
407 UNIMPLEMENTED_GETTER_ONE,
408 UNIMPLEMENTED_IMPLICIT_GETTER,
409 UNIMPLEMENTED_IMPLICIT_SETTER,
410 UNIMPLEMENTED_METHOD,
411 UNIMPLEMENTED_METHOD_CONT,
412 UNIMPLEMENTED_METHOD_ONE,
413 UNIMPLEMENTED_SETTER,
414 UNIMPLEMENTED_SETTER_ONE,
415 UNMATCHED_TOKEN,
416 UNSUPPORTED_BANG_EQ_EQ,
417 UNSUPPORTED_EQ_EQ_EQ,
418 UNSUPPORTED_LITERAL_SYMBOL,
419 UNSUPPORTED_PREFIX_PLUS,
420 UNSUPPORTED_THROW_WITHOUT_EXP,
421 UNTERMINATED_COMMENT,
422 UNTERMINATED_STRING,
423 UNTERMINATED_TOKEN,
424 UNUSED_CLASS,
425 UNUSED_LABEL,
426 UNUSED_METHOD,
427 UNUSED_TYPEDEF,
428 VAR_FUNCTION_TYPE_PARAMETER,
429 VOID_EXPRESSION,
430 VOID_NOT_ALLOWED,
431 VOID_VARIABLE,
432 WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT,
433 WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT,
434 YIELDING_MODIFIER_ON_ARROW_BODY,
435 }
436
437 /// A message template for an error, warning, hint or info message generated
438 /// by the compiler. Each template is associated with a [MessageKind] that
439 /// uniquely identifies the message template.
66 // TODO(johnnniwinther): For Infos, consider adding a reference to the 440 // TODO(johnnniwinther): For Infos, consider adding a reference to the
67 // error/warning/hint that they belong to. 441 // error/warning/hint that they belong to.
68 class MessageKind { 442 class MessageTemplate {
443 final MessageKind kind;
444
69 /// Should describe what is wrong and why. 445 /// Should describe what is wrong and why.
70 final String template; 446 final String template;
71 447
72 /// Should describe how to fix the problem. Elided when using --terse option. 448 /// Should describe how to fix the problem. Elided when using --terse option.
73 final String howToFix; 449 final String howToFix;
74 450
75 /** 451 /**
76 * Examples will be checked by 452 * Examples will be checked by
77 * tests/compiler/dart2js/message_kind_test.dart. 453 * tests/compiler/dart2js/message_kind_test.dart.
78 * 454 *
79 * An example is either a String containing the example source code or a Map 455 * An example is either a String containing the example source code or a Map
80 * from filenames to source code. In the latter case, the filename for the 456 * from filenames to source code. In the latter case, the filename for the
81 * main library code must be 'main.dart'. 457 * main library code must be 'main.dart'.
82 */ 458 */
83 final List examples; 459 final List examples;
84 460
85 /// Additional options needed for the examples to work. 461 /// Additional options needed for the examples to work.
86 final List<String> options; 462 final List<String> options;
87 463
88 const MessageKind(this.template, 464 const MessageTemplate(
89 {this.howToFix, 465 this.kind,
90 this.examples, 466 this.template,
91 this.options: const <String>[]}); 467 {this.howToFix,
468 this.examples,
469 this.options: const <String>[]});
92 470
93 /// Do not use this. It is here for legacy and debugging. It violates item 4 471 /// All templates used by the compiler.
94 /// above. 472 ///
95 static const MessageKind GENERIC = const MessageKind('#{text}'); 473 /// The map is complete mapping from [MessageKind] to their corresponding
474 /// [MessageTemplate].
475 static const Map<MessageKind, MessageTemplate> TEMPLATES =
476 const <MessageKind, MessageTemplate>{
477 /// Do not use this. It is here for legacy and debugging. It violates item
478 /// 4 of the guide lines for error messages in the beginning of the file.
479 MessageKind.GENERIC:
480 const MessageTemplate(MessageKind.GENERIC, '#{text}'),
96 481
97 static const MessageKind NOT_ASSIGNABLE = const MessageKind( 482 MessageKind.NOT_ASSIGNABLE:
98 "'#{fromType}' is not assignable to '#{toType}'."); 483 const MessageTemplate(MessageKind.NOT_ASSIGNABLE,
484 "'#{fromType}' is not assignable to '#{toType}'."),
99 485
100 static const MessageKind VOID_EXPRESSION = const MessageKind( 486 MessageKind.VOID_EXPRESSION:
101 "Expression does not yield a value."); 487 const MessageTemplate(MessageKind.VOID_EXPRESSION,
488 "Expression does not yield a value."),
102 489
103 static const MessageKind VOID_VARIABLE = const MessageKind( 490 MessageKind.VOID_VARIABLE:
104 "Variable cannot be of type void."); 491 const MessageTemplate(MessageKind.VOID_VARIABLE,
492 "Variable cannot be of type void."),
105 493
106 static const MessageKind RETURN_VALUE_IN_VOID = const MessageKind( 494 MessageKind.RETURN_VALUE_IN_VOID:
107 "Cannot return value from void function."); 495 const MessageTemplate(MessageKind.RETURN_VALUE_IN_VOID,
496 "Cannot return value from void function."),
108 497
109 static const MessageKind RETURN_NOTHING = const MessageKind( 498 MessageKind.RETURN_NOTHING:
110 "Value of type '#{returnType}' expected."); 499 const MessageTemplate(MessageKind.RETURN_NOTHING,
500 "Value of type '#{returnType}' expected."),
111 501
112 static const MessageKind MISSING_ARGUMENT = const MessageKind( 502 MessageKind.MISSING_ARGUMENT:
113 "Missing argument of type '#{argumentType}'."); 503 const MessageTemplate(MessageKind.MISSING_ARGUMENT,
504 "Missing argument of type '#{argumentType}'."),
114 505
115 static const MessageKind ADDITIONAL_ARGUMENT = const MessageKind( 506 MessageKind.ADDITIONAL_ARGUMENT:
116 "Additional argument."); 507 const MessageTemplate(MessageKind.ADDITIONAL_ARGUMENT,
508 "Additional argument."),
117 509
118 static const MessageKind NAMED_ARGUMENT_NOT_FOUND = const MessageKind( 510 MessageKind.NAMED_ARGUMENT_NOT_FOUND:
119 "No named argument '#{argumentName}' found on method."); 511 const MessageTemplate(MessageKind.NAMED_ARGUMENT_NOT_FOUND,
512 "No named argument '#{argumentName}' found on method."),
120 513
121 static const MessageKind MEMBER_NOT_FOUND = const MessageKind( 514 MessageKind.MEMBER_NOT_FOUND:
122 "No member named '#{memberName}' in class '#{className}'."); 515 const MessageTemplate(MessageKind.MEMBER_NOT_FOUND,
516 "No member named '#{memberName}' in class '#{className}'."),
123 517
124 static const MessageKind AWAIT_MEMBER_NOT_FOUND = const MessageKind( 518 MessageKind.AWAIT_MEMBER_NOT_FOUND:
125 "No member named 'await' in class '#{className}'.", 519 const MessageTemplate(MessageKind.AWAIT_MEMBER_NOT_FOUND,
126 howToFix: "Did you mean to add the 'async' marker " 520 "No member named 'await' in class '#{className}'.",
127 "to '#{functionName}'?", 521 howToFix: "Did you mean to add the 'async' marker "
128 examples: const [""" 522 "to '#{functionName}'?",
523 examples: const ["""
129 class A { 524 class A {
130 m() => await -3; 525 m() => await -3;
131 } 526 }
132 main() => new A().m(); 527 main() => new A().m();
133 """]); 528 """]),
134 529
135 static const MessageKind AWAIT_MEMBER_NOT_FOUND_IN_CLOSURE = 530 MessageKind.AWAIT_MEMBER_NOT_FOUND_IN_CLOSURE:
136 const MessageKind("No member named 'await' in class '#{className}'.", 531 const MessageTemplate(MessageKind.AWAIT_MEMBER_NOT_FOUND_IN_CLOSURE,
137 howToFix: "Did you mean to add the 'async' marker " 532 "No member named 'await' in class '#{className}'.",
138 "to the enclosing function?", 533 howToFix: "Did you mean to add the 'async' marker "
139 examples: const [""" 534 "to the enclosing function?",
535 examples: const ["""
140 class A { 536 class A {
141 m() => () => await -3; 537 m() => () => await -3;
142 } 538 }
143 main() => new A().m(); 539 main() => new A().m();
144 """]); 540 """]),
145 541
146 static const MessageKind METHOD_NOT_FOUND = const MessageKind( 542 MessageKind.METHOD_NOT_FOUND:
147 "No method named '#{memberName}' in class '#{className}'."); 543 const MessageTemplate(MessageKind.METHOD_NOT_FOUND,
544 "No method named '#{memberName}' in class '#{className}'."),
148 545
149 static const MessageKind OPERATOR_NOT_FOUND = const MessageKind( 546 MessageKind.OPERATOR_NOT_FOUND:
150 "No operator '#{memberName}' in class '#{className}'."); 547 const MessageTemplate(MessageKind.OPERATOR_NOT_FOUND,
548 "No operator '#{memberName}' in class '#{className}'."),
151 549
152 static const MessageKind SETTER_NOT_FOUND = const MessageKind( 550 MessageKind.SETTER_NOT_FOUND:
153 "No setter named '#{memberName}' in class '#{className}'."); 551 const MessageTemplate(MessageKind.SETTER_NOT_FOUND,
552 "No setter named '#{memberName}' in class '#{className}'."),
154 553
155 static const MessageKind SETTER_NOT_FOUND_IN_SUPER = const MessageKind( 554 MessageKind.SETTER_NOT_FOUND_IN_SUPER:
156 "No setter named '#{name}' in superclass of '#{className}'."); 555 const MessageTemplate(MessageKind.SETTER_NOT_FOUND_IN_SUPER,
556 "No setter named '#{name}' in superclass of '#{className}'."),
157 557
158 static const MessageKind GETTER_NOT_FOUND = const MessageKind( 558 MessageKind.GETTER_NOT_FOUND:
159 "No getter named '#{memberName}' in class '#{className}'."); 559 const MessageTemplate(MessageKind.GETTER_NOT_FOUND,
560 "No getter named '#{memberName}' in class '#{className}'."),
160 561
161 static const MessageKind NOT_CALLABLE = const MessageKind( 562 MessageKind.NOT_CALLABLE:
162 "'#{elementName}' is not callable."); 563 const MessageTemplate(MessageKind.NOT_CALLABLE,
564 "'#{elementName}' is not callable."),
163 565
164 static const MessageKind MEMBER_NOT_STATIC = const MessageKind( 566 MessageKind.MEMBER_NOT_STATIC:
165 "'#{className}.#{memberName}' is not static."); 567 const MessageTemplate(MessageKind.MEMBER_NOT_STATIC,
568 "'#{className}.#{memberName}' is not static."),
166 569
167 static const MessageKind NO_INSTANCE_AVAILABLE = const MessageKind( 570 MessageKind.NO_INSTANCE_AVAILABLE:
168 "'#{name}' is only available in instance methods."); 571 const MessageTemplate(MessageKind.NO_INSTANCE_AVAILABLE,
572 "'#{name}' is only available in instance methods."),
169 573
170 static const MessageKind NO_THIS_AVAILABLE = const MessageKind( 574 MessageKind.NO_THIS_AVAILABLE:
171 "'this' is only available in instance methods."); 575 const MessageTemplate(MessageKind.NO_THIS_AVAILABLE,
576 "'this' is only available in instance methods."),
172 577
173 static const MessageKind PRIVATE_ACCESS = const MessageKind( 578 MessageKind.PRIVATE_ACCESS:
174 "'#{name}' is declared private within library " 579 const MessageTemplate(MessageKind.PRIVATE_ACCESS,
175 "'#{libraryName}'."); 580 "'#{name}' is declared private within library "
581 "'#{libraryName}'."),
176 582
177 static const MessageKind THIS_IS_THE_DECLARATION = const MessageKind( 583 MessageKind.THIS_IS_THE_DECLARATION:
178 "This is the declaration of '#{name}'."); 584 const MessageTemplate(MessageKind.THIS_IS_THE_DECLARATION,
585 "This is the declaration of '#{name}'."),
179 586
180 static const MessageKind THIS_IS_THE_METHOD = const MessageKind( 587 MessageKind.THIS_IS_THE_METHOD:
181 "This is the method declaration."); 588 const MessageTemplate(MessageKind.THIS_IS_THE_METHOD,
589 "This is the method declaration."),
182 590
183 static const MessageKind CANNOT_RESOLVE = const MessageKind( 591 MessageKind.CANNOT_RESOLVE:
184 "Cannot resolve '#{name}'."); 592 const MessageTemplate(MessageKind.CANNOT_RESOLVE,
593 "Cannot resolve '#{name}'."),
185 594
186 static const MessageKind CANNOT_RESOLVE_AWAIT = const MessageKind( 595 MessageKind.CANNOT_RESOLVE_AWAIT:
187 "Cannot resolve '#{name}'.", 596 const MessageTemplate(MessageKind.CANNOT_RESOLVE_AWAIT,
188 howToFix: "Did you mean to add the 'async' marker " 597 "Cannot resolve '#{name}'.",
189 "to '#{functionName}'?", 598 howToFix: "Did you mean to add the 'async' marker "
190 examples: const [ 599 "to '#{functionName}'?",
191 "main() => await -3;", 600 examples: const [
192 "foo() => await -3; main() => foo();" 601 "main() => await -3;",
193 ]); 602 "foo() => await -3; main() => foo();"
603 ]),
194 604
195 static const MessageKind CANNOT_RESOLVE_AWAIT_IN_CLOSURE = const MessageKind( 605 MessageKind.CANNOT_RESOLVE_AWAIT_IN_CLOSURE:
196 "Cannot resolve '#{name}'.", 606 const MessageTemplate(MessageKind.CANNOT_RESOLVE_AWAIT_IN_CLOSURE,
197 howToFix: "Did you mean to add the 'async' marker " 607 "Cannot resolve '#{name}'.",
198 "to the enclosing function?", 608 howToFix: "Did you mean to add the 'async' marker "
199 examples: const [ 609 "to the enclosing function?",
200 "main() { (() => await -3)(); }", 610 examples: const [
201 ]); 611 "main() { (() => await -3)(); }",
612 ]),
202 613
203 static const MessageKind CANNOT_RESOLVE_IN_INITIALIZER = const MessageKind( 614 MessageKind.CANNOT_RESOLVE_IN_INITIALIZER:
204 "Cannot resolve '#{name}'. It would be implicitly looked up on this " 615 const MessageTemplate(MessageKind.CANNOT_RESOLVE_IN_INITIALIZER,
205 "instance, but instances are not available in initializers.", 616 "Cannot resolve '#{name}'. It would be implicitly looked up on this "
206 howToFix: "Try correcting the unresolved reference or move the " 617 "instance, but instances are not available in initializers.",
207 "initialization to a constructor body.", 618 howToFix: "Try correcting the unresolved reference or move the "
208 examples: const [""" 619 "initialization to a constructor body.",
620 examples: const ["""
209 class A { 621 class A {
210 var test = unresolvedName; 622 var test = unresolvedName;
211 } 623 }
212 main() => new A(); 624 main() => new A();
213 """]); 625 """]),
214 626
215 static const MessageKind CANNOT_RESOLVE_CONSTRUCTOR = const MessageKind( 627 MessageKind.CANNOT_RESOLVE_CONSTRUCTOR:
216 "Cannot resolve constructor '#{constructorName}'."); 628 const MessageTemplate(MessageKind.CANNOT_RESOLVE_CONSTRUCTOR,
629 "Cannot resolve constructor '#{constructorName}'."),
217 630
218 static const MessageKind CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT = 631 MessageKind.CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT:
219 const MessageKind("cannot resolve constructor '#{constructorName}'" 632 const MessageTemplate(
220 " for implicit super call.", 633 MessageKind.CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT,
221 howToFix: "Try explicitly invoking a constructor of the super class", 634 "cannot resolve constructor '#{constructorName}' "
222 examples: const [""" 635 "for implicit super call.",
636 howToFix: "Try explicitly invoking a constructor of the super class",
637 examples: const ["""
223 class A { 638 class A {
224 A.foo() {} 639 A.foo() {}
225 } 640 }
226 class B extends A { 641 class B extends A {
227 B(); 642 B();
228 } 643 }
229 main() => new B(); 644 main() => new B();
230 """]); 645 """]),
231 646
232 static const MessageKind INVALID_UNNAMED_CONSTRUCTOR_NAME = const MessageKind( 647 MessageKind.INVALID_UNNAMED_CONSTRUCTOR_NAME:
233 "Unnamed constructor name must be '#{name}'."); 648 const MessageTemplate(MessageKind.INVALID_UNNAMED_CONSTRUCTOR_NAME,
649 "Unnamed constructor name must be '#{name}'."),
234 650
235 static const MessageKind INVALID_CONSTRUCTOR_NAME = const MessageKind( 651 MessageKind.INVALID_CONSTRUCTOR_NAME:
236 "Constructor name must start with '#{name}'."); 652 const MessageTemplate(MessageKind.INVALID_CONSTRUCTOR_NAME,
653 "Constructor name must start with '#{name}'."),
237 654
238 static const MessageKind CANNOT_RESOLVE_TYPE = const MessageKind( 655 MessageKind.CANNOT_RESOLVE_TYPE:
239 "Cannot resolve type '#{typeName}'."); 656 const MessageTemplate(MessageKind.CANNOT_RESOLVE_TYPE,
657 "Cannot resolve type '#{typeName}'."),
240 658
241 static const MessageKind DUPLICATE_DEFINITION = const MessageKind( 659 MessageKind.DUPLICATE_DEFINITION:
242 "Duplicate definition of '#{name}'.", 660 const MessageTemplate(MessageKind.DUPLICATE_DEFINITION,
243 howToFix: "Try to rename or remove this definition.", 661 "Duplicate definition of '#{name}'.",
244 examples: const [""" 662 howToFix: "Try to rename or remove this definition.",
663 examples: const ["""
245 class C { 664 class C {
246 void f() {} 665 void f() {}
247 int get f => 1; 666 int get f => 1;
248 } 667 }
249 668
250 main() { 669 main() {
251 new C(); 670 new C();
252 } 671 }
253 672
254 """]); 673 """]),
255 674
256 static const MessageKind EXISTING_DEFINITION = const MessageKind( 675 MessageKind.EXISTING_DEFINITION:
257 "Existing definition of '#{name}'."); 676 const MessageTemplate(MessageKind.EXISTING_DEFINITION,
677 "Existing definition of '#{name}'."),
258 678
259 static const MessageKind DUPLICATE_IMPORT = const MessageKind( 679 MessageKind.DUPLICATE_IMPORT:
260 "Duplicate import of '#{name}'."); 680 const MessageTemplate(MessageKind.DUPLICATE_IMPORT,
681 "Duplicate import of '#{name}'."),
261 682
262 static const MessageKind HIDDEN_IMPORT = const MessageKind( 683 MessageKind.HIDDEN_IMPORT:
263 "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' " 684 const MessageTemplate(MessageKind.HIDDEN_IMPORT,
264 "from library '#{hidingUri}'.", 685 "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' "
265 howToFix: "Try adding 'hide #{name}' to the import of '#{hiddenUri}'.", 686 "from library '#{hidingUri}'.",
266 examples: const [ 687 howToFix:
267 const { 688 "Try adding 'hide #{name}' to the import of '#{hiddenUri}'.",
689 examples: const [
690 const {
268 'main.dart': 691 'main.dart':
269 """ 692 """
270 import 'dart:async'; // This imports a class Future. 693 import 'dart:async'; // This imports a class Future.
271 import 'future.dart'; 694 import 'future.dart';
272 695
273 void main() => new Future();""", 696 void main() => new Future();""",
274 697
275 'future.dart': 698 'future.dart':
276 """ 699 """
277 library future; 700 library future;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 """ 740 """
318 import 'future.dart' as prefix; 741 import 'future.dart' as prefix;
319 import 'dart:async' as prefix; // This imports a class Future. 742 import 'dart:async' as prefix; // This imports a class Future.
320 743
321 void main() => new prefix.Future();""", 744 void main() => new prefix.Future();""",
322 745
323 'future.dart': 746 'future.dart':
324 """ 747 """
325 library future; 748 library future;
326 749
327 class Future {}"""}]); 750 class Future {}"""}]),
328 751
329 752
330 static const MessageKind HIDDEN_IMPLICIT_IMPORT = const MessageKind( 753 MessageKind.HIDDEN_IMPLICIT_IMPORT:
331 "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' " 754 const MessageTemplate(MessageKind.HIDDEN_IMPLICIT_IMPORT,
332 "from library '#{hidingUri}'.", 755 "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' "
333 howToFix: "Try adding an explicit " 756 "from library '#{hidingUri}'.",
334 "'import \"#{hiddenUri}\" hide #{name}'.", 757 howToFix: "Try adding an explicit "
335 examples: const [ 758 "'import \"#{hiddenUri}\" hide #{name}'.",
336 const { 759 examples: const [
760 const {
337 'main.dart': 761 'main.dart':
338 """ 762 """
339 // This hides the implicit import of class Type from dart:core. 763 // This hides the implicit import of class Type from dart:core.
340 import 'type.dart'; 764 import 'type.dart';
341 765
342 void main() => new Type();""", 766 void main() => new Type();""",
343 767
344 'type.dart': 768 'type.dart':
345 """ 769 """
346 library type; 770 library type;
(...skipping 21 matching lines...) Expand all
368 'main.dart': 792 'main.dart':
369 r""" 793 r"""
370 library testDartConflicts; 794 library testDartConflicts;
371 795
372 import 'conflictsWithDart.dart'; 796 import 'conflictsWithDart.dart';
373 import 'conflictsWithDartAsWell.dart'; 797 import 'conflictsWithDartAsWell.dart';
374 798
375 main() { 799 main() {
376 print("Hail Caesar ${Duration.x}"); 800 print("Hail Caesar ${Duration.x}");
377 } 801 }
378 """}]); 802 """}]),
379 803
380 static const MessageKind DUPLICATE_EXPORT = const MessageKind( 804 MessageKind.DUPLICATE_EXPORT:
381 "Duplicate export of '#{name}'.", 805 const MessageTemplate(MessageKind.DUPLICATE_EXPORT,
382 howToFix: "Trying adding 'hide #{name}' to one of the exports.", 806 "Duplicate export of '#{name}'.",
383 examples: const [const { 807 howToFix: "Trying adding 'hide #{name}' to one of the exports.",
808 examples: const [const {
384 'main.dart': """ 809 'main.dart': """
385 export 'decl1.dart'; 810 export 'decl1.dart';
386 export 'decl2.dart'; 811 export 'decl2.dart';
387 812
388 main() {}""", 813 main() {}""",
389 'decl1.dart': "class Class {}", 814 'decl1.dart': "class Class {}",
390 'decl2.dart': "class Class {}"}]); 815 'decl2.dart': "class Class {}"}]),
391 816
392 static const MessageKind DUPLICATE_EXPORT_CONT = const MessageKind( 817 MessageKind.DUPLICATE_EXPORT_CONT:
393 "This is another export of '#{name}'."); 818 const MessageTemplate(MessageKind.DUPLICATE_EXPORT_CONT,
819 "This is another export of '#{name}'."),
394 820
395 static const MessageKind DUPLICATE_EXPORT_DECL = const MessageKind( 821 MessageKind.DUPLICATE_EXPORT_DECL:
396 "The exported '#{name}' from export #{uriString} is defined here."); 822 const MessageTemplate(MessageKind.DUPLICATE_EXPORT_DECL,
823 "The exported '#{name}' from export #{uriString} is defined here."),
397 824
398 static const MessageKind NOT_A_TYPE = const MessageKind( 825 MessageKind.NOT_A_TYPE:
399 "'#{node}' is not a type."); 826 const MessageTemplate(MessageKind.NOT_A_TYPE,
827 "'#{node}' is not a type."),
400 828
401 static const MessageKind NOT_A_PREFIX = const MessageKind( 829 MessageKind.NOT_A_PREFIX:
402 "'#{node}' is not a prefix."); 830 const MessageTemplate(MessageKind.NOT_A_PREFIX,
831 "'#{node}' is not a prefix."),
403 832
404 static const MessageKind PREFIX_AS_EXPRESSION = const MessageKind( 833 MessageKind.PREFIX_AS_EXPRESSION:
405 "Library prefix '#{prefix}' is not a valid expression."); 834 const MessageTemplate(MessageKind.PREFIX_AS_EXPRESSION,
835 "Library prefix '#{prefix}' is not a valid expression."),
406 836
407 static const MessageKind CANNOT_FIND_CONSTRUCTOR = const MessageKind( 837 MessageKind.CANNOT_FIND_CONSTRUCTOR:
408 "Cannot find constructor '#{constructorName}'."); 838 const MessageTemplate(MessageKind.CANNOT_FIND_CONSTRUCTOR,
839 "Cannot find constructor '#{constructorName}'."),
409 840
410 static const MessageKind CYCLIC_CLASS_HIERARCHY = const MessageKind( 841 MessageKind.CYCLIC_CLASS_HIERARCHY:
411 "'#{className}' creates a cycle in the class hierarchy."); 842 const MessageTemplate(MessageKind.CYCLIC_CLASS_HIERARCHY,
843 "'#{className}' creates a cycle in the class hierarchy."),
412 844
413 static const MessageKind CYCLIC_REDIRECTING_FACTORY = const MessageKind( 845 MessageKind.CYCLIC_REDIRECTING_FACTORY:
414 'Redirecting factory leads to a cyclic redirection.'); 846 const MessageTemplate(MessageKind.CYCLIC_REDIRECTING_FACTORY,
847 'Redirecting factory leads to a cyclic redirection.'),
415 848
416 static const MessageKind INVALID_RECEIVER_IN_INITIALIZER = const MessageKind( 849 MessageKind.INVALID_RECEIVER_IN_INITIALIZER:
417 "Field initializer expected."); 850 const MessageTemplate(MessageKind.INVALID_RECEIVER_IN_INITIALIZER,
851 "Field initializer expected."),
418 852
419 static const MessageKind NO_SUPER_IN_STATIC = const MessageKind( 853 MessageKind.NO_SUPER_IN_STATIC:
420 "'super' is only available in instance methods."); 854 const MessageTemplate(MessageKind.NO_SUPER_IN_STATIC,
855 "'super' is only available in instance methods."),
421 856
422 static const MessageKind DUPLICATE_INITIALIZER = const MessageKind( 857 MessageKind.DUPLICATE_INITIALIZER:
423 "Field '#{fieldName}' is initialized more than once."); 858 const MessageTemplate(MessageKind.DUPLICATE_INITIALIZER,
859 "Field '#{fieldName}' is initialized more than once."),
424 860
425 static const MessageKind ALREADY_INITIALIZED = const MessageKind( 861 MessageKind.ALREADY_INITIALIZED:
426 "'#{fieldName}' was already initialized here."); 862 const MessageTemplate(MessageKind.ALREADY_INITIALIZED,
863 "'#{fieldName}' was already initialized here."),
427 864
428 static const MessageKind INIT_STATIC_FIELD = const MessageKind( 865 MessageKind.INIT_STATIC_FIELD:
429 "Cannot initialize static field '#{fieldName}'."); 866 const MessageTemplate(MessageKind.INIT_STATIC_FIELD,
867 "Cannot initialize static field '#{fieldName}'."),
430 868
431 static const MessageKind NOT_A_FIELD = const MessageKind( 869 MessageKind.NOT_A_FIELD:
432 "'#{fieldName}' is not a field."); 870 const MessageTemplate(MessageKind.NOT_A_FIELD,
871 "'#{fieldName}' is not a field."),
433 872
434 static const MessageKind CONSTRUCTOR_CALL_EXPECTED = const MessageKind( 873 MessageKind.CONSTRUCTOR_CALL_EXPECTED:
435 "only call to 'this' or 'super' constructor allowed."); 874 const MessageTemplate(MessageKind.CONSTRUCTOR_CALL_EXPECTED,
875 "only call to 'this' or 'super' constructor allowed."),
436 876
437 static const MessageKind INVALID_FOR_IN = const MessageKind( 877 MessageKind.INVALID_FOR_IN:
438 "Invalid for-in variable declaration."); 878 const MessageTemplate(MessageKind.INVALID_FOR_IN,
879 "Invalid for-in variable declaration."),
439 880
440 static const MessageKind INVALID_INITIALIZER = const MessageKind( 881 MessageKind.INVALID_INITIALIZER:
441 "Invalid initializer."); 882 const MessageTemplate(MessageKind.INVALID_INITIALIZER,
883 "Invalid initializer."),
442 884
443 static const MessageKind FUNCTION_WITH_INITIALIZER = const MessageKind( 885 MessageKind.FUNCTION_WITH_INITIALIZER:
444 "Only constructors can have initializers."); 886 const MessageTemplate(MessageKind.FUNCTION_WITH_INITIALIZER,
887 "Only constructors can have initializers."),
445 888
446 static const MessageKind REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind( 889 MessageKind.REDIRECTING_CONSTRUCTOR_CYCLE:
447 "Cyclic constructor redirection."); 890 const MessageTemplate(MessageKind.REDIRECTING_CONSTRUCTOR_CYCLE,
891 "Cyclic constructor redirection."),
448 892
449 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind( 893 MessageKind.REDIRECTING_CONSTRUCTOR_HAS_BODY:
450 "Redirecting constructor can't have a body."); 894 const MessageTemplate(MessageKind.REDIRECTING_CONSTRUCTOR_HAS_BODY,
895 "Redirecting constructor can't have a body."),
451 896
452 static const MessageKind CONST_CONSTRUCTOR_HAS_BODY = const MessageKind( 897 MessageKind.CONST_CONSTRUCTOR_HAS_BODY:
453 "Const constructor or factory can't have a body.", 898 const MessageTemplate(MessageKind.CONST_CONSTRUCTOR_HAS_BODY,
454 howToFix: "Remove the 'const' keyword or the body", 899 "Const constructor or factory can't have a body.",
455 examples: const [""" 900 howToFix: "Remove the 'const' keyword or the body",
901 examples: const ["""
456 class C { 902 class C {
457 const C() {} 903 const C() {}
458 } 904 }
459 905
460 main() => new C();"""]); 906 main() => new C();"""]),
461 907
462 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER = 908 MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER:
463 const MessageKind( 909 const MessageTemplate(
464 "Redirecting constructor cannot have other initializers."); 910 MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER,
911 "Redirecting constructor cannot have other initializers."),
465 912
466 static const MessageKind SUPER_INITIALIZER_IN_OBJECT = const MessageKind( 913 MessageKind.SUPER_INITIALIZER_IN_OBJECT:
467 "'Object' cannot have a super initializer."); 914 const MessageTemplate(MessageKind.SUPER_INITIALIZER_IN_OBJECT,
915 "'Object' cannot have a super initializer."),
468 916
469 static const MessageKind DUPLICATE_SUPER_INITIALIZER = const MessageKind( 917 MessageKind.DUPLICATE_SUPER_INITIALIZER:
470 "Cannot have more than one super initializer."); 918 const MessageTemplate(MessageKind.DUPLICATE_SUPER_INITIALIZER,
919 "Cannot have more than one super initializer."),
471 920
472 static const MessageKind INVALID_CONSTRUCTOR_ARGUMENTS = const MessageKind( 921 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS:
473 "Arguments do not match the expected parameters of constructor " 922 const MessageTemplate(MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS,
474 "'#{constructorName}'."); 923 "Arguments do not match the expected parameters of constructor "
924 "'#{constructorName}'."),
475 925
476 static const MessageKind NO_MATCHING_CONSTRUCTOR = const MessageKind( 926 MessageKind.NO_MATCHING_CONSTRUCTOR:
477 "'super' call arguments and constructor parameters do not match."); 927 const MessageTemplate(MessageKind.NO_MATCHING_CONSTRUCTOR,
928 "'super' call arguments and constructor parameters do not match."),
478 929
479 static const MessageKind NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT = 930 MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT:
480 const MessageKind( 931 const MessageTemplate(MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT,
481 "Implicit 'super' call arguments and constructor parameters " 932 "Implicit 'super' call arguments and constructor parameters "
482 "do not match."); 933 "do not match."),
483 934
484 static const MessageKind CONST_CALLS_NON_CONST = const MessageKind( 935 MessageKind.CONST_CALLS_NON_CONST:
485 "'const' constructor cannot call a non-const constructor."); 936 const MessageTemplate(MessageKind.CONST_CALLS_NON_CONST,
937 "'const' constructor cannot call a non-const constructor."),
486 938
487 static const MessageKind CONST_CALLS_NON_CONST_FOR_IMPLICIT = 939 MessageKind.CONST_CALLS_NON_CONST_FOR_IMPLICIT:
488 const MessageKind( 940 const MessageTemplate(MessageKind.CONST_CALLS_NON_CONST_FOR_IMPLICIT,
489 "'const' constructor cannot call a non-const constructor. " 941 "'const' constructor cannot call a non-const constructor. "
490 "This constructor has an implicit call to a " 942 "This constructor has an implicit call to a "
491 "super non-const constructor.", 943 "super non-const constructor.",
492 howToFix: "Try making the super constructor const.", 944 howToFix: "Try making the super constructor const.",
493 examples: const [""" 945 examples: const ["""
494 class C { 946 class C {
495 C(); // missing const 947 C(); // missing const
496 } 948 }
497 class D extends C { 949 class D extends C {
498 final d; 950 final d;
499 const D(this.d); 951 const D(this.d);
500 } 952 }
501 main() => new D(0);"""]); 953 main() => new D(0);"""]),
502 954
503 static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS = 955 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS:
504 const MessageKind( 956 const MessageTemplate(
957 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS,
505 "Can't declare constructor 'const' on class #{className} " 958 "Can't declare constructor 'const' on class #{className} "
506 "because the class contains non-final instance fields.", 959 "because the class contains non-final instance fields.",
507 howToFix: "Try making all fields final.", 960 howToFix: "Try making all fields final.",
508 examples: const [""" 961 examples: const ["""
509 class C { 962 class C {
510 // 'a' must be declared final to allow for the const constructor. 963 // 'a' must be declared final to allow for the const constructor.
511 var a; 964 var a;
512 const C(this.a); 965 const C(this.a);
513 } 966 }
514 967
515 main() => new C(0);"""]); 968 main() => new C(0);"""]),
516 969
517 static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD = 970 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD:
518 const MessageKind("This non-final field prevents using const " 971 const MessageTemplate(
519 "constructors."); 972 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD,
973 "This non-final field prevents using const constructors."),
520 974
521 static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR = 975 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR:
522 const MessageKind("This const constructor is not allowed due to " 976 const MessageTemplate(
523 "non-final fields."); 977 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
978 "This const constructor is not allowed due to "
979 "non-final fields."),
524 980
525 981
526 static const MessageKind INITIALIZING_FORMAL_NOT_ALLOWED = const MessageKind( 982 MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED:
527 "Initializing formal parameter only allowed in generative " 983 const MessageTemplate(MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED,
528 "constructor."); 984 "Initializing formal parameter only allowed in generative "
985 "constructor."),
529 986
530 static const MessageKind INVALID_PARAMETER = const MessageKind( 987 MessageKind.INVALID_PARAMETER:
531 "Cannot resolve parameter."); 988 const MessageTemplate(MessageKind.INVALID_PARAMETER,
989 "Cannot resolve parameter."),
532 990
533 static const MessageKind NOT_INSTANCE_FIELD = const MessageKind( 991 MessageKind.NOT_INSTANCE_FIELD:
534 "'#{fieldName}' is not an instance field."); 992 const MessageTemplate(MessageKind.NOT_INSTANCE_FIELD,
993 "'#{fieldName}' is not an instance field."),
535 994
536 static const MessageKind THIS_PROPERTY = const MessageKind( 995 MessageKind.THIS_PROPERTY:
537 "Expected an identifier."); 996 const MessageTemplate(MessageKind.THIS_PROPERTY,
997 "Expected an identifier."),
538 998
539 static const MessageKind NO_CATCH_NOR_FINALLY = const MessageKind( 999 MessageKind.NO_CATCH_NOR_FINALLY:
540 "Expected 'catch' or 'finally'."); 1000 const MessageTemplate(MessageKind.NO_CATCH_NOR_FINALLY,
1001 "Expected 'catch' or 'finally'."),
541 1002
542 static const MessageKind EMPTY_CATCH_DECLARATION = const MessageKind( 1003 MessageKind.EMPTY_CATCH_DECLARATION:
543 "Expected an identifier in catch declaration."); 1004 const MessageTemplate(MessageKind.EMPTY_CATCH_DECLARATION,
1005 "Expected an identifier in catch declaration."),
544 1006
545 static const MessageKind EXTRA_CATCH_DECLARATION = const MessageKind( 1007 MessageKind.EXTRA_CATCH_DECLARATION:
546 "Extra parameter in catch declaration."); 1008 const MessageTemplate(MessageKind.EXTRA_CATCH_DECLARATION,
1009 "Extra parameter in catch declaration."),
547 1010
548 static const MessageKind PARAMETER_WITH_TYPE_IN_CATCH = const MessageKind( 1011 MessageKind.PARAMETER_WITH_TYPE_IN_CATCH:
549 "Cannot use type annotations in catch."); 1012 const MessageTemplate(MessageKind.PARAMETER_WITH_TYPE_IN_CATCH,
1013 "Cannot use type annotations in catch."),
550 1014
551 static const MessageKind PARAMETER_WITH_MODIFIER_IN_CATCH = const MessageKind( 1015 MessageKind.PARAMETER_WITH_MODIFIER_IN_CATCH:
552 "Cannot use modifiers in catch."); 1016 const MessageTemplate(MessageKind.PARAMETER_WITH_MODIFIER_IN_CATCH,
1017 "Cannot use modifiers in catch."),
553 1018
554 static const MessageKind OPTIONAL_PARAMETER_IN_CATCH = const MessageKind( 1019 MessageKind.OPTIONAL_PARAMETER_IN_CATCH:
555 "Cannot use optional parameters in catch."); 1020 const MessageTemplate(MessageKind.OPTIONAL_PARAMETER_IN_CATCH,
1021 "Cannot use optional parameters in catch."),
556 1022
557 static const MessageKind THROW_WITHOUT_EXPRESSION = const MessageKind( 1023 MessageKind.THROW_WITHOUT_EXPRESSION:
558 "Cannot use re-throw outside of catch block " 1024 const MessageTemplate(MessageKind.THROW_WITHOUT_EXPRESSION,
559 "(expression expected after 'throw')."); 1025 "Cannot use re-throw outside of catch block "
1026 "(expression expected after 'throw')."),
560 1027
561 static const MessageKind UNBOUND_LABEL = const MessageKind( 1028 MessageKind.UNBOUND_LABEL:
562 "Cannot resolve label '#{labelName}'."); 1029 const MessageTemplate(MessageKind.UNBOUND_LABEL,
1030 "Cannot resolve label '#{labelName}'."),
563 1031
564 static const MessageKind NO_BREAK_TARGET = const MessageKind( 1032 MessageKind.NO_BREAK_TARGET:
565 "'break' statement not inside switch or loop."); 1033 const MessageTemplate(MessageKind.NO_BREAK_TARGET,
1034 "'break' statement not inside switch or loop."),
566 1035
567 static const MessageKind NO_CONTINUE_TARGET = const MessageKind( 1036 MessageKind.NO_CONTINUE_TARGET:
568 "'continue' statement not inside loop."); 1037 const MessageTemplate(MessageKind.NO_CONTINUE_TARGET,
1038 "'continue' statement not inside loop."),
569 1039
570 static const MessageKind EXISTING_LABEL = const MessageKind( 1040 MessageKind.EXISTING_LABEL:
571 "Original declaration of duplicate label '#{labelName}'."); 1041 const MessageTemplate(MessageKind.EXISTING_LABEL,
1042 "Original declaration of duplicate label '#{labelName}'."),
572 1043
573 static const MessageKind DUPLICATE_LABEL = const MessageKind( 1044 MessageKind.DUPLICATE_LABEL:
574 "Duplicate declaration of label '#{labelName}'."); 1045 const MessageTemplate(MessageKind.DUPLICATE_LABEL,
1046 "Duplicate declaration of label '#{labelName}'."),
575 1047
576 static const MessageKind UNUSED_LABEL = const MessageKind( 1048 MessageKind.UNUSED_LABEL:
577 "Unused label '#{labelName}'."); 1049 const MessageTemplate(MessageKind.UNUSED_LABEL,
1050 "Unused label '#{labelName}'."),
578 1051
579 static const MessageKind INVALID_CONTINUE = const MessageKind( 1052 MessageKind.INVALID_CONTINUE:
580 "Target of continue is not a loop or switch case."); 1053 const MessageTemplate(MessageKind.INVALID_CONTINUE,
1054 "Target of continue is not a loop or switch case."),
581 1055
582 static const MessageKind INVALID_BREAK = const MessageKind( 1056 MessageKind.INVALID_BREAK:
583 "Target of break is not a statement."); 1057 const MessageTemplate(MessageKind.INVALID_BREAK,
1058 "Target of break is not a statement."),
584 1059
585 static const MessageKind DUPLICATE_TYPE_VARIABLE_NAME = const MessageKind( 1060 MessageKind.DUPLICATE_TYPE_VARIABLE_NAME:
586 "Type variable '#{typeVariableName}' already declared."); 1061 const MessageTemplate(MessageKind.DUPLICATE_TYPE_VARIABLE_NAME,
1062 "Type variable '#{typeVariableName}' already declared."),
587 1063
588 static const MessageKind TYPE_VARIABLE_WITHIN_STATIC_MEMBER = 1064 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER:
589 const MessageKind( 1065 const MessageTemplate(MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
590 "Cannot refer to type variable '#{typeVariableName}' " 1066 "Cannot refer to type variable '#{typeVariableName}' "
591 "within a static member."); 1067 "within a static member."),
592 1068
593 static const MessageKind TYPE_VARIABLE_IN_CONSTANT = const MessageKind( 1069 MessageKind.TYPE_VARIABLE_IN_CONSTANT:
594 "Constant expressions can't refer to type variables.", 1070 const MessageTemplate(MessageKind.TYPE_VARIABLE_IN_CONSTANT,
595 howToFix: "Try removing the type variable or replacing it with a " 1071 "Constant expressions can't refer to type variables.",
596 "concrete type.", 1072 howToFix: "Try removing the type variable or replacing it with a "
597 examples: const [""" 1073 "concrete type.",
1074 examples: const ["""
598 class C<T> { 1075 class C<T> {
599 const C(); 1076 const C();
600 1077
601 m(T t) => const C<T>(); 1078 m(T t) => const C<T>();
602 } 1079 }
603 1080
604 void main() => new C().m(null); 1081 void main() => new C().m(null);
605 """ 1082 """
606 ]); 1083 ]),
607 1084
608 1085 MessageKind.INVALID_TYPE_VARIABLE_BOUND:
609 static const MessageKind INVALID_TYPE_VARIABLE_BOUND = const MessageKind( 1086 const MessageTemplate(MessageKind.INVALID_TYPE_VARIABLE_BOUND,
610 "'#{typeArgument}' is not a subtype of bound '#{bound}' for " 1087 "'#{typeArgument}' is not a subtype of bound '#{bound}' for "
611 "type variable '#{typeVariable}' of type '#{thisType}'.", 1088 "type variable '#{typeVariable}' of type '#{thisType}'.",
612 howToFix: "Try to change or remove the type argument.", 1089 howToFix: "Try to change or remove the type argument.",
613 examples: const [""" 1090 examples: const ["""
614 class C<T extends num> {} 1091 class C<T extends num> {}
615 1092
616 // 'String' is not a valid instantiation of T with bound num.'. 1093 // 'String' is not a valid instantiation of T with bound num.'.
617 main() => new C<String>(); 1094 main() => new C<String>();
618 """]); 1095 """]),
619 1096
620 static const MessageKind INVALID_USE_OF_SUPER = const MessageKind( 1097 MessageKind.INVALID_USE_OF_SUPER:
621 "'super' not allowed here."); 1098 const MessageTemplate(MessageKind.INVALID_USE_OF_SUPER,
1099 "'super' not allowed here."),
622 1100
623 static const MessageKind INVALID_CASE_DEFAULT = const MessageKind( 1101 MessageKind.INVALID_CASE_DEFAULT:
624 "'default' only allowed on last case of a switch."); 1102 const MessageTemplate(MessageKind.INVALID_CASE_DEFAULT,
1103 "'default' only allowed on last case of a switch."),
625 1104
626 static const MessageKind SWITCH_CASE_TYPES_NOT_EQUAL = const MessageKind( 1105 MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL:
627 "'case' expressions do not all have type '#{type}'."); 1106 const MessageTemplate(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL,
1107 "'case' expressions do not all have type '#{type}'."),
628 1108
629 static const MessageKind SWITCH_CASE_TYPES_NOT_EQUAL_CASE = const MessageKind( 1109 MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE:
630 "'case' expression of type '#{type}'."); 1110 const MessageTemplate(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE,
1111 "'case' expression of type '#{type}'."),
631 1112
632 static const MessageKind SWITCH_CASE_FORBIDDEN = const MessageKind( 1113 MessageKind.SWITCH_CASE_FORBIDDEN:
633 "'case' expression may not be of type '#{type}'."); 1114 const MessageTemplate(MessageKind.SWITCH_CASE_FORBIDDEN,
1115 "'case' expression may not be of type '#{type}'."),
634 1116
635 static const MessageKind SWITCH_CASE_VALUE_OVERRIDES_EQUALS = 1117 MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS:
636 const MessageKind( 1118 const MessageTemplate(MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS,
637 "'case' expression type '#{type}' overrides 'operator =='."); 1119 "'case' expression type '#{type}' overrides 'operator =='."),
638 1120
639 static const MessageKind INVALID_ARGUMENT_AFTER_NAMED = const MessageKind( 1121 MessageKind.INVALID_ARGUMENT_AFTER_NAMED:
640 "Unnamed argument after named argument."); 1122 const MessageTemplate(MessageKind.INVALID_ARGUMENT_AFTER_NAMED,
1123 "Unnamed argument after named argument."),
641 1124
642 static const MessageKind NOT_A_COMPILE_TIME_CONSTANT = const MessageKind( 1125 MessageKind.NOT_A_COMPILE_TIME_CONSTANT:
643 "Not a compile-time constant."); 1126 const MessageTemplate(MessageKind.NOT_A_COMPILE_TIME_CONSTANT,
1127 "Not a compile-time constant."),
644 1128
645 static const MessageKind DEFERRED_COMPILE_TIME_CONSTANT = const MessageKind( 1129 MessageKind.DEFERRED_COMPILE_TIME_CONSTANT:
646 "A deferred value cannot be used as a compile-time constant."); 1130 const MessageTemplate(MessageKind.DEFERRED_COMPILE_TIME_CONSTANT,
1131 "A deferred value cannot be used as a compile-time constant."),
647 1132
648 static const MessageKind DEFERRED_COMPILE_TIME_CONSTANT_CONSTRUCTION = 1133 MessageKind.DEFERRED_COMPILE_TIME_CONSTANT_CONSTRUCTION:
649 const MessageKind( 1134 const MessageTemplate(
1135 MessageKind.DEFERRED_COMPILE_TIME_CONSTANT_CONSTRUCTION,
650 "A deferred class cannot be used to create a " 1136 "A deferred class cannot be used to create a "
651 "compile-time constant."); 1137 "compile-time constant."),
652 1138
653 static const MessageKind CYCLIC_COMPILE_TIME_CONSTANTS = const MessageKind( 1139 MessageKind.CYCLIC_COMPILE_TIME_CONSTANTS:
654 "Cycle in the compile-time constant computation."); 1140 const MessageTemplate(MessageKind.CYCLIC_COMPILE_TIME_CONSTANTS,
1141 "Cycle in the compile-time constant computation."),
655 1142
656 static const MessageKind CONSTRUCTOR_IS_NOT_CONST = const MessageKind( 1143 MessageKind.CONSTRUCTOR_IS_NOT_CONST:
657 "Constructor is not a 'const' constructor."); 1144 const MessageTemplate(MessageKind.CONSTRUCTOR_IS_NOT_CONST,
1145 "Constructor is not a 'const' constructor."),
658 1146
659 static const MessageKind CONST_MAP_KEY_OVERRIDES_EQUALS = 1147 MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS:
660 const MessageKind( 1148 const MessageTemplate(MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS,
661 "Const-map key type '#{type}' overrides 'operator =='."); 1149 "Const-map key type '#{type}' overrides 'operator =='."),
662 1150
663 static const MessageKind NO_SUCH_LIBRARY_MEMBER = const MessageKind( 1151 MessageKind.NO_SUCH_LIBRARY_MEMBER:
664 "'#{libraryName}' has no member named '#{memberName}'."); 1152 const MessageTemplate(MessageKind.NO_SUCH_LIBRARY_MEMBER,
1153 "'#{libraryName}' has no member named '#{memberName}'."),
665 1154
666 static const MessageKind CANNOT_INSTANTIATE_TYPEDEF = const MessageKind( 1155 MessageKind.CANNOT_INSTANTIATE_TYPEDEF:
667 "Cannot instantiate typedef '#{typedefName}'."); 1156 const MessageTemplate(MessageKind.CANNOT_INSTANTIATE_TYPEDEF,
1157 "Cannot instantiate typedef '#{typedefName}'."),
668 1158
669 static const MessageKind REQUIRED_PARAMETER_WITH_DEFAULT = const MessageKind( 1159 MessageKind.REQUIRED_PARAMETER_WITH_DEFAULT:
670 "Non-optional parameters can't have a default value.", 1160 const MessageTemplate(MessageKind.REQUIRED_PARAMETER_WITH_DEFAULT,
671 howToFix: 1161 "Non-optional parameters can't have a default value.",
672 "Try removing the default value or making the parameter optional.", 1162 howToFix:
673 examples: const [""" 1163 "Try removing the default value or making the parameter optional.",
1164 examples: const ["""
674 main() { 1165 main() {
675 foo(a: 1) => print(a); 1166 foo(a: 1) => print(a);
676 foo(2); 1167 foo(2);
677 }""", """ 1168 }""", """
678 main() { 1169 main() {
679 foo(a = 1) => print(a); 1170 foo(a = 1) => print(a);
680 foo(2); 1171 foo(2);
681 }"""]); 1172 }"""]),
682 1173
683 static const MessageKind NAMED_PARAMETER_WITH_EQUALS = const MessageKind( 1174 MessageKind.NAMED_PARAMETER_WITH_EQUALS:
684 "Named optional parameters can't use '=' to specify a default " 1175 const MessageTemplate(MessageKind.NAMED_PARAMETER_WITH_EQUALS,
685 "value.", 1176 "Named optional parameters can't use '=' to specify a default "
686 howToFix: "Try replacing '=' with ':'.", 1177 "value.",
687 examples: const [""" 1178 howToFix: "Try replacing '=' with ':'.",
1179 examples: const ["""
688 main() { 1180 main() {
689 foo({a = 1}) => print(a); 1181 foo({a = 1}) => print(a);
690 foo(a: 2); 1182 foo(a: 2);
691 }"""]); 1183 }"""]),
692 1184
693 static const MessageKind POSITIONAL_PARAMETER_WITH_EQUALS = const MessageKind( 1185 MessageKind.POSITIONAL_PARAMETER_WITH_EQUALS:
694 "Positional optional parameters can't use ':' to specify a " 1186 const MessageTemplate(MessageKind.POSITIONAL_PARAMETER_WITH_EQUALS,
695 "default value.", 1187 "Positional optional parameters can't use ':' to specify a "
696 howToFix: "Try replacing ':' with '='.", 1188 "default value.",
697 examples: const [""" 1189 howToFix: "Try replacing ':' with '='.",
1190 examples: const ["""
698 main() { 1191 main() {
699 foo([a: 1]) => print(a); 1192 foo([a: 1]) => print(a);
700 foo(2); 1193 foo(2);
701 }"""]); 1194 }"""]),
702 1195
703 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind( 1196 MessageKind.TYPEDEF_FORMAL_WITH_DEFAULT:
704 "A parameter of a typedef can't specify a default value.", 1197 const MessageTemplate(MessageKind.TYPEDEF_FORMAL_WITH_DEFAULT,
705 howToFix: 1198 "A parameter of a typedef can't specify a default value.",
706 "Try removing the default value.", 1199 howToFix:
707 examples: const [""" 1200 "Try removing the default value.",
1201 examples: const ["""
708 typedef void F([int arg = 0]); 1202 typedef void F([int arg = 0]);
709 1203
710 main() { 1204 main() {
711 F f; 1205 F f;
712 }""", """ 1206 }""", """
713 typedef void F({int arg: 0}); 1207 typedef void F({int arg: 0});
714 1208
715 main() { 1209 main() {
716 F f; 1210 F f;
717 }"""]); 1211 }"""]),
718 1212
719 static const MessageKind FUNCTION_TYPE_FORMAL_WITH_DEFAULT = const MessageKind ( 1213 MessageKind.FUNCTION_TYPE_FORMAL_WITH_DEFAULT:
720 "A function type parameter can't specify a default value.", 1214 const MessageTemplate(MessageKind.FUNCTION_TYPE_FORMAL_WITH_DEFAULT,
721 howToFix: 1215 "A function type parameter can't specify a default value.",
722 "Try removing the default value.", 1216 howToFix:
723 examples: const [""" 1217 "Try removing the default value.",
1218 examples: const ["""
724 foo(f(int i, [a = 1])) {} 1219 foo(f(int i, [a = 1])) {}
725 1220
726 main() { 1221 main() {
727 foo(1, 2); 1222 foo(1, 2);
728 }""", """ 1223 }""", """
729 foo(f(int i, {a: 1})) {} 1224 foo(f(int i, {a: 1})) {}
730 1225
731 main() { 1226 main() {
732 foo(1, a: 2); 1227 foo(1, a: 2);
733 }"""]); 1228 }"""]),
734 1229
735 static const MessageKind REDIRECTING_FACTORY_WITH_DEFAULT = const MessageKind( 1230 MessageKind.REDIRECTING_FACTORY_WITH_DEFAULT:
736 "A parameter of a redirecting factory constructor can't specify a " 1231 const MessageTemplate(MessageKind.REDIRECTING_FACTORY_WITH_DEFAULT,
737 "default value.", 1232 "A parameter of a redirecting factory constructor can't specify a "
738 howToFix: 1233 "default value.",
739 "Try removing the default value.", 1234 howToFix:
740 examples: const [""" 1235 "Try removing the default value.",
1236 examples: const ["""
741 class A { 1237 class A {
742 A([a]); 1238 A([a]);
743 factory A.foo([a = 1]) = A; 1239 factory A.foo([a = 1]) = A;
744 } 1240 }
745 1241
746 main() { 1242 main() {
747 new A.foo(1); 1243 new A.foo(1);
748 }""", """ 1244 }""", """
749 class A { 1245 class A {
750 A({a}); 1246 A({a});
751 factory A.foo({a: 1}) = A; 1247 factory A.foo({a: 1}) = A;
752 } 1248 }
753 1249
754 main() { 1250 main() {
755 new A.foo(a: 1); 1251 new A.foo(a: 1);
756 }"""]); 1252 }"""]),
757 1253
758 static const MessageKind FORMAL_DECLARED_CONST = const MessageKind( 1254 MessageKind.FORMAL_DECLARED_CONST:
759 "A formal parameter can't be declared const.", 1255 const MessageTemplate(MessageKind.FORMAL_DECLARED_CONST,
760 howToFix: "Try removing 'const'.", 1256 "A formal parameter can't be declared const.",
761 examples: const [""" 1257 howToFix: "Try removing 'const'.",
1258 examples: const ["""
762 foo(const x) {} 1259 foo(const x) {}
763 main() => foo(42); 1260 main() => foo(42);
764 """, """ 1261 """, """
765 foo({const x}) {} 1262 foo({const x}) {}
766 main() => foo(42); 1263 main() => foo(42);
767 """, """ 1264 """, """
768 foo([const x]) {} 1265 foo([const x]) {}
769 main() => foo(42); 1266 main() => foo(42);
770 """]); 1267 """]),
771 1268
772 static const MessageKind FORMAL_DECLARED_STATIC = const MessageKind( 1269 MessageKind.FORMAL_DECLARED_STATIC:
773 "A formal parameter can't be declared static.", 1270 const MessageTemplate(MessageKind.FORMAL_DECLARED_STATIC,
774 howToFix: "Try removing 'static'.", 1271 "A formal parameter can't be declared static.",
775 examples: const [""" 1272 howToFix: "Try removing 'static'.",
1273 examples: const ["""
776 foo(static x) {} 1274 foo(static x) {}
777 main() => foo(42); 1275 main() => foo(42);
778 """, """ 1276 """, """
779 foo({static x}) {} 1277 foo({static x}) {}
780 main() => foo(42); 1278 main() => foo(42);
781 """, """ 1279 """, """
782 foo([static x]) {} 1280 foo([static x]) {}
783 main() => foo(42); 1281 main() => foo(42);
784 """]); 1282 """]),
785 1283
786 static const MessageKind FINAL_FUNCTION_TYPE_PARAMETER = const MessageKind( 1284 MessageKind.FINAL_FUNCTION_TYPE_PARAMETER:
787 "A function type parameter can't be declared final.", 1285 const MessageTemplate(MessageKind.FINAL_FUNCTION_TYPE_PARAMETER,
788 howToFix: "Try removing 'final'.", 1286 "A function type parameter can't be declared final.",
789 examples: const [""" 1287 howToFix: "Try removing 'final'.",
1288 examples: const ["""
790 foo(final int x(int a)) {} 1289 foo(final int x(int a)) {}
791 main() => foo((y) => 42); 1290 main() => foo((y) => 42);
792 """, """ 1291 """, """
793 foo({final int x(int a)}) {} 1292 foo({final int x(int a)}) {}
794 main() => foo((y) => 42); 1293 main() => foo((y) => 42);
795 """, """ 1294 """, """
796 foo([final int x(int a)]) {} 1295 foo([final int x(int a)]) {}
797 main() => foo((y) => 42); 1296 main() => foo((y) => 42);
798 """]); 1297 """]),
799 1298
800 static const MessageKind VAR_FUNCTION_TYPE_PARAMETER = const MessageKind( 1299 MessageKind.VAR_FUNCTION_TYPE_PARAMETER:
801 "A function type parameter can't be declared with 'var'.", 1300 const MessageTemplate(MessageKind.VAR_FUNCTION_TYPE_PARAMETER,
802 howToFix: "Try removing 'var'.", 1301 "A function type parameter can't be declared with 'var'.",
803 examples: const [""" 1302 howToFix: "Try removing 'var'.",
1303 examples: const ["""
804 foo(var int x(int a)) {} 1304 foo(var int x(int a)) {}
805 main() => foo((y) => 42); 1305 main() => foo((y) => 42);
806 """, """ 1306 """, """
807 foo({var int x(int a)}) {} 1307 foo({var int x(int a)}) {}
808 main() => foo((y) => 42); 1308 main() => foo((y) => 42);
809 """, """ 1309 """, """
810 foo([var int x(int a)]) {} 1310 foo([var int x(int a)]) {}
811 main() => foo((y) => 42); 1311 main() => foo((y) => 42);
812 """]); 1312 """]),
813 1313
814 static const MessageKind CANNOT_INSTANTIATE_TYPE_VARIABLE = const MessageKind( 1314 MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE:
815 "Cannot instantiate type variable '#{typeVariableName}'."); 1315 const MessageTemplate(MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE,
1316 "Cannot instantiate type variable '#{typeVariableName}'."),
816 1317
817 static const MessageKind CYCLIC_TYPE_VARIABLE = const MessageKind( 1318 MessageKind.CYCLIC_TYPE_VARIABLE:
818 "Type variable '#{typeVariableName}' is a supertype of itself."); 1319 const MessageTemplate(MessageKind.CYCLIC_TYPE_VARIABLE,
1320 "Type variable '#{typeVariableName}' is a supertype of itself."),
819 1321
820 static const CYCLIC_TYPEDEF = const MessageKind( 1322 MessageKind.CYCLIC_TYPEDEF:
821 "A typedef can't refer to itself.", 1323 const MessageTemplate(MessageKind.CYCLIC_TYPEDEF,
822 howToFix: "Try removing all references to '#{typedefName}' " 1324 "A typedef can't refer to itself.",
823 "in the definition of '#{typedefName}'.", 1325 howToFix: "Try removing all references to '#{typedefName}' "
824 examples: const [""" 1326 "in the definition of '#{typedefName}'.",
1327 examples: const ["""
825 typedef F F(); // The return type 'F' is a self-reference. 1328 typedef F F(); // The return type 'F' is a self-reference.
826 main() { F f = null; }"""]); 1329 main() { F f = null; }"""]),
827 1330
828 static const CYCLIC_TYPEDEF_ONE = const MessageKind( 1331 MessageKind.CYCLIC_TYPEDEF_ONE:
829 "A typedef can't refer to itself through another typedef.", 1332 const MessageTemplate(MessageKind.CYCLIC_TYPEDEF_ONE,
830 howToFix: "Try removing all references to " 1333 "A typedef can't refer to itself through another typedef.",
831 "'#{otherTypedefName}' in the definition of '#{typedefName}'.", 1334 howToFix:
832 examples: const [""" 1335 "Try removing all references to "
1336 "'#{otherTypedefName}' in the definition of '#{typedefName}'.",
1337 examples: const ["""
833 typedef G F(); // The return type 'G' is a self-reference through typedef 'G'. 1338 typedef G F(); // The return type 'G' is a self-reference through typedef 'G'.
834 typedef F G(); // The return type 'F' is a self-reference through typedef 'F'. 1339 typedef F G(); // The return type 'F' is a self-reference through typedef 'F'.
835 main() { F f = null; }""", 1340 main() { F f = null; }""",
836 """ 1341 """
837 typedef G F(); // The return type 'G' creates a self-reference. 1342 typedef G F(); // The return type 'G' creates a self-reference.
838 typedef H G(); // The return type 'H' creates a self-reference. 1343 typedef H G(); // The return type 'H' creates a self-reference.
839 typedef H(F f); // The argument type 'F' creates a self-reference. 1344 typedef H(F f); // The argument type 'F' creates a self-reference.
840 main() { F f = null; }"""]); 1345 main() { F f = null; }"""]),
841 1346
842 static const MessageKind CLASS_NAME_EXPECTED = const MessageKind( 1347 MessageKind.CLASS_NAME_EXPECTED:
843 "Class name expected."); 1348 const MessageTemplate(MessageKind.CLASS_NAME_EXPECTED,
1349 "Class name expected."),
844 1350
845 static const MessageKind CANNOT_EXTEND = const MessageKind( 1351 MessageKind.CANNOT_EXTEND:
846 "'#{type}' cannot be extended."); 1352 const MessageTemplate(MessageKind.CANNOT_EXTEND,
1353 "'#{type}' cannot be extended."),
847 1354
848 static const MessageKind CANNOT_IMPLEMENT = const MessageKind( 1355 MessageKind.CANNOT_IMPLEMENT:
849 "'#{type}' cannot be implemented."); 1356 const MessageTemplate(MessageKind.CANNOT_IMPLEMENT,
1357 "'#{type}' cannot be implemented."),
850 1358
851 // TODO(johnnwinther): Split messages into reasons for malformedness. 1359 // TODO(johnnwinther): Split messages into reasons for malformedness.
852 static const MessageKind CANNOT_EXTEND_MALFORMED = const MessageKind( 1360 MessageKind.CANNOT_EXTEND_MALFORMED:
853 "Class '#{className}' can't extend the type '#{malformedType}' because " 1361 const MessageTemplate(MessageKind.CANNOT_EXTEND_MALFORMED,
854 "it is malformed.", 1362 "Class '#{className}' can't extend the type '#{malformedType}' "
855 howToFix: "Try correcting the malformed type annotation or removing the " 1363 "because it is malformed.",
856 "'extends' clause.", 1364 howToFix:
857 examples: const [""" 1365 "Try correcting the malformed type annotation or removing the "
1366 "'extends' clause.",
1367 examples: const ["""
858 class A extends Malformed {} 1368 class A extends Malformed {}
859 main() => new A();"""]); 1369 main() => new A();"""]),
860 1370
861 static const MessageKind CANNOT_IMPLEMENT_MALFORMED = const MessageKind( 1371 MessageKind.CANNOT_IMPLEMENT_MALFORMED:
862 "Class '#{className}' can't implement the type '#{malformedType}' " 1372 const MessageTemplate(MessageKind.CANNOT_IMPLEMENT_MALFORMED,
863 "because it is malformed.", 1373 "Class '#{className}' can't implement the type '#{malformedType}' "
864 howToFix: "Try correcting the malformed type annotation or removing the " 1374 "because it is malformed.",
865 "type from the 'implements' clause.", 1375 howToFix:
866 examples: const [""" 1376 "Try correcting the malformed type annotation or removing the "
1377 "type from the 'implements' clause.",
1378 examples: const ["""
867 class A implements Malformed {} 1379 class A implements Malformed {}
868 main() => new A();"""]); 1380 main() => new A();"""]),
869 1381
870 static const MessageKind CANNOT_MIXIN_MALFORMED = const MessageKind( 1382 MessageKind.CANNOT_MIXIN_MALFORMED:
871 "Class '#{className}' can't mixin the type '#{malformedType}' because it " 1383 const MessageTemplate(MessageKind.CANNOT_MIXIN_MALFORMED,
872 "is malformed.", 1384 "Class '#{className}' can't mixin the type '#{malformedType}' "
873 howToFix: "Try correcting the malformed type annotation or removing the " 1385 "because it is malformed.",
874 "type from the 'with' clause.", 1386 howToFix:
875 examples: const [""" 1387 "Try correcting the malformed type annotation or removing the "
1388 "type from the 'with' clause.",
1389 examples: const ["""
876 class A extends Object with Malformed {} 1390 class A extends Object with Malformed {}
877 main() => new A();"""]); 1391 main() => new A();"""]),
878 1392
879 static const MessageKind CANNOT_MIXIN = const MessageKind( 1393 MessageKind.CANNOT_MIXIN:
880 "The type '#{type}' can't be mixed in.", 1394 const MessageTemplate(MessageKind.CANNOT_MIXIN,
881 howToFix: "Try removing '#{type}' from the 'with' clause.", 1395 "The type '#{type}' can't be mixed in.",
882 examples: const [""" 1396 howToFix: "Try removing '#{type}' from the 'with' clause.",
1397 examples: const ["""
883 class C extends Object with String {} 1398 class C extends Object with String {}
884 1399
885 main() => new C(); 1400 main() => new C();
886 """, """ 1401 """, """
887 typedef C = Object with String; 1402 typedef C = Object with String;
888 1403
889 main() => new C(); 1404 main() => new C();
890 """]); 1405 """]),
891 1406
892 static const MessageKind CANNOT_EXTEND_ENUM = const MessageKind( 1407 MessageKind.CANNOT_EXTEND_ENUM:
893 "Class '#{className}' can't extend the type '#{enumType}' because " 1408 const MessageTemplate(MessageKind.CANNOT_EXTEND_ENUM,
894 "it is declared by an enum.", 1409 "Class '#{className}' can't extend the type '#{enumType}' because "
895 howToFix: "Try making '#{enumType}' a normal class or removing the " 1410 "it is declared by an enum.",
896 "'extends' clause.", 1411 howToFix: "Try making '#{enumType}' a normal class or removing the "
897 examples: const [""" 1412 "'extends' clause.",
1413 examples: const ["""
898 enum Enum { A } 1414 enum Enum { A }
899 class B extends Enum {} 1415 class B extends Enum {}
900 main() => new B();"""]); 1416 main() => new B();"""]),
901 1417
902 static const MessageKind CANNOT_IMPLEMENT_ENUM = const MessageKind( 1418 MessageKind.CANNOT_IMPLEMENT_ENUM:
903 "Class '#{className}' can't implement the type '#{enumType}' " 1419 const MessageTemplate(MessageKind.CANNOT_IMPLEMENT_ENUM,
904 "because it is declared by an enum.", 1420 "Class '#{className}' can't implement the type '#{enumType}' "
905 howToFix: "Try making '#{enumType}' a normal class or removing the " 1421 "because it is declared by an enum.",
906 "type from the 'implements' clause.", 1422 howToFix: "Try making '#{enumType}' a normal class or removing the "
907 examples: const [""" 1423 "type from the 'implements' clause.",
1424 examples: const ["""
908 enum Enum { A } 1425 enum Enum { A }
909 class B implements Enum {} 1426 class B implements Enum {}
910 main() => new B();"""]); 1427 main() => new B();"""]),
911 1428
912 static const MessageKind CANNOT_MIXIN_ENUM = const MessageKind( 1429 MessageKind.CANNOT_MIXIN_ENUM:
913 "Class '#{className}' can't mixin the type '#{enumType}' because it " 1430 const MessageTemplate(MessageKind.CANNOT_MIXIN_ENUM,
914 "is declared by an enum.", 1431 "Class '#{className}' can't mixin the type '#{enumType}' because it "
915 howToFix: "Try making '#{enumType}' a normal class or removing the " 1432 "is declared by an enum.",
916 "type from the 'with' clause.", 1433 howToFix: "Try making '#{enumType}' a normal class or removing the "
917 examples: const [""" 1434 "type from the 'with' clause.",
1435 examples: const ["""
918 enum Enum { A } 1436 enum Enum { A }
919 class B extends Object with Enum {} 1437 class B extends Object with Enum {}
920 main() => new B();"""]); 1438 main() => new B();"""]),
921 1439
922 static const MessageKind CANNOT_INSTANTIATE_ENUM = const MessageKind( 1440 MessageKind.CANNOT_INSTANTIATE_ENUM:
923 "Enum type '#{enumName}' cannot be instantiated.", 1441 const MessageTemplate(MessageKind.CANNOT_INSTANTIATE_ENUM,
924 howToFix: "Try making '#{enumType}' a normal class or use an enum " 1442 "Enum type '#{enumName}' cannot be instantiated.",
925 "constant.", 1443 howToFix: "Try making '#{enumType}' a normal class or use an enum "
926 examples: const [""" 1444 "constant.",
1445 examples: const ["""
927 enum Enum { A } 1446 enum Enum { A }
928 main() => new Enum(0);""", """ 1447 main() => new Enum(0);""", """
929 enum Enum { A } 1448 enum Enum { A }
930 main() => const Enum(0);"""]); 1449 main() => const Enum(0);"""]),
931 1450
932 static const MessageKind EMPTY_ENUM_DECLARATION = const MessageKind( 1451 MessageKind.EMPTY_ENUM_DECLARATION:
933 "Enum '#{enumName}' must contain at least one value.", 1452 const MessageTemplate(MessageKind.EMPTY_ENUM_DECLARATION,
934 howToFix: "Try adding an enum constant or making #{enumName} a " 1453 "Enum '#{enumName}' must contain at least one value.",
935 "normal class.", 1454 howToFix: "Try adding an enum constant or making #{enumName} a "
936 examples: const [""" 1455 "normal class.",
1456 examples: const ["""
937 enum Enum {} 1457 enum Enum {}
938 main() { Enum e; }"""]); 1458 main() { Enum e; }"""]),
939 1459
940 static const MessageKind MISSING_ENUM_CASES = const MessageKind( 1460 MessageKind.MISSING_ENUM_CASES:
941 "Missing enum constants in switch statement: #{enumValues}.", 1461 const MessageTemplate(MessageKind.MISSING_ENUM_CASES,
942 howToFix: "Try adding the missing constants or a default case.", 1462 "Missing enum constants in switch statement: #{enumValues}.",
943 examples: const [""" 1463 howToFix: "Try adding the missing constants or a default case.",
1464 examples: const ["""
944 enum Enum { A, B } 1465 enum Enum { A, B }
945 main() { 1466 main() {
946 switch (Enum.A) { 1467 switch (Enum.A) {
947 case Enum.B: break; 1468 case Enum.B: break;
948 } 1469 }
949 }""", """ 1470 }""", """
950 enum Enum { A, B, C } 1471 enum Enum { A, B, C }
951 main() { 1472 main() {
952 switch (Enum.A) { 1473 switch (Enum.A) {
953 case Enum.B: break; 1474 case Enum.B: break;
954 } 1475 }
955 }"""]); 1476 }"""]),
956 1477
957 static const MessageKind DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind( 1478 MessageKind.DUPLICATE_EXTENDS_IMPLEMENTS:
958 "'#{type}' can not be both extended and implemented."); 1479 const MessageTemplate(MessageKind.DUPLICATE_EXTENDS_IMPLEMENTS,
959 1480 "'#{type}' can not be both extended and implemented."),
960 static const MessageKind DUPLICATE_IMPLEMENTS = const MessageKind( 1481
961 "'#{type}' must not occur more than once " 1482 MessageKind.DUPLICATE_IMPLEMENTS:
962 "in the implements clause."); 1483 const MessageTemplate(MessageKind.DUPLICATE_IMPLEMENTS,
963 1484 "'#{type}' must not occur more than once "
964 static const MessageKind MULTI_INHERITANCE = const MessageKind( 1485 "in the implements clause."),
965 "Dart2js does not currently support inheritance of the same class with " 1486
966 "different type arguments: Both #{firstType} and #{secondType} are " 1487 MessageKind.MULTI_INHERITANCE:
967 "supertypes of #{thisType}."); 1488 const MessageTemplate(MessageKind.MULTI_INHERITANCE,
968 1489 "Dart2js does not currently support inheritance of the same class "
969 static const MessageKind ILLEGAL_SUPER_SEND = const MessageKind( 1490 "with different type arguments: Both #{firstType} and #{secondType} "
970 "'#{name}' cannot be called on super."); 1491 "are supertypes of #{thisType}."),
971 1492
972 static const MessageKind NO_SUCH_SUPER_MEMBER = const MessageKind( 1493 MessageKind.ILLEGAL_SUPER_SEND:
973 "Cannot resolve '#{memberName}' in a superclass of '#{className}'."); 1494 const MessageTemplate(MessageKind.ILLEGAL_SUPER_SEND,
974 1495 "'#{name}' cannot be called on super."),
975 static const MessageKind ADDITIONAL_TYPE_ARGUMENT = const MessageKind( 1496
976 "Additional type argument."); 1497 MessageKind.NO_SUCH_SUPER_MEMBER:
977 1498 const MessageTemplate(MessageKind.NO_SUCH_SUPER_MEMBER,
978 static const MessageKind MISSING_TYPE_ARGUMENT = const MessageKind( 1499 "Cannot resolve '#{memberName}' in a superclass of '#{className}'."),
979 "Missing type argument."); 1500
980 1501 MessageKind.ADDITIONAL_TYPE_ARGUMENT:
981 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or MISSING_TYPE_ARGUMENT 1502 const MessageTemplate(MessageKind.ADDITIONAL_TYPE_ARGUMENT,
982 // instead. 1503 "Additional type argument."),
983 static const MessageKind TYPE_ARGUMENT_COUNT_MISMATCH = const MessageKind( 1504
984 "Incorrect number of type arguments on '#{type}'."); 1505 MessageKind.MISSING_TYPE_ARGUMENT:
985 1506 const MessageTemplate(MessageKind.MISSING_TYPE_ARGUMENT,
986 static const MessageKind GETTER_MISMATCH = const MessageKind( 1507 "Missing type argument."),
987 "Setter disagrees on: '#{modifiers}'."); 1508
988 1509 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or
989 static const MessageKind SETTER_MISMATCH = const MessageKind( 1510 // MISSING_TYPE_ARGUMENT instead.
990 "Getter disagrees on: '#{modifiers}'."); 1511 MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH:
991 1512 const MessageTemplate(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH,
992 static const MessageKind ILLEGAL_SETTER_FORMALS = const MessageKind( 1513 "Incorrect number of type arguments on '#{type}'."),
993 "A setter must have exactly one argument."); 1514
994 1515 MessageKind.GETTER_MISMATCH:
995 static const MessageKind NO_STATIC_OVERRIDE = const MessageKind( 1516 const MessageTemplate(MessageKind.GETTER_MISMATCH,
996 "Static member cannot override instance member '#{memberName}' of " 1517 "Setter disagrees on: '#{modifiers}'."),
997 "'#{className}'."); 1518
998 1519 MessageKind.SETTER_MISMATCH:
999 static const MessageKind NO_STATIC_OVERRIDE_CONT = const MessageKind( 1520 const MessageTemplate(MessageKind.SETTER_MISMATCH,
1000 "This is the instance member that cannot be overridden " 1521 "Getter disagrees on: '#{modifiers}'."),
1001 "by a static member."); 1522
1002 1523 MessageKind.ILLEGAL_SETTER_FORMALS:
1003 static const MessageKind INSTANCE_STATIC_SAME_NAME = const MessageKind( 1524 const MessageTemplate(MessageKind.ILLEGAL_SETTER_FORMALS,
1004 "Instance member '#{memberName}' and static member of " 1525 "A setter must have exactly one argument."),
1005 "superclass '#{className}' have the same name."); 1526
1006 1527 MessageKind.NO_STATIC_OVERRIDE:
1007 static const MessageKind INSTANCE_STATIC_SAME_NAME_CONT = const MessageKind( 1528 const MessageTemplate(MessageKind.NO_STATIC_OVERRIDE,
1008 "This is the static member with the same name."); 1529 "Static member cannot override instance member '#{memberName}' of "
1009 1530 "'#{className}'."),
1010 static const MessageKind INVALID_OVERRIDE_METHOD = const MessageKind( 1531
1011 "The type '#{declaredType}' of method '#{name}' declared in " 1532 MessageKind.NO_STATIC_OVERRIDE_CONT:
1012 "'#{class}' is not a subtype of the overridden method type " 1533 const MessageTemplate(MessageKind.NO_STATIC_OVERRIDE_CONT,
1013 "'#{inheritedType}' inherited from '#{inheritedClass}'."); 1534 "This is the instance member that cannot be overridden "
1014 1535 "by a static member."),
1015 static const MessageKind INVALID_OVERRIDDEN_METHOD = const MessageKind( 1536
1016 "This is the overridden method '#{name}' declared in class " 1537 MessageKind.INSTANCE_STATIC_SAME_NAME:
1017 "'#{class}'."); 1538 const MessageTemplate(MessageKind.INSTANCE_STATIC_SAME_NAME,
1018 1539 "Instance member '#{memberName}' and static member of "
1019 static const MessageKind INVALID_OVERRIDE_GETTER = const MessageKind( 1540 "superclass '#{className}' have the same name."),
1020 "The type '#{declaredType}' of getter '#{name}' declared in " 1541
1021 "'#{class}' is not assignable to the type '#{inheritedType}' of the " 1542 MessageKind.INSTANCE_STATIC_SAME_NAME_CONT:
1022 "overridden getter inherited from '#{inheritedClass}'."); 1543 const MessageTemplate(MessageKind.INSTANCE_STATIC_SAME_NAME_CONT,
1023 1544 "This is the static member with the same name."),
1024 static const MessageKind INVALID_OVERRIDDEN_GETTER = const MessageKind( 1545
1025 "This is the overridden getter '#{name}' declared in class " 1546 MessageKind.INVALID_OVERRIDE_METHOD:
1026 "'#{class}'."); 1547 const MessageTemplate(MessageKind.INVALID_OVERRIDE_METHOD,
1027 1548 "The type '#{declaredType}' of method '#{name}' declared in "
1028 static const MessageKind INVALID_OVERRIDE_GETTER_WITH_FIELD = 1549 "'#{class}' is not a subtype of the overridden method type "
1029 const MessageKind( 1550 "'#{inheritedType}' inherited from '#{inheritedClass}'."),
1551
1552 MessageKind.INVALID_OVERRIDDEN_METHOD:
1553 const MessageTemplate(MessageKind.INVALID_OVERRIDDEN_METHOD,
1554 "This is the overridden method '#{name}' declared in class "
1555 "'#{class}'."),
1556
1557 MessageKind.INVALID_OVERRIDE_GETTER:
1558 const MessageTemplate(MessageKind.INVALID_OVERRIDE_GETTER,
1559 "The type '#{declaredType}' of getter '#{name}' declared in "
1560 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1561 "overridden getter inherited from '#{inheritedClass}'."),
1562
1563 MessageKind.INVALID_OVERRIDDEN_GETTER:
1564 const MessageTemplate(MessageKind.INVALID_OVERRIDDEN_GETTER,
1565 "This is the overridden getter '#{name}' declared in class "
1566 "'#{class}'."),
1567
1568 MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD:
1569 const MessageTemplate(MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD,
1030 "The type '#{declaredType}' of field '#{name}' declared in " 1570 "The type '#{declaredType}' of field '#{name}' declared in "
1031 "'#{class}' is not assignable to the type '#{inheritedType}' of the " 1571 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1032 "overridden getter inherited from '#{inheritedClass}'."); 1572 "overridden getter inherited from '#{inheritedClass}'."),
1033 1573
1034 static const MessageKind INVALID_OVERRIDE_FIELD_WITH_GETTER = 1574 MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER:
1035 const MessageKind( 1575 const MessageTemplate(MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER,
1036 "The type '#{declaredType}' of getter '#{name}' declared in " 1576 "The type '#{declaredType}' of getter '#{name}' declared in "
1037 "'#{class}' is not assignable to the type '#{inheritedType}' of the " 1577 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1038 "overridden field inherited from '#{inheritedClass}'."); 1578 "overridden field inherited from '#{inheritedClass}'."),
1039 1579
1040 static const MessageKind INVALID_OVERRIDE_SETTER = const MessageKind( 1580 MessageKind.INVALID_OVERRIDE_SETTER:
1041 "The type '#{declaredType}' of setter '#{name}' declared in " 1581 const MessageTemplate(MessageKind.INVALID_OVERRIDE_SETTER,
1042 "'#{class}' is not assignable to the type '#{inheritedType}' of the " 1582 "The type '#{declaredType}' of setter '#{name}' declared in "
1043 "overridden setter inherited from '#{inheritedClass}'."); 1583 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1044 1584 "overridden setter inherited from '#{inheritedClass}'."),
1045 static const MessageKind INVALID_OVERRIDDEN_SETTER = const MessageKind( 1585
1046 "This is the overridden setter '#{name}' declared in class " 1586 MessageKind.INVALID_OVERRIDDEN_SETTER:
1047 "'#{class}'."); 1587 const MessageTemplate(MessageKind.INVALID_OVERRIDDEN_SETTER,
1048 1588 "This is the overridden setter '#{name}' declared in class "
1049 static const MessageKind INVALID_OVERRIDE_SETTER_WITH_FIELD = 1589 "'#{class}'."),
1050 const MessageKind( 1590
1591 MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD:
1592 const MessageTemplate(MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD,
1051 "The type '#{declaredType}' of field '#{name}' declared in " 1593 "The type '#{declaredType}' of field '#{name}' declared in "
1052 "'#{class}' is not assignable to the type '#{inheritedType}' of the " 1594 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1053 "overridden setter inherited from '#{inheritedClass}'."); 1595 "overridden setter inherited from '#{inheritedClass}'."),
1054 1596
1055 static const MessageKind INVALID_OVERRIDE_FIELD_WITH_SETTER = 1597 MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER:
1056 const MessageKind( 1598 const MessageTemplate(MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER,
1057 "The type '#{declaredType}' of setter '#{name}' declared in " 1599 "The type '#{declaredType}' of setter '#{name}' declared in "
1058 "'#{class}' is not assignable to the type '#{inheritedType}' of the " 1600 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1059 "overridden field inherited from '#{inheritedClass}'."); 1601 "overridden field inherited from '#{inheritedClass}'."),
1060 1602
1061 static const MessageKind INVALID_OVERRIDE_FIELD = const MessageKind( 1603 MessageKind.INVALID_OVERRIDE_FIELD:
1062 "The type '#{declaredType}' of field '#{name}' declared in " 1604 const MessageTemplate(MessageKind.INVALID_OVERRIDE_FIELD,
1063 "'#{class}' is not assignable to the type '#{inheritedType}' of the " 1605 "The type '#{declaredType}' of field '#{name}' declared in "
1064 "overridden field inherited from '#{inheritedClass}'."); 1606 "'#{class}' is not assignable to the type '#{inheritedType}' of the "
1065 1607 "overridden field inherited from '#{inheritedClass}'."),
1066 static const MessageKind INVALID_OVERRIDDEN_FIELD = const MessageKind( 1608
1067 "This is the overridden field '#{name}' declared in class " 1609 MessageKind.INVALID_OVERRIDDEN_FIELD:
1068 "'#{class}'."); 1610 const MessageTemplate(MessageKind.INVALID_OVERRIDDEN_FIELD,
1069 1611 "This is the overridden field '#{name}' declared in class "
1070 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD = 1612 "'#{class}'."),
1071 const MessageKind( 1613
1614 MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD:
1615 const MessageTemplate(MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD,
1072 "Method '#{name}' in '#{class}' can't override field from " 1616 "Method '#{name}' in '#{class}' can't override field from "
1073 "'#{inheritedClass}'."); 1617 "'#{inheritedClass}'."),
1074 1618
1075 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT = 1619 MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT:
1076 const MessageKind( 1620 const MessageTemplate(
1077 "This is the field that cannot be overridden by a method."); 1621 MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT,
1078 1622 "This is the field that cannot be overridden by a method."),
1079 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD = 1623
1080 const MessageKind( 1624 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD:
1625 const MessageTemplate(
1626 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD,
1081 "Field '#{name}' in '#{class}' can't override method from " 1627 "Field '#{name}' in '#{class}' can't override method from "
1082 "'#{inheritedClass}'."); 1628 "'#{inheritedClass}'."),
1083 1629
1084 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT = 1630 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT:
1085 const MessageKind( 1631 const MessageTemplate(
1086 "This is the method that cannot be overridden by a field."); 1632 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT,
1087 1633 "This is the method that cannot be overridden by a field."),
1088 static const MessageKind CANNOT_OVERRIDE_GETTER_WITH_METHOD = 1634
1089 const MessageKind( 1635 MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD:
1090 "Method '#{name}' in '#{class}' can't override getter from " 1636 const MessageTemplate(MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD,
1091 "'#{inheritedClass}'."); 1637 "Method '#{name}' in '#{class}' can't override getter from "
1092 1638 "'#{inheritedClass}'."),
1093 static const MessageKind CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT = 1639
1094 const MessageKind( 1640 MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT:
1095 "This is the getter that cannot be overridden by a method."); 1641 const MessageTemplate(
1096 1642 MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT,
1097 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_GETTER = 1643 "This is the getter that cannot be overridden by a method."),
1098 const MessageKind( 1644
1645 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER:
1646 const MessageTemplate(MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER,
1099 "Getter '#{name}' in '#{class}' can't override method from " 1647 "Getter '#{name}' in '#{class}' can't override method from "
1100 "'#{inheritedClass}'."); 1648 "'#{inheritedClass}'."),
1101 1649
1102 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT = 1650 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT:
1103 const MessageKind( 1651 const MessageTemplate(
1104 "This is the method that cannot be overridden by a getter."); 1652 MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT,
1105 1653 "This is the method that cannot be overridden by a getter."),
1106 static const MessageKind MISSING_FORMALS = const MessageKind( 1654
1107 "Formal parameters are missing."); 1655 MessageKind.MISSING_FORMALS:
1108 1656 const MessageTemplate(MessageKind.MISSING_FORMALS,
1109 static const MessageKind EXTRA_FORMALS = const MessageKind( 1657 "Formal parameters are missing."),
1110 "Formal parameters are not allowed here."); 1658
1111 1659 MessageKind.EXTRA_FORMALS:
1112 static const MessageKind UNARY_OPERATOR_BAD_ARITY = const MessageKind( 1660 const MessageTemplate(MessageKind.EXTRA_FORMALS,
1113 "Operator '#{operatorName}' must have no parameters."); 1661 "Formal parameters are not allowed here."),
1114 1662
1115 static const MessageKind MINUS_OPERATOR_BAD_ARITY = const MessageKind( 1663 MessageKind.UNARY_OPERATOR_BAD_ARITY:
1116 "Operator '-' must have 0 or 1 parameters."); 1664 const MessageTemplate(MessageKind.UNARY_OPERATOR_BAD_ARITY,
1117 1665 "Operator '#{operatorName}' must have no parameters."),
1118 static const MessageKind BINARY_OPERATOR_BAD_ARITY = const MessageKind( 1666
1119 "Operator '#{operatorName}' must have exactly 1 parameter."); 1667 MessageKind.MINUS_OPERATOR_BAD_ARITY:
1120 1668 const MessageTemplate(MessageKind.MINUS_OPERATOR_BAD_ARITY,
1121 static const MessageKind TERNARY_OPERATOR_BAD_ARITY = const MessageKind( 1669 "Operator '-' must have 0 or 1 parameters."),
1122 "Operator '#{operatorName}' must have exactly 2 parameters."); 1670
1123 1671 MessageKind.BINARY_OPERATOR_BAD_ARITY:
1124 static const MessageKind OPERATOR_OPTIONAL_PARAMETERS = const MessageKind( 1672 const MessageTemplate(MessageKind.BINARY_OPERATOR_BAD_ARITY,
1125 "Operator '#{operatorName}' cannot have optional parameters."); 1673 "Operator '#{operatorName}' must have exactly 1 parameter."),
1126 1674
1127 static const MessageKind OPERATOR_NAMED_PARAMETERS = const MessageKind( 1675 MessageKind.TERNARY_OPERATOR_BAD_ARITY:
1128 "Operator '#{operatorName}' cannot have named parameters."); 1676 const MessageTemplate(MessageKind.TERNARY_OPERATOR_BAD_ARITY,
1129 1677 "Operator '#{operatorName}' must have exactly 2 parameters."),
1130 static const MessageKind CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind( 1678
1131 "Cannot have return type for constructor."); 1679 MessageKind.OPERATOR_OPTIONAL_PARAMETERS:
1132 1680 const MessageTemplate(MessageKind.OPERATOR_OPTIONAL_PARAMETERS,
1133 static const MessageKind CANNOT_RETURN_FROM_CONSTRUCTOR = const MessageKind( 1681 "Operator '#{operatorName}' cannot have optional parameters."),
1134 "Constructors can't return values.", 1682
1135 howToFix: "Remove the return statement or use a factory constructor.", 1683 MessageKind.OPERATOR_NAMED_PARAMETERS:
1136 examples: const [""" 1684 const MessageTemplate(MessageKind.OPERATOR_NAMED_PARAMETERS,
1685 "Operator '#{operatorName}' cannot have named parameters."),
1686
1687 MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE:
1688 const MessageTemplate(MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE,
1689 "Cannot have return type for constructor."),
1690
1691 MessageKind.CANNOT_RETURN_FROM_CONSTRUCTOR:
1692 const MessageTemplate(MessageKind.CANNOT_RETURN_FROM_CONSTRUCTOR,
1693 "Constructors can't return values.",
1694 howToFix: "Remove the return statement or use a factory constructor.",
1695 examples: const ["""
1137 class C { 1696 class C {
1138 C() { 1697 C() {
1139 return 1; 1698 return 1;
1140 } 1699 }
1141 } 1700 }
1142 1701
1143 main() => new C();"""]); 1702 main() => new C();"""]),
1144 1703
1145 static const MessageKind ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind( 1704 MessageKind.ILLEGAL_FINAL_METHOD_MODIFIER:
1146 "Cannot have final modifier on method."); 1705 const MessageTemplate(MessageKind.ILLEGAL_FINAL_METHOD_MODIFIER,
1147 1706 "Cannot have final modifier on method."),
1148 static const MessageKind ILLEGAL_CONST_FIELD_MODIFIER = const MessageKind( 1707
1149 "Cannot have const modifier on non-static field.", 1708 MessageKind.ILLEGAL_CONST_FIELD_MODIFIER:
1150 howToFix: "Try adding a static modifier, or removing the const modifier.", 1709 const MessageTemplate(MessageKind.ILLEGAL_CONST_FIELD_MODIFIER,
1151 examples: const [""" 1710 "Cannot have const modifier on non-static field.",
1711 howToFix:
1712 "Try adding a static modifier, or removing the const modifier.",
1713 examples: const ["""
1152 class C { 1714 class C {
1153 const int a = 1; 1715 const int a = 1;
1154 } 1716 }
1155 1717
1156 main() => new C();"""]); 1718 main() => new C();"""]),
1157 1719
1158 static const MessageKind ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind( 1720 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS:
1159 "Illegal constructor modifiers: '#{modifiers}'."); 1721 const MessageTemplate(MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS,
1160 1722 "Illegal constructor modifiers: '#{modifiers}'."),
1161 static const MessageKind ILLEGAL_MIXIN_APPLICATION_MODIFIERS = 1723
1162 const MessageKind( 1724 MessageKind.ILLEGAL_MIXIN_APPLICATION_MODIFIERS:
1163 "Illegal mixin application modifiers: '#{modifiers}'."); 1725 const MessageTemplate(MessageKind.ILLEGAL_MIXIN_APPLICATION_MODIFIERS,
1164 1726 "Illegal mixin application modifiers: '#{modifiers}'."),
1165 static const MessageKind ILLEGAL_MIXIN_SUPERCLASS = const MessageKind( 1727
1166 "Class used as mixin must have Object as superclass."); 1728 MessageKind.ILLEGAL_MIXIN_SUPERCLASS:
1167 1729 const MessageTemplate(MessageKind.ILLEGAL_MIXIN_SUPERCLASS,
1168 static const MessageKind ILLEGAL_MIXIN_OBJECT = const MessageKind( 1730 "Class used as mixin must have Object as superclass."),
1169 "Cannot use Object as mixin."); 1731
1170 1732 MessageKind.ILLEGAL_MIXIN_OBJECT:
1171 static const MessageKind ILLEGAL_MIXIN_CONSTRUCTOR = const MessageKind( 1733 const MessageTemplate(MessageKind.ILLEGAL_MIXIN_OBJECT,
1172 "Class used as mixin cannot have non-factory constructor."); 1734 "Cannot use Object as mixin."),
1173 1735
1174 static const MessageKind ILLEGAL_MIXIN_CYCLE = const MessageKind( 1736 MessageKind.ILLEGAL_MIXIN_CONSTRUCTOR:
1175 "Class used as mixin introduces mixin cycle: " 1737 const MessageTemplate(MessageKind.ILLEGAL_MIXIN_CONSTRUCTOR,
1176 "'#{mixinName1}' <-> '#{mixinName2}'."); 1738 "Class used as mixin cannot have non-factory constructor."),
1177 1739
1178 static const MessageKind ILLEGAL_MIXIN_WITH_SUPER = const MessageKind( 1740 MessageKind.ILLEGAL_MIXIN_CYCLE:
1179 "Cannot use class '#{className}' as a mixin because it uses " 1741 const MessageTemplate(MessageKind.ILLEGAL_MIXIN_CYCLE,
1180 "'super'."); 1742 "Class used as mixin introduces mixin cycle: "
1181 1743 "'#{mixinName1}' <-> '#{mixinName2}'."),
1182 static const MessageKind ILLEGAL_MIXIN_SUPER_USE = const MessageKind( 1744
1183 "Use of 'super' in class used as mixin."); 1745 MessageKind.ILLEGAL_MIXIN_WITH_SUPER:
1184 1746 const MessageTemplate(MessageKind.ILLEGAL_MIXIN_WITH_SUPER,
1185 static const MessageKind PARAMETER_NAME_EXPECTED = const MessageKind( 1747 "Cannot use class '#{className}' as a mixin because it uses "
1186 "parameter name expected."); 1748 "'super'."),
1187 1749
1188 static const MessageKind CANNOT_RESOLVE_GETTER = const MessageKind( 1750 MessageKind.ILLEGAL_MIXIN_SUPER_USE:
1189 "Cannot resolve getter."); 1751 const MessageTemplate(MessageKind.ILLEGAL_MIXIN_SUPER_USE,
1190 1752 "Use of 'super' in class used as mixin."),
1191 static const MessageKind CANNOT_RESOLVE_SETTER = const MessageKind( 1753
1192 "Cannot resolve setter."); 1754 MessageKind.PARAMETER_NAME_EXPECTED:
1193 1755 const MessageTemplate(MessageKind.PARAMETER_NAME_EXPECTED,
1194 static const MessageKind ASSIGNING_METHOD = const MessageKind( 1756 "parameter name expected."),
1195 "Cannot assign a value to a method."); 1757
1196 1758 MessageKind.CANNOT_RESOLVE_GETTER:
1197 static const MessageKind ASSIGNING_METHOD_IN_SUPER = const MessageKind( 1759 const MessageTemplate(MessageKind.CANNOT_RESOLVE_GETTER,
1198 "Cannot assign a value to method '#{name}' " 1760 "Cannot resolve getter."),
1199 "in superclass '#{superclassName}'."); 1761
1200 1762 MessageKind.CANNOT_RESOLVE_SETTER:
1201 static const MessageKind ASSIGNING_TYPE = const MessageKind( 1763 const MessageTemplate(MessageKind.CANNOT_RESOLVE_SETTER,
1202 "Cannot assign a value to a type."); 1764 "Cannot resolve setter."),
1203 1765
1204 static const MessageKind IF_NULL_ASSIGNING_TYPE = const MessageKind( 1766 MessageKind.ASSIGNING_METHOD:
1205 "Cannot assign a value to a type. Note that types are never null, " 1767 const MessageTemplate(MessageKind.ASSIGNING_METHOD,
1206 "so this ??= assignment has no effect.", 1768 "Cannot assign a value to a method."),
1207 howToFix: "Try removing the '??=' assignment.", 1769
1208 examples: const [ 1770 MessageKind.ASSIGNING_METHOD_IN_SUPER:
1209 "class A {} main() { print(A ??= 3);}", 1771 const MessageTemplate(MessageKind.ASSIGNING_METHOD_IN_SUPER,
1210 ]); 1772 "Cannot assign a value to method '#{name}' "
1211 1773 "in superclass '#{superclassName}'."),
1212 static const MessageKind VOID_NOT_ALLOWED = const MessageKind( 1774
1213 "Type 'void' can't be used here because it isn't a return type.", 1775 MessageKind.ASSIGNING_TYPE:
1214 howToFix: "Try removing 'void' keyword or replace it with 'var', 'final'," 1776 const MessageTemplate(MessageKind.ASSIGNING_TYPE,
1215 " or a type.", 1777 "Cannot assign a value to a type."),
1216 examples: const [ 1778
1217 "void x; main() {}", 1779 MessageKind.IF_NULL_ASSIGNING_TYPE:
1218 "foo(void x) {} main() { foo(null); }", 1780 const MessageTemplate(MessageKind.IF_NULL_ASSIGNING_TYPE,
1219 ]); 1781 "Cannot assign a value to a type. Note that types are never null, "
1220 1782 "so this ??= assignment has no effect.",
1221 static const MessageKind NULL_NOT_ALLOWED = const MessageKind( 1783 howToFix: "Try removing the '??=' assignment.",
1222 "`null` can't be used here."); 1784 examples: const [
1223 1785 "class A {} main() { print(A ??= 3);}",
1224 static const MessageKind BEFORE_TOP_LEVEL = const MessageKind( 1786 ]),
1225 "Part header must come before top-level definitions."); 1787
1226 1788 MessageKind.VOID_NOT_ALLOWED:
1227 static const MessageKind IMPORT_PART_OF = const MessageKind( 1789 const MessageTemplate(MessageKind.VOID_NOT_ALLOWED,
1228 "The imported library must not have a 'part-of' directive.", 1790 "Type 'void' can't be used here because it isn't a return type.",
1229 howToFix: "Try removing the 'part-of' directive or replacing the " 1791 howToFix:
1230 "import of the library with a 'part' directive.", 1792 "Try removing 'void' keyword or replace it with 'var', 'final', "
1231 examples: const [const { 1793 "or a type.",
1794 examples: const [
1795 "void x; main() {}",
1796 "foo(void x) {} main() { foo(null); }",
1797 ]),
1798
1799 MessageKind.NULL_NOT_ALLOWED:
1800 const MessageTemplate(MessageKind.NULL_NOT_ALLOWED,
1801 "`null` can't be used here."),
1802
1803 MessageKind.BEFORE_TOP_LEVEL:
1804 const MessageTemplate(MessageKind.BEFORE_TOP_LEVEL,
1805 "Part header must come before top-level definitions."),
1806
1807 MessageKind.IMPORT_PART_OF:
1808 const MessageTemplate(MessageKind.IMPORT_PART_OF,
1809 "The imported library must not have a 'part-of' directive.",
1810 howToFix: "Try removing the 'part-of' directive or replacing the "
1811 "import of the library with a 'part' directive.",
1812 examples: const [const {
1232 'main.dart': """ 1813 'main.dart': """
1233 library library; 1814 library library;
1234 1815
1235 import 'part.dart'; 1816 import 'part.dart';
1236 1817
1237 main() {} 1818 main() {}
1238 """, 1819 """,
1239 1820
1240 'part.dart': """ 1821 'part.dart': """
1241 part of library; 1822 part of library;
1242 """}]); 1823 """}]),
1243 1824
1244 static const MessageKind LIBRARY_NAME_MISMATCH = const MessageKind( 1825 MessageKind.LIBRARY_NAME_MISMATCH:
1245 "Expected part of library name '#{libraryName}'.", 1826 const MessageTemplate(MessageKind.LIBRARY_NAME_MISMATCH,
1246 howToFix: "Try changing the directive to 'part of #{libraryName};'.", 1827 "Expected part of library name '#{libraryName}'.",
1247 examples: const [const { 1828 howToFix: "Try changing the directive to 'part of #{libraryName};'.",
1829 examples: const [const {
1248 'main.dart': """ 1830 'main.dart': """
1249 library lib.foo; 1831 library lib.foo;
1250 1832
1251 part 'part.dart'; 1833 part 'part.dart';
1252 1834
1253 main() {} 1835 main() {}
1254 """, 1836 """,
1255 1837
1256 'part.dart': """ 1838 'part.dart': """
1257 part of lib.bar; 1839 part of lib.bar;
1258 """}]); 1840 """}]),
1259 1841
1260 static const MessageKind MISSING_LIBRARY_NAME = const MessageKind( 1842 MessageKind.MISSING_LIBRARY_NAME:
1261 "Library has no name. Part directive expected library name " 1843 const MessageTemplate(MessageKind.MISSING_LIBRARY_NAME,
1262 "to be '#{libraryName}'.", 1844 "Library has no name. Part directive expected library name "
1263 howToFix: "Try adding 'library #{libraryName};' to the library.", 1845 "to be '#{libraryName}'.",
1264 examples: const [const { 1846 howToFix: "Try adding 'library #{libraryName};' to the library.",
1847 examples: const [const {
1265 'main.dart': """ 1848 'main.dart': """
1266 part 'part.dart'; 1849 part 'part.dart';
1267 1850
1268 main() {} 1851 main() {}
1269 """, 1852 """,
1270 1853
1271 'part.dart': """ 1854 'part.dart': """
1272 part of lib.foo; 1855 part of lib.foo;
1273 """}]); 1856 """}]),
1274 1857
1275 static const MessageKind THIS_IS_THE_PART_OF_TAG = const MessageKind( 1858 MessageKind.THIS_IS_THE_PART_OF_TAG:
1276 "This is the part of directive."); 1859 const MessageTemplate(MessageKind.THIS_IS_THE_PART_OF_TAG,
1860 "This is the part of directive."),
1277 1861
1278 static const MessageKind MISSING_PART_OF_TAG = const MessageKind( 1862 MessageKind.MISSING_PART_OF_TAG:
1279 "This file has no part-of tag, but it is being used as a part."); 1863 const MessageTemplate(MessageKind.MISSING_PART_OF_TAG,
1864 "This file has no part-of tag, but it is being used as a part."),
1280 1865
1281 static const MessageKind DUPLICATED_PART_OF = const MessageKind( 1866 MessageKind.DUPLICATED_PART_OF:
1282 "Duplicated part-of directive."); 1867 const MessageTemplate(MessageKind.DUPLICATED_PART_OF,
1868 "Duplicated part-of directive."),
1283 1869
1284 static const MessageKind DUPLICATED_LIBRARY_NAME = const MessageKind( 1870 MessageKind.DUPLICATED_LIBRARY_NAME:
1285 "Duplicated library name '#{libraryName}'."); 1871 const MessageTemplate(MessageKind.DUPLICATED_LIBRARY_NAME,
1872 "Duplicated library name '#{libraryName}'."),
1286 1873
1287 static const MessageKind DUPLICATED_RESOURCE = const MessageKind( 1874 MessageKind.DUPLICATED_RESOURCE:
1288 "The resource '#{resourceUri}' is loaded through both " 1875 const MessageTemplate(MessageKind.DUPLICATED_RESOURCE,
1289 "'#{canonicalUri1}' and '#{canonicalUri2}'."); 1876 "The resource '#{resourceUri}' is loaded through both "
1877 "'#{canonicalUri1}' and '#{canonicalUri2}'."),
1290 1878
1291 static const MessageKind DUPLICATED_LIBRARY_RESOURCE = 1879 MessageKind.DUPLICATED_LIBRARY_RESOURCE:
1292 const MessageKind( 1880 const MessageTemplate(MessageKind.DUPLICATED_LIBRARY_RESOURCE,
1293 "The library '#{libraryName}' in '#{resourceUri}' is loaded through " 1881 "The library '#{libraryName}' in '#{resourceUri}' is loaded through "
1294 "both '#{canonicalUri1}' and '#{canonicalUri2}'."); 1882 "both '#{canonicalUri1}' and '#{canonicalUri2}'."),
1295 1883
1296 // This is used as an exception. 1884 // This is used as an exception.
1297 static const MessageKind INVALID_SOURCE_FILE_LOCATION = const MessageKind(''' 1885 MessageKind.INVALID_SOURCE_FILE_LOCATION:
1886 const MessageTemplate(MessageKind.INVALID_SOURCE_FILE_LOCATION, '''
1298 Invalid offset (#{offset}) in source map. 1887 Invalid offset (#{offset}) in source map.
1299 File: #{fileName} 1888 File: #{fileName}
1300 Length: #{length}'''); 1889 Length: #{length}'''),
1301 1890
1302 static const MessageKind TOP_LEVEL_VARIABLE_DECLARED_STATIC = 1891 MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC:
1303 const MessageKind( 1892 const MessageTemplate(MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC,
1304 "Top-level variable cannot be declared static."); 1893 "Top-level variable cannot be declared static."),
1305 1894
1306 static const MessageKind REFERENCE_IN_INITIALIZATION = const MessageKind( 1895 MessageKind.REFERENCE_IN_INITIALIZATION:
1307 "Variable '#{variableName}' is referenced during its " 1896 const MessageTemplate(MessageKind.REFERENCE_IN_INITIALIZATION,
1308 "initialization.", 1897 "Variable '#{variableName}' is referenced during its "
1309 howToFix: "If you are trying to reference a shadowed variable, rename" 1898 "initialization.",
1310 " one of the variables.", 1899 howToFix:
1311 examples: const [""" 1900 "If you are trying to reference a shadowed variable, rename "
1901 "one of the variables.",
1902 examples: const ["""
1312 foo(t) { 1903 foo(t) {
1313 var t = t; 1904 var t = t;
1314 return t; 1905 return t;
1315 } 1906 }
1316 1907
1317 main() => foo(1); 1908 main() => foo(1);
1318 """]); 1909 """]),
1319 1910
1320 static const MessageKind CONST_WITHOUT_INITIALIZER = const MessageKind( 1911 MessageKind.CONST_WITHOUT_INITIALIZER:
1321 "A constant variable must be initialized.", 1912 const MessageTemplate(MessageKind.CONST_WITHOUT_INITIALIZER,
1322 howToFix: "Try adding an initializer or " 1913 "A constant variable must be initialized.",
1323 "removing the 'const' modifier.", 1914 howToFix: "Try adding an initializer or "
1324 examples: const [""" 1915 "removing the 'const' modifier.",
1916 examples: const ["""
1325 void main() { 1917 void main() {
1326 const c; // This constant variable must be initialized. 1918 const c; // This constant variable must be initialized.
1327 }"""]); 1919 }"""]),
1328 1920
1329 static const MessageKind FINAL_WITHOUT_INITIALIZER = const MessageKind( 1921 MessageKind.FINAL_WITHOUT_INITIALIZER:
1330 "A final variable must be initialized.", 1922 const MessageTemplate(MessageKind.FINAL_WITHOUT_INITIALIZER,
1331 howToFix: "Try adding an initializer or " 1923 "A final variable must be initialized.",
1332 "removing the 'final' modifier.", 1924 howToFix: "Try adding an initializer or "
1333 examples: const [ 1925 "removing the 'final' modifier.",
1334 "class C { static final field; } main() => C.field;"]); 1926 examples: const [
1927 "class C { static final field; } main() => C.field;"]),
1335 1928
1336 static const MessageKind MEMBER_USES_CLASS_NAME = const MessageKind( 1929 MessageKind.MEMBER_USES_CLASS_NAME:
1337 "Member variable can't have the same name as the class it is " 1930 const MessageTemplate(MessageKind.MEMBER_USES_CLASS_NAME,
1338 "declared in.", 1931 "Member variable can't have the same name as the class it is "
1339 howToFix: "Try renaming the variable.", 1932 "declared in.",
1340 examples: const [""" 1933 howToFix: "Try renaming the variable.",
1934 examples: const ["""
1341 class A { var A; } 1935 class A { var A; }
1342 main() { 1936 main() {
1343 var a = new A(); 1937 var a = new A();
1344 a.A = 1; 1938 a.A = 1;
1345 } 1939 }
1346 """, """ 1940 """, """
1347 class A { static var A; } 1941 class A { static var A; }
1348 main() => A.A = 1; 1942 main() => A.A = 1;
1349 """]); 1943 """]),
1350 1944
1351 static const MessageKind WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT = 1945 MessageKind.WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT:
1352 const MessageKind( 1946 const MessageTemplate(
1947 MessageKind.WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT,
1353 "Wrong number of arguments to assert. Should be 1, but given " 1948 "Wrong number of arguments to assert. Should be 1, but given "
1354 "#{argumentCount}."); 1949 "#{argumentCount}."),
1355 1950
1356 static const MessageKind ASSERT_IS_GIVEN_NAMED_ARGUMENTS = const MessageKind( 1951 MessageKind.ASSERT_IS_GIVEN_NAMED_ARGUMENTS:
1357 "'assert' takes no named arguments, but given #{argumentCount}."); 1952 const MessageTemplate(MessageKind.ASSERT_IS_GIVEN_NAMED_ARGUMENTS,
1953 "'assert' takes no named arguments, but given #{argumentCount}."),
1358 1954
1359 static const MessageKind FACTORY_REDIRECTION_IN_NON_FACTORY = 1955 MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY:
1360 const MessageKind( 1956 const MessageTemplate(MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY,
1361 "Factory redirection only allowed in factories."); 1957 "Factory redirection only allowed in factories."),
1362 1958
1363 static const MessageKind MISSING_FACTORY_KEYWORD = const MessageKind( 1959 MessageKind.MISSING_FACTORY_KEYWORD:
1364 "Did you forget a factory keyword here?"); 1960 const MessageTemplate(MessageKind.MISSING_FACTORY_KEYWORD,
1961 "Did you forget a factory keyword here?"),
1365 1962
1366 static const MessageKind NO_SUCH_METHOD_IN_NATIVE = 1963 MessageKind.NO_SUCH_METHOD_IN_NATIVE:
1367 const MessageKind( 1964 const MessageTemplate(MessageKind.NO_SUCH_METHOD_IN_NATIVE,
1368 "'NoSuchMethod' is not supported for classes that extend native " 1965 "'NoSuchMethod' is not supported for classes that extend native "
1369 "classes."); 1966 "classes."),
1370 1967
1371 static const MessageKind DEFERRED_LIBRARY_DART_2_DART = 1968 MessageKind.DEFERRED_LIBRARY_DART_2_DART:
1372 const MessageKind( 1969 const MessageTemplate(MessageKind.DEFERRED_LIBRARY_DART_2_DART,
1373 "Deferred loading is not supported by the dart backend yet. " 1970 "Deferred loading is not supported by the dart backend yet. "
1374 "The output will not be split."); 1971 "The output will not be split."),
1375 1972
1376 static const MessageKind DEFERRED_LIBRARY_WITHOUT_PREFIX = 1973 MessageKind.DEFERRED_LIBRARY_WITHOUT_PREFIX:
1377 const MessageKind( 1974 const MessageTemplate(MessageKind.DEFERRED_LIBRARY_WITHOUT_PREFIX,
1378 "This import is deferred but there is no prefix keyword.", 1975 "This import is deferred but there is no prefix keyword.",
1379 howToFix: 1976 howToFix: "Try adding a prefix to the import."),
1380 "Try adding a prefix to the import.");
1381 1977
1382 static const MessageKind DEFERRED_OLD_SYNTAX = 1978 MessageKind.DEFERRED_OLD_SYNTAX:
1383 const MessageKind( 1979 const MessageTemplate(MessageKind.DEFERRED_OLD_SYNTAX,
1384 "The DeferredLibrary annotation is obsolete.", 1980 "The DeferredLibrary annotation is obsolete.",
1385 howToFix: 1981 howToFix:
1386 "Use the \"import 'lib.dart' deferred as prefix\" syntax instead."); 1982 "Use the \"import 'lib.dart' deferred as prefix\" syntax instead."),
1387 1983
1388 static const MessageKind DEFERRED_LIBRARY_DUPLICATE_PREFIX = 1984 MessageKind.DEFERRED_LIBRARY_DUPLICATE_PREFIX:
1389 const MessageKind( 1985 const MessageTemplate(MessageKind.DEFERRED_LIBRARY_DUPLICATE_PREFIX,
1390 "The prefix of this deferred import is not unique.", 1986 "The prefix of this deferred import is not unique.",
1391 howToFix: 1987 howToFix: "Try changing the import prefix."),
1392 "Try changing the import prefix.");
1393 1988
1394 static const MessageKind DEFERRED_TYPE_ANNOTATION = 1989 MessageKind.DEFERRED_TYPE_ANNOTATION:
1395 const MessageKind( 1990 const MessageTemplate(MessageKind.DEFERRED_TYPE_ANNOTATION,
1396 "The type #{node} is deferred. " 1991 "The type #{node} is deferred. "
1397 "Deferred types are not valid as type annotations.", 1992 "Deferred types are not valid as type annotations.",
1398 howToFix: 1993 howToFix:
1399 "Try using a non-deferred abstract class as an interface."); 1994 "Try using a non-deferred abstract class as an interface."),
1400 1995
1401 static const MessageKind ILLEGAL_STATIC = const MessageKind( 1996 MessageKind.ILLEGAL_STATIC:
1402 "Modifier static is only allowed on functions declared in " 1997 const MessageTemplate(MessageKind.ILLEGAL_STATIC,
1403 "a class."); 1998 "Modifier static is only allowed on functions declared in "
1999 "a class."),
1404 2000
1405 static const MessageKind STATIC_FUNCTION_BLOAT = const MessageKind( 2001 MessageKind.STATIC_FUNCTION_BLOAT:
1406 "Using '#{class}.#{name}' may lead to unnecessarily large " 2002 const MessageTemplate(MessageKind.STATIC_FUNCTION_BLOAT,
1407 "generated code.", 2003 "Using '#{class}.#{name}' may lead to unnecessarily large "
1408 howToFix: 2004 "generated code.",
1409 "Try adding '@MirrorsUsed(...)' as described at " 2005 howToFix:
1410 "https://goo.gl/Akrrog."); 2006 "Try adding '@MirrorsUsed(...)' as described at "
2007 "https://goo.gl/Akrrog."),
1411 2008
1412 static const MessageKind NON_CONST_BLOAT = const MessageKind( 2009 MessageKind.NON_CONST_BLOAT:
1413 "Using 'new #{name}' may lead to unnecessarily large generated " 2010 const MessageTemplate(MessageKind.NON_CONST_BLOAT,
1414 "code.", 2011 "Using 'new #{name}' may lead to unnecessarily large generated "
1415 howToFix: 2012 "code.",
1416 "Try using 'const #{name}' or adding '@MirrorsUsed(...)' as " 2013 howToFix:
1417 "described at https://goo.gl/Akrrog."); 2014 "Try using 'const #{name}' or adding '@MirrorsUsed(...)' as "
2015 "described at https://goo.gl/Akrrog."),
1418 2016
1419 static const MessageKind STRING_EXPECTED = const MessageKind( 2017 MessageKind.STRING_EXPECTED:
1420 "Expected a 'String', but got an instance of '#{type}'."); 2018 const MessageTemplate(MessageKind.STRING_EXPECTED,
2019 "Expected a 'String', but got an instance of '#{type}'."),
1421 2020
1422 static const MessageKind PRIVATE_IDENTIFIER = const MessageKind( 2021 MessageKind.PRIVATE_IDENTIFIER:
1423 "'#{value}' is not a valid Symbol name because it starts with " 2022 const MessageTemplate(MessageKind.PRIVATE_IDENTIFIER,
1424 "'_'."); 2023 "'#{value}' is not a valid Symbol name because it starts with "
2024 "'_'."),
1425 2025
1426 static const MessageKind PRIVATE_NAMED_PARAMETER = const MessageKind( 2026 MessageKind.PRIVATE_NAMED_PARAMETER:
1427 "Named optional parameter can't have a library private name.", 2027 const MessageTemplate(MessageKind.PRIVATE_NAMED_PARAMETER,
1428 howToFix: "Try removing the '_' or making the parameter positional or " 2028 "Named optional parameter can't have a library private name.",
1429 "required.", 2029 howToFix:
1430 examples: const ["""foo({int _p}) {} main() => foo();"""] 2030 "Try removing the '_' or making the parameter positional or "
1431 ); 2031 "required.",
2032 examples: const ["""foo({int _p}) {} main() => foo();"""]),
1432 2033
1433 static const MessageKind UNSUPPORTED_LITERAL_SYMBOL = const MessageKind( 2034 MessageKind.UNSUPPORTED_LITERAL_SYMBOL:
1434 "Symbol literal '##{value}' is currently unsupported by dart2js."); 2035 const MessageTemplate(MessageKind.UNSUPPORTED_LITERAL_SYMBOL,
2036 "Symbol literal '##{value}' is currently unsupported by dart2js."),
1435 2037
1436 static const MessageKind INVALID_SYMBOL = const MessageKind(''' 2038 MessageKind.INVALID_SYMBOL:
2039 const MessageTemplate(MessageKind.INVALID_SYMBOL, '''
1437 '#{value}' is not a valid Symbol name because is not: 2040 '#{value}' is not a valid Symbol name because is not:
1438 * an empty String, 2041 * an empty String,
1439 * a user defined operator, 2042 * a user defined operator,
1440 * a qualified non-private identifier optionally followed by '=', or 2043 * a qualified non-private identifier optionally followed by '=', or
1441 * a qualified non-private identifier followed by '.' and a user-defined ''' 2044 * a qualified non-private identifier followed by '.' and a user-defined '''
1442 "operator."); 2045 "operator."),
1443 2046
1444 static const MessageKind AMBIGUOUS_REEXPORT = const MessageKind( 2047 MessageKind.AMBIGUOUS_REEXPORT:
1445 "'#{name}' is (re)exported by multiple libraries."); 2048 const MessageTemplate(MessageKind.AMBIGUOUS_REEXPORT,
2049 "'#{name}' is (re)exported by multiple libraries."),
1446 2050
1447 static const MessageKind AMBIGUOUS_LOCATION = const MessageKind( 2051 MessageKind.AMBIGUOUS_LOCATION:
1448 "'#{name}' is defined here."); 2052 const MessageTemplate(MessageKind.AMBIGUOUS_LOCATION,
2053 "'#{name}' is defined here."),
1449 2054
1450 static const MessageKind IMPORTED_HERE = const MessageKind( 2055 MessageKind.IMPORTED_HERE:
1451 "'#{name}' is imported here."); 2056 const MessageTemplate(MessageKind.IMPORTED_HERE,
2057 "'#{name}' is imported here."),
1452 2058
1453 static const MessageKind OVERRIDE_EQUALS_NOT_HASH_CODE = const MessageKind( 2059 MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE:
1454 "The class '#{class}' overrides 'operator==', " 2060 const MessageTemplate(MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE,
1455 "but not 'get hashCode'."); 2061 "The class '#{class}' overrides 'operator==', "
2062 "but not 'get hashCode'."),
1456 2063
1457 static const MessageKind INTERNAL_LIBRARY_FROM = const MessageKind( 2064 MessageKind.INTERNAL_LIBRARY_FROM:
1458 "Internal library '#{resolvedUri}' is not accessible from " 2065 const MessageTemplate(MessageKind.INTERNAL_LIBRARY_FROM,
1459 "'#{importingUri}'."); 2066 "Internal library '#{resolvedUri}' is not accessible from "
2067 "'#{importingUri}'."),
1460 2068
1461 static const MessageKind INTERNAL_LIBRARY = const MessageKind( 2069 MessageKind.INTERNAL_LIBRARY:
1462 "Internal library '#{resolvedUri}' is not accessible."); 2070 const MessageTemplate(MessageKind.INTERNAL_LIBRARY,
2071 "Internal library '#{resolvedUri}' is not accessible."),
1463 2072
1464 static const MessageKind LIBRARY_NOT_FOUND = const MessageKind( 2073 MessageKind.LIBRARY_NOT_FOUND:
1465 "Library not found '#{resolvedUri}'."); 2074 const MessageTemplate(MessageKind.LIBRARY_NOT_FOUND,
2075 "Library not found '#{resolvedUri}'."),
1466 2076
1467 static const MessageKind UNSUPPORTED_EQ_EQ_EQ = const MessageKind( 2077 MessageKind.UNSUPPORTED_EQ_EQ_EQ:
1468 "'===' is not an operator. " 2078 const MessageTemplate(MessageKind.UNSUPPORTED_EQ_EQ_EQ,
1469 "Did you mean '#{lhs} == #{rhs}' or 'identical(#{lhs}, #{rhs})'?"); 2079 "'===' is not an operator. "
2080 "Did you mean '#{lhs} == #{rhs}' or 'identical(#{lhs}, #{rhs})'?"),
1470 2081
1471 static const MessageKind UNSUPPORTED_BANG_EQ_EQ = const MessageKind( 2082 MessageKind.UNSUPPORTED_BANG_EQ_EQ:
1472 "'!==' is not an operator. " 2083 const MessageTemplate(MessageKind.UNSUPPORTED_BANG_EQ_EQ,
1473 "Did you mean '#{lhs} != #{rhs}' or '!identical(#{lhs}, #{rhs})'?"); 2084 "'!==' is not an operator. "
2085 "Did you mean '#{lhs} != #{rhs}' or '!identical(#{lhs}, #{rhs})'?"),
1474 2086
1475 static const MessageKind UNSUPPORTED_PREFIX_PLUS = const MessageKind( 2087 MessageKind.UNSUPPORTED_PREFIX_PLUS:
1476 "'+' is not a prefix operator. ", 2088 const MessageTemplate(MessageKind.UNSUPPORTED_PREFIX_PLUS,
1477 howToFix: "Try removing '+'.", 2089 "'+' is not a prefix operator. ",
1478 examples: const [ 2090 howToFix: "Try removing '+'.",
1479 "main() => +2; // No longer a valid way to write '2'" 2091 examples: const [
1480 ]); 2092 "main() => +2; // No longer a valid way to write '2'"
2093 ]),
1481 2094
1482 static const MessageKind UNSUPPORTED_THROW_WITHOUT_EXP = const MessageKind( 2095 MessageKind.UNSUPPORTED_THROW_WITHOUT_EXP:
1483 "No expression after 'throw'. " 2096 const MessageTemplate(MessageKind.UNSUPPORTED_THROW_WITHOUT_EXP,
1484 "Did you mean 'rethrow'?"); 2097 "No expression after 'throw'. "
2098 "Did you mean 'rethrow'?"),
1485 2099
1486 static const MessageKind DEPRECATED_TYPEDEF_MIXIN_SYNTAX = const MessageKind( 2100 MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX:
1487 "'typedef' not allowed here. ", 2101 const MessageTemplate(MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX,
1488 howToFix: "Try replacing 'typedef' with 'class'.", 2102 "'typedef' not allowed here. ",
1489 examples: const [ 2103 howToFix: "Try replacing 'typedef' with 'class'.",
1490 """ 2104 examples: const [
2105 """
1491 class B { } 2106 class B { }
1492 class M1 { } 2107 class M1 { }
1493 typedef C = B with M1; // Need to replace 'typedef' with 'class'. 2108 typedef C = B with M1; // Need to replace 'typedef' with 'class'.
1494 main() { new C(); } 2109 main() { new C(); }
1495 """] 2110 """]),
1496 );
1497 2111
1498 static const MessageKind MIRRORS_EXPECTED_STRING = const MessageKind( 2112 MessageKind.MIRRORS_EXPECTED_STRING:
1499 "Can't use '#{name}' here because it's an instance of '#{type}' " 2113 const MessageTemplate(MessageKind.MIRRORS_EXPECTED_STRING,
1500 "and a 'String' value is expected.", 2114 "Can't use '#{name}' here because it's an instance of '#{type}' "
1501 howToFix: "Did you forget to add quotes?", 2115 "and a 'String' value is expected.",
1502 examples: const [ 2116 howToFix: "Did you forget to add quotes?",
1503 """ 2117 examples: const [
2118 """
1504 // 'Foo' is a type literal, not a string. 2119 // 'Foo' is a type literal, not a string.
1505 @MirrorsUsed(symbols: const [Foo]) 2120 @MirrorsUsed(symbols: const [Foo])
1506 import 'dart:mirrors'; 2121 import 'dart:mirrors';
1507 2122
1508 class Foo {} 2123 class Foo {}
1509 2124
1510 main() {} 2125 main() {}
1511 """]); 2126 """]),
1512 2127
1513 static const MessageKind MIRRORS_EXPECTED_STRING_OR_TYPE = const MessageKind( 2128 MessageKind.MIRRORS_EXPECTED_STRING_OR_TYPE:
1514 "Can't use '#{name}' here because it's an instance of '#{type}' " 2129 const MessageTemplate(MessageKind.MIRRORS_EXPECTED_STRING_OR_TYPE,
1515 "and a 'String' or 'Type' value is expected.", 2130 "Can't use '#{name}' here because it's an instance of '#{type}' "
1516 howToFix: "Did you forget to add quotes?", 2131 "and a 'String' or 'Type' value is expected.",
1517 examples: const [ 2132 howToFix: "Did you forget to add quotes?",
1518 """ 2133 examples: const [
2134 """
1519 // 'main' is a method, not a class. 2135 // 'main' is a method, not a class.
1520 @MirrorsUsed(targets: const [main]) 2136 @MirrorsUsed(targets: const [main])
1521 import 'dart:mirrors'; 2137 import 'dart:mirrors';
1522 2138
1523 main() {} 2139 main() {}
1524 """]); 2140 """]),
1525 2141
1526 static const MessageKind MIRRORS_EXPECTED_STRING_OR_LIST = const MessageKind( 2142 MessageKind.MIRRORS_EXPECTED_STRING_OR_LIST:
1527 "Can't use '#{name}' here because it's an instance of '#{type}' " 2143 const MessageTemplate(MessageKind.MIRRORS_EXPECTED_STRING_OR_LIST,
1528 "and a 'String' or 'List' value is expected.", 2144 "Can't use '#{name}' here because it's an instance of '#{type}' "
1529 howToFix: "Did you forget to add quotes?", 2145 "and a 'String' or 'List' value is expected.",
1530 examples: const [ 2146 howToFix: "Did you forget to add quotes?",
1531 """ 2147 examples: const [
2148 """
1532 // 'Foo' is not a string. 2149 // 'Foo' is not a string.
1533 @MirrorsUsed(symbols: Foo) 2150 @MirrorsUsed(symbols: Foo)
1534 import 'dart:mirrors'; 2151 import 'dart:mirrors';
1535 2152
1536 class Foo {} 2153 class Foo {}
1537 2154
1538 main() {} 2155 main() {}
1539 """]); 2156 """]),
1540 2157
1541 static const MessageKind MIRRORS_EXPECTED_STRING_TYPE_OR_LIST = 2158 MessageKind.MIRRORS_EXPECTED_STRING_TYPE_OR_LIST:
1542 const MessageKind( 2159 const MessageTemplate(MessageKind.MIRRORS_EXPECTED_STRING_TYPE_OR_LIST,
1543 "Can't use '#{name}' here because it's an instance of '#{type}' " 2160 "Can't use '#{name}' here because it's an instance of '#{type}' "
1544 "but a 'String', 'Type', or 'List' value is expected.", 2161 "but a 'String', 'Type', or 'List' value is expected.",
1545 howToFix: "Did you forget to add quotes?", 2162 howToFix: "Did you forget to add quotes?",
1546 examples: const [ 2163 examples: const [
1547 """ 2164 """
1548 // '1' is not a string. 2165 // '1' is not a string.
1549 @MirrorsUsed(targets: 1) 2166 @MirrorsUsed(targets: 1)
1550 import 'dart:mirrors'; 2167 import 'dart:mirrors';
1551 2168
1552 main() {} 2169 main() {}
1553 """]); 2170 """]),
1554 2171
1555 static const MessageKind MIRRORS_CANNOT_RESOLVE_IN_CURRENT_LIBRARY = 2172 MessageKind.MIRRORS_CANNOT_RESOLVE_IN_CURRENT_LIBRARY:
1556 const MessageKind( 2173 const MessageTemplate(
1557 "Can't find '#{name}' in the current library.", 2174 MessageKind.MIRRORS_CANNOT_RESOLVE_IN_CURRENT_LIBRARY,
1558 // TODO(ahe): The closest identifiers in edit distance would be nice. 2175 "Can't find '#{name}' in the current library.",
1559 howToFix: "Did you forget to add an import?", 2176 // TODO(ahe): The closest identifiers in edit distance would be nice.
1560 examples: const [ 2177 howToFix: "Did you forget to add an import?",
1561 """ 2178 examples: const [
2179 """
1562 // 'window' is not in scope because dart:html isn't imported. 2180 // 'window' is not in scope because dart:html isn't imported.
1563 @MirrorsUsed(targets: 'window') 2181 @MirrorsUsed(targets: 'window')
1564 import 'dart:mirrors'; 2182 import 'dart:mirrors';
1565 2183
1566 main() {} 2184 main() {}
1567 """]); 2185 """]),
1568 2186
1569 static const MessageKind MIRRORS_CANNOT_RESOLVE_IN_LIBRARY = 2187 MessageKind.MIRRORS_CANNOT_RESOLVE_IN_LIBRARY:
1570 const MessageKind( 2188 const MessageTemplate(MessageKind.MIRRORS_CANNOT_RESOLVE_IN_LIBRARY,
1571 "Can't find '#{name}' in the library '#{library}'.", 2189 "Can't find '#{name}' in the library '#{library}'.",
1572 // TODO(ahe): The closest identifiers in edit distance would be nice. 2190 // TODO(ahe): The closest identifiers in edit distance would be nice.
1573 howToFix: "Is '#{name}' spelled right?", 2191 howToFix: "Is '#{name}' spelled right?",
1574 examples: const [ 2192 examples: const [
1575 """ 2193 """
1576 // 'List' is misspelled. 2194 // 'List' is misspelled.
1577 @MirrorsUsed(targets: 'dart.core.Lsit') 2195 @MirrorsUsed(targets: 'dart.core.Lsit')
1578 import 'dart:mirrors'; 2196 import 'dart:mirrors';
1579 2197
1580 main() {} 2198 main() {}
1581 """]); 2199 """]),
1582 2200
1583 static const MessageKind MIRRORS_CANNOT_FIND_IN_ELEMENT = 2201 MessageKind.MIRRORS_CANNOT_FIND_IN_ELEMENT:
1584 const MessageKind( 2202 const MessageTemplate(MessageKind.MIRRORS_CANNOT_FIND_IN_ELEMENT,
1585 "Can't find '#{name}' in '#{element}'.", 2203 "Can't find '#{name}' in '#{element}'.",
1586 // TODO(ahe): The closest identifiers in edit distance would be nice. 2204 // TODO(ahe): The closest identifiers in edit distance would be nice.
1587 howToFix: "Is '#{name}' spelled right?", 2205 howToFix: "Is '#{name}' spelled right?",
1588 examples: const [ 2206 examples: const [
1589 """ 2207 """
1590 // 'addAll' is misspelled. 2208 // 'addAll' is misspelled.
1591 @MirrorsUsed(targets: 'dart.core.List.addAl') 2209 @MirrorsUsed(targets: 'dart.core.List.addAl')
1592 import 'dart:mirrors'; 2210 import 'dart:mirrors';
1593 2211
1594 main() {} 2212 main() {}
1595 """]); 2213 """]),
1596 2214
1597 static const MessageKind INVALID_URI = const MessageKind( 2215 MessageKind.INVALID_URI:
1598 "'#{uri}' is not a valid URI.", 2216 const MessageTemplate(MessageKind.INVALID_URI,
1599 howToFix: DONT_KNOW_HOW_TO_FIX, 2217 "'#{uri}' is not a valid URI.",
1600 examples: const [ 2218 howToFix: DONT_KNOW_HOW_TO_FIX,
1601 """ 2219 examples: const [
2220 """
1602 // can't have a '[' in a URI 2221 // can't have a '[' in a URI
1603 import '../../Udyn[mic ils/expect.dart'; 2222 import '../../Udyn[mic ils/expect.dart';
1604 2223
1605 main() {} 2224 main() {}
1606 """]); 2225 """]),
1607 2226
1608 static const MessageKind INVALID_PACKAGE_URI = const MessageKind( 2227 MessageKind.INVALID_PACKAGE_URI:
1609 "'#{uri}' is not a valid package URI (#{exception}).", 2228 const MessageTemplate(MessageKind.INVALID_PACKAGE_URI,
1610 howToFix: DONT_KNOW_HOW_TO_FIX, 2229 "'#{uri}' is not a valid package URI (#{exception}).",
1611 examples: const [ 2230 howToFix: DONT_KNOW_HOW_TO_FIX,
1612 """ 2231 examples: const [
2232 """
1613 // can't have a 'top level' package URI 2233 // can't have a 'top level' package URI
1614 import 'package:foo.dart'; 2234 import 'package:foo.dart';
1615 2235
1616 main() {} 2236 main() {}
1617 """, """ 2237 """, """
1618 // can't have 2 slashes 2238 // can't have 2 slashes
1619 import 'package://foo/foo.dart'; 2239 import 'package://foo/foo.dart';
1620 2240
1621 main() {} 2241 main() {}
1622 """, """ 2242 """, """
1623 // package name must be valid 2243 // package name must be valid
1624 import 'package:not\valid/foo.dart'; 2244 import 'package:not\valid/foo.dart';
1625 2245
1626 main() {} 2246 main() {}
1627 """]); 2247 """]),
1628 2248
1629 static const MessageKind READ_SCRIPT_ERROR = const MessageKind( 2249 MessageKind.READ_SCRIPT_ERROR:
1630 "Can't read '#{uri}' (#{exception}).", 2250 const MessageTemplate(MessageKind.READ_SCRIPT_ERROR,
1631 // Don't know how to fix since the underlying error is unknown. 2251 "Can't read '#{uri}' (#{exception}).",
1632 howToFix: DONT_KNOW_HOW_TO_FIX, 2252 // Don't know how to fix since the underlying error is unknown.
1633 examples: const [ 2253 howToFix: DONT_KNOW_HOW_TO_FIX,
1634 """ 2254 examples: const [
2255 """
1635 // 'foo.dart' does not exist. 2256 // 'foo.dart' does not exist.
1636 import 'foo.dart'; 2257 import 'foo.dart';
1637 2258
1638 main() {} 2259 main() {}
1639 """]); 2260 """]),
1640 2261
1641 static const MessageKind READ_SELF_ERROR = const MessageKind( 2262 MessageKind.READ_SELF_ERROR:
1642 "#{exception}", 2263 const MessageTemplate(MessageKind.READ_SELF_ERROR,
1643 // Don't know how to fix since the underlying error is unknown. 2264 "#{exception}",
1644 howToFix: DONT_KNOW_HOW_TO_FIX); 2265 // Don't know how to fix since the underlying error is unknown.
2266 howToFix: DONT_KNOW_HOW_TO_FIX),
1645 2267
1646 static const MessageKind EXTRANEOUS_MODIFIER = const MessageKind( 2268 MessageKind.EXTRANEOUS_MODIFIER:
1647 "Can't have modifier '#{modifier}' here.", 2269 const MessageTemplate(MessageKind.EXTRANEOUS_MODIFIER,
1648 howToFix: "Try removing '#{modifier}'.", 2270 "Can't have modifier '#{modifier}' here.",
1649 examples: const [ 2271 howToFix: "Try removing '#{modifier}'.",
1650 "var String foo; main(){}", 2272 examples: const [
1651 // "var get foo; main(){}", 2273 "var String foo; main(){}",
1652 "var set foo; main(){}", 2274 // "var get foo; main(){}",
1653 "var final foo; main(){}", 2275 "var set foo; main(){}",
1654 "var var foo; main(){}", 2276 "var final foo; main(){}",
1655 "var const foo; main(){}", 2277 "var var foo; main(){}",
1656 "var abstract foo; main(){}", 2278 "var const foo; main(){}",
1657 "var static foo; main(){}", 2279 "var abstract foo; main(){}",
1658 "var external foo; main(){}", 2280 "var static foo; main(){}",
1659 "get var foo; main(){}", 2281 "var external foo; main(){}",
1660 "set var foo; main(){}", 2282 "get var foo; main(){}",
1661 "final var foo; main(){}", 2283 "set var foo; main(){}",
1662 "var var foo; main(){}", 2284 "final var foo; main(){}",
1663 "const var foo; main(){}", 2285 "var var foo; main(){}",
1664 "abstract var foo; main(){}", 2286 "const var foo; main(){}",
1665 "static var foo; main(){}", 2287 "abstract var foo; main(){}",
1666 "external var foo; main(){}"]); 2288 "static var foo; main(){}",
2289 "external var foo; main(){}"]),
1667 2290
1668 static const MessageKind EXTRANEOUS_MODIFIER_REPLACE = const MessageKind( 2291 MessageKind.EXTRANEOUS_MODIFIER_REPLACE:
1669 "Can't have modifier '#{modifier}' here.", 2292 const MessageTemplate(MessageKind.EXTRANEOUS_MODIFIER_REPLACE,
1670 howToFix: "Try replacing modifier '#{modifier}' with 'var', 'final'," 2293 "Can't have modifier '#{modifier}' here.",
1671 " or a type.", 2294 howToFix:
1672 examples: const [ 2295 "Try replacing modifier '#{modifier}' with 'var', 'final', "
1673 // "get foo; main(){}", 2296 "or a type.",
1674 "set foo; main(){}", 2297 examples: const [
1675 "abstract foo; main(){}", 2298 // "get foo; main(){}",
1676 "static foo; main(){}", 2299 "set foo; main(){}",
1677 "external foo; main(){}"]); 2300 "abstract foo; main(){}",
2301 "static foo; main(){}",
2302 "external foo; main(){}"]),
1678 2303
1679 static const MessageKind ABSTRACT_CLASS_INSTANTIATION = const MessageKind( 2304 MessageKind.ABSTRACT_CLASS_INSTANTIATION:
1680 "Can't instantiate abstract class.", 2305 const MessageTemplate(MessageKind.ABSTRACT_CLASS_INSTANTIATION,
1681 howToFix: DONT_KNOW_HOW_TO_FIX, 2306 "Can't instantiate abstract class.",
1682 examples: const ["abstract class A {} main() { new A(); }"]); 2307 howToFix: DONT_KNOW_HOW_TO_FIX,
2308 examples: const ["abstract class A {} main() { new A(); }"]),
1683 2309
1684 static const MessageKind BODY_EXPECTED = const MessageKind( 2310 MessageKind.BODY_EXPECTED:
1685 "Expected a function body or '=>'.", 2311 const MessageTemplate(MessageKind.BODY_EXPECTED,
1686 // TODO(ahe): In some scenarios, we can suggest removing the 'static' 2312 "Expected a function body or '=>'.",
1687 // keyword. 2313 // TODO(ahe): In some scenarios, we can suggest removing the 'static'
1688 howToFix: "Try adding {}.", 2314 // keyword.
1689 examples: const [ 2315 howToFix: "Try adding {}.",
1690 "main();"]); 2316 examples: const [
2317 "main();"]),
1691 2318
1692 static const MessageKind MIRROR_BLOAT = const MessageKind( 2319 MessageKind.MIRROR_BLOAT:
1693 "#{count} methods retained for use by dart:mirrors out of #{total}" 2320 const MessageTemplate(MessageKind.MIRROR_BLOAT,
1694 " total methods (#{percentage}%)."); 2321 "#{count} methods retained for use by dart:mirrors out of #{total}"
2322 " total methods (#{percentage}%)."),
1695 2323
1696 static const MessageKind MIRROR_IMPORT = const MessageKind( 2324 MessageKind.MIRROR_IMPORT:
1697 "Import of 'dart:mirrors'."); 2325 const MessageTemplate(MessageKind.MIRROR_IMPORT,
2326 "Import of 'dart:mirrors'."),
1698 2327
1699 static const MessageKind MIRROR_IMPORT_NO_USAGE = const MessageKind( 2328 MessageKind.MIRROR_IMPORT_NO_USAGE:
1700 "This import is not annotated with @MirrorsUsed, which may lead to " 2329 const MessageTemplate(MessageKind.MIRROR_IMPORT_NO_USAGE,
1701 "unnecessarily large generated code.", 2330 "This import is not annotated with @MirrorsUsed, which may lead to "
1702 howToFix: 2331 "unnecessarily large generated code.",
1703 "Try adding '@MirrorsUsed(...)' as described at " 2332 howToFix:
1704 "https://goo.gl/Akrrog."); 2333 "Try adding '@MirrorsUsed(...)' as described at "
2334 "https://goo.gl/Akrrog."),
1705 2335
1706 static const MessageKind WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT = 2336 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT:
1707 const MessageKind( 2337 const MessageTemplate(
1708 "Argument for 'JS_INTERCEPTOR_CONSTANT' must be a type constant."); 2338 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT,
2339 "Argument for 'JS_INTERCEPTOR_CONSTANT' must be a type constant."),
1709 2340
1710 static const MessageKind EXPECTED_IDENTIFIER_NOT_RESERVED_WORD = 2341 MessageKind.EXPECTED_IDENTIFIER_NOT_RESERVED_WORD:
1711 const MessageKind( 2342 const MessageTemplate(MessageKind.EXPECTED_IDENTIFIER_NOT_RESERVED_WORD,
1712 "'#{keyword}' is a reserved word and can't be used here.", 2343 "'#{keyword}' is a reserved word and can't be used here.",
1713 howToFix: "Try using a different name.", 2344 howToFix: "Try using a different name.",
1714 examples: const ["do() {} main() {}"]); 2345 examples: const ["do() {} main() {}"]),
1715 2346
1716 static const MessageKind NAMED_FUNCTION_EXPRESSION = 2347 MessageKind. NAMED_FUNCTION_EXPRESSION:
1717 const MessageKind("Function expression '#{name}' cannot be named.", 2348 const MessageTemplate(MessageKind.NAMED_FUNCTION_EXPRESSION,
2349 "Function expression '#{name}' cannot be named.",
1718 howToFix: "Try removing the name.", 2350 howToFix: "Try removing the name.",
1719 examples: const ["main() { var f = func() {}; }"]); 2351 examples: const ["main() { var f = func() {}; }"]),
1720 2352
1721 static const MessageKind UNUSED_METHOD = const MessageKind( 2353 MessageKind.UNUSED_METHOD:
1722 "The method '#{name}' is never called.", 2354 const MessageTemplate(MessageKind.UNUSED_METHOD,
1723 howToFix: "Consider deleting it.", 2355 "The method '#{name}' is never called.",
1724 examples: const ["deadCode() {} main() {}"]); 2356 howToFix: "Consider deleting it.",
2357 examples: const ["deadCode() {} main() {}"]),
1725 2358
1726 static const MessageKind UNUSED_CLASS = const MessageKind( 2359 MessageKind.UNUSED_CLASS:
1727 "The class '#{name}' is never used.", 2360 const MessageTemplate(MessageKind.UNUSED_CLASS,
1728 howToFix: "Consider deleting it.", 2361 "The class '#{name}' is never used.",
1729 examples: const ["class DeadCode {} main() {}"]); 2362 howToFix: "Consider deleting it.",
2363 examples: const ["class DeadCode {} main() {}"]),
1730 2364
1731 static const MessageKind UNUSED_TYPEDEF = const MessageKind( 2365 MessageKind.UNUSED_TYPEDEF:
1732 "The typedef '#{name}' is never used.", 2366 const MessageTemplate(MessageKind.UNUSED_TYPEDEF,
1733 howToFix: "Consider deleting it.", 2367 "The typedef '#{name}' is never used.",
1734 examples: const ["typedef DeadCode(); main() {}"]); 2368 howToFix: "Consider deleting it.",
2369 examples: const ["typedef DeadCode(); main() {}"]),
1735 2370
1736 static const MessageKind ABSTRACT_METHOD = const MessageKind( 2371 MessageKind.ABSTRACT_METHOD:
1737 "The method '#{name}' has no implementation in " 2372 const MessageTemplate(MessageKind.ABSTRACT_METHOD,
1738 "class '#{class}'.", 2373 "The method '#{name}' has no implementation in "
1739 howToFix: "Try adding a body to '#{name}' or declaring " 2374 "class '#{class}'.",
1740 "'#{class}' to be 'abstract'.", 2375 howToFix: "Try adding a body to '#{name}' or declaring "
1741 examples: const [""" 2376 "'#{class}' to be 'abstract'.",
2377 examples: const ["""
1742 class Class { 2378 class Class {
1743 method(); 2379 method();
1744 } 2380 }
1745 main() => new Class().method(); 2381 main() => new Class().method();
1746 """]); 2382 """]),
1747 2383
1748 static const MessageKind ABSTRACT_GETTER = const MessageKind( 2384 MessageKind.ABSTRACT_GETTER:
1749 "The getter '#{name}' has no implementation in " 2385 const MessageTemplate(MessageKind.ABSTRACT_GETTER,
1750 "class '#{class}'.", 2386 "The getter '#{name}' has no implementation in "
1751 howToFix: "Try adding a body to '#{name}' or declaring " 2387 "class '#{class}'.",
1752 "'#{class}' to be 'abstract'.", 2388 howToFix: "Try adding a body to '#{name}' or declaring "
1753 examples: const [""" 2389 "'#{class}' to be 'abstract'.",
2390 examples: const ["""
1754 class Class { 2391 class Class {
1755 get getter; 2392 get getter;
1756 } 2393 }
1757 main() => new Class(); 2394 main() => new Class();
1758 """]); 2395 """]),
1759 2396
1760 static const MessageKind ABSTRACT_SETTER = const MessageKind( 2397 MessageKind.ABSTRACT_SETTER:
1761 "The setter '#{name}' has no implementation in " 2398 const MessageTemplate(MessageKind.ABSTRACT_SETTER,
1762 "class '#{class}'.", 2399 "The setter '#{name}' has no implementation in "
1763 howToFix: "Try adding a body to '#{name}' or declaring " 2400 "class '#{class}'.",
1764 "'#{class}' to be 'abstract'.", 2401 howToFix: "Try adding a body to '#{name}' or declaring "
1765 examples: const [""" 2402 "'#{class}' to be 'abstract'.",
2403 examples: const ["""
1766 class Class { 2404 class Class {
1767 set setter(_); 2405 set setter(_);
1768 } 2406 }
1769 main() => new Class(); 2407 main() => new Class();
1770 """]); 2408 """]),
1771 2409
1772 static const MessageKind INHERIT_GETTER_AND_METHOD = const MessageKind( 2410 MessageKind.INHERIT_GETTER_AND_METHOD:
1773 "The class '#{class}' can't inherit both getters and methods " 2411 const MessageTemplate(MessageKind.INHERIT_GETTER_AND_METHOD,
1774 "by the named '#{name}'.", 2412 "The class '#{class}' can't inherit both getters and methods "
1775 howToFix: DONT_KNOW_HOW_TO_FIX, 2413 "by the named '#{name}'.",
1776 examples: const [""" 2414 howToFix: DONT_KNOW_HOW_TO_FIX,
2415 examples: const ["""
1777 class A { 2416 class A {
1778 get member => null; 2417 get member => null;
1779 } 2418 }
1780 class B { 2419 class B {
1781 member() {} 2420 member() {}
1782 } 2421 }
1783 class Class implements A, B { 2422 class Class implements A, B {
1784 } 2423 }
1785 main() => new Class(); 2424 main() => new Class();
1786 """]); 2425 """]),
1787 2426
1788 static const MessageKind INHERITED_METHOD = const MessageKind( 2427 MessageKind.INHERITED_METHOD:
1789 "The inherited method '#{name}' is declared here in class " 2428 const MessageTemplate(MessageKind.INHERITED_METHOD,
1790 "'#{class}'."); 2429 "The inherited method '#{name}' is declared here in class "
2430 "'#{class}'."),
1791 2431
1792 static const MessageKind INHERITED_EXPLICIT_GETTER = const MessageKind( 2432 MessageKind.INHERITED_EXPLICIT_GETTER:
1793 "The inherited getter '#{name}' is declared here in class " 2433 const MessageTemplate(MessageKind.INHERITED_EXPLICIT_GETTER,
1794 "'#{class}'."); 2434 "The inherited getter '#{name}' is declared here in class "
2435 "'#{class}'."),
1795 2436
1796 static const MessageKind INHERITED_IMPLICIT_GETTER = const MessageKind( 2437 MessageKind.INHERITED_IMPLICIT_GETTER:
1797 "The inherited getter '#{name}' is implicitly declared by this " 2438 const MessageTemplate(MessageKind.INHERITED_IMPLICIT_GETTER,
1798 "field in class '#{class}'."); 2439 "The inherited getter '#{name}' is implicitly declared by this "
2440 "field in class '#{class}'."),
1799 2441
1800 static const MessageKind UNIMPLEMENTED_METHOD_ONE = const MessageKind( 2442 MessageKind.UNIMPLEMENTED_METHOD_ONE:
1801 "'#{class}' doesn't implement '#{method}' " 2443 const MessageTemplate(MessageKind.UNIMPLEMENTED_METHOD_ONE,
1802 "declared in '#{declarer}'.", 2444 "'#{class}' doesn't implement '#{method}' "
1803 howToFix: "Try adding an implementation of '#{name}' or declaring " 2445 "declared in '#{declarer}'.",
1804 "'#{class}' to be 'abstract'.", 2446 howToFix: "Try adding an implementation of '#{name}' or declaring "
1805 examples: const [""" 2447 "'#{class}' to be 'abstract'.",
2448 examples: const ["""
1806 abstract class I { 2449 abstract class I {
1807 m(); 2450 m();
1808 } 2451 }
1809 class C implements I {} 2452 class C implements I {}
1810 main() => new C(); 2453 main() => new C();
1811 """, """ 2454 """, """
1812 abstract class I { 2455 abstract class I {
1813 m(); 2456 m();
1814 } 2457 }
1815 class C extends I {} 2458 class C extends I {}
1816 main() => new C(); 2459 main() => new C();
1817 """]); 2460 """]),
1818 2461
1819 static const MessageKind UNIMPLEMENTED_METHOD = const MessageKind( 2462 MessageKind.UNIMPLEMENTED_METHOD:
1820 "'#{class}' doesn't implement '#{method}'.", 2463 const MessageTemplate(MessageKind.UNIMPLEMENTED_METHOD,
1821 howToFix: "Try adding an implementation of '#{name}' or declaring " 2464 "'#{class}' doesn't implement '#{method}'.",
1822 "'#{class}' to be 'abstract'.", 2465 howToFix: "Try adding an implementation of '#{name}' or declaring "
1823 examples: const [""" 2466 "'#{class}' to be 'abstract'.",
2467 examples: const ["""
1824 abstract class I { 2468 abstract class I {
1825 m(); 2469 m();
1826 } 2470 }
1827 2471
1828 abstract class J { 2472 abstract class J {
1829 m(); 2473 m();
1830 } 2474 }
1831 2475
1832 class C implements I, J {} 2476 class C implements I, J {}
1833 2477
1834 main() { 2478 main() {
1835 new C(); 2479 new C();
1836 } 2480 }
1837 """, """ 2481 """, """
1838 abstract class I { 2482 abstract class I {
1839 m(); 2483 m();
1840 } 2484 }
1841 2485
1842 abstract class J { 2486 abstract class J {
1843 m(); 2487 m();
1844 } 2488 }
1845 2489
1846 class C extends I implements J {} 2490 class C extends I implements J {}
1847 2491
1848 main() { 2492 main() {
1849 new C(); 2493 new C();
1850 } 2494 }
1851 """]); 2495 """]),
1852 2496
1853 static const MessageKind UNIMPLEMENTED_METHOD_CONT = const MessageKind( 2497 MessageKind.UNIMPLEMENTED_METHOD_CONT:
1854 "The method '#{name}' is declared here in class '#{class}'."); 2498 const MessageTemplate(MessageKind.UNIMPLEMENTED_METHOD_CONT,
2499 "The method '#{name}' is declared here in class '#{class}'."),
1855 2500
1856 static const MessageKind UNIMPLEMENTED_SETTER_ONE = const MessageKind( 2501 MessageKind.UNIMPLEMENTED_SETTER_ONE:
1857 "'#{class}' doesn't implement the setter '#{name}' " 2502 const MessageTemplate(MessageKind.UNIMPLEMENTED_SETTER_ONE,
1858 "declared in '#{declarer}'.", 2503 "'#{class}' doesn't implement the setter '#{name}' "
1859 howToFix: "Try adding an implementation of '#{name}' or declaring " 2504 "declared in '#{declarer}'.",
1860 "'#{class}' to be 'abstract'.", 2505 howToFix: "Try adding an implementation of '#{name}' or declaring "
1861 examples: const [""" 2506 "'#{class}' to be 'abstract'.",
2507 examples: const ["""
1862 abstract class I { 2508 abstract class I {
1863 set m(_); 2509 set m(_);
1864 } 2510 }
1865 class C implements I {} 2511 class C implements I {}
1866 class D implements I { 2512 class D implements I {
1867 set m(_) {} 2513 set m(_) {}
1868 } 2514 }
1869 main() { 2515 main() {
1870 new D().m = 0; 2516 new D().m = 0;
1871 new C(); 2517 new C();
1872 } 2518 }
1873 """]); 2519 """]),
1874 2520
1875 static const MessageKind UNIMPLEMENTED_SETTER = const MessageKind( 2521 MessageKind.UNIMPLEMENTED_SETTER:
1876 "'#{class}' doesn't implement the setter '#{name}'.", 2522 const MessageTemplate(MessageKind.UNIMPLEMENTED_SETTER,
1877 howToFix: "Try adding an implementation of '#{name}' or declaring " 2523 "'#{class}' doesn't implement the setter '#{name}'.",
1878 "'#{class}' to be 'abstract'.", 2524 howToFix: "Try adding an implementation of '#{name}' or declaring "
1879 examples: const [""" 2525 "'#{class}' to be 'abstract'.",
2526 examples: const ["""
1880 abstract class I { 2527 abstract class I {
1881 set m(_); 2528 set m(_);
1882 } 2529 }
1883 abstract class J { 2530 abstract class J {
1884 set m(_); 2531 set m(_);
1885 } 2532 }
1886 class C implements I, J {} 2533 class C implements I, J {}
1887 main() => new C(); 2534 main() => new C();
1888 """, """ 2535 """, """
1889 abstract class I { 2536 abstract class I {
1890 set m(_); 2537 set m(_);
1891 } 2538 }
1892 abstract class J { 2539 abstract class J {
1893 set m(_); 2540 set m(_);
1894 } 2541 }
1895 class C extends I implements J {} 2542 class C extends I implements J {}
1896 main() => new C(); 2543 main() => new C();
1897 """]); 2544 """]),
1898 2545
1899 static const MessageKind UNIMPLEMENTED_EXPLICIT_SETTER = const MessageKind( 2546 MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER:
1900 "The setter '#{name}' is declared here in class '#{class}'."); 2547 const MessageTemplate(MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER,
2548 "The setter '#{name}' is declared here in class '#{class}'."),
1901 2549
1902 static const MessageKind UNIMPLEMENTED_IMPLICIT_SETTER = const MessageKind( 2550 MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER:
1903 "The setter '#{name}' is implicitly declared by this field " 2551 const MessageTemplate(MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER,
1904 "in class '#{class}'."); 2552 "The setter '#{name}' is implicitly declared by this field "
2553 "in class '#{class}'."),
1905 2554
1906 static const MessageKind UNIMPLEMENTED_GETTER_ONE = const MessageKind( 2555 MessageKind.UNIMPLEMENTED_GETTER_ONE:
1907 "'#{class}' doesn't implement the getter '#{name}' " 2556 const MessageTemplate(MessageKind.UNIMPLEMENTED_GETTER_ONE,
1908 "declared in '#{declarer}'.", 2557 "'#{class}' doesn't implement the getter '#{name}' "
1909 howToFix: "Try adding an implementation of '#{name}' or declaring " 2558 "declared in '#{declarer}'.",
1910 "'#{class}' to be 'abstract'.", 2559 howToFix: "Try adding an implementation of '#{name}' or declaring "
1911 examples: const [""" 2560 "'#{class}' to be 'abstract'.",
2561 examples: const ["""
1912 abstract class I { 2562 abstract class I {
1913 get m; 2563 get m;
1914 } 2564 }
1915 class C implements I {} 2565 class C implements I {}
1916 main() => new C(); 2566 main() => new C();
1917 """, """ 2567 """, """
1918 abstract class I { 2568 abstract class I {
1919 get m; 2569 get m;
1920 } 2570 }
1921 class C extends I {} 2571 class C extends I {}
1922 main() => new C(); 2572 main() => new C();
1923 """]); 2573 """]),
1924 2574
1925 static const MessageKind UNIMPLEMENTED_GETTER = const MessageKind( 2575 MessageKind.UNIMPLEMENTED_GETTER:
1926 "'#{class}' doesn't implement the getter '#{name}'.", 2576 const MessageTemplate(MessageKind.UNIMPLEMENTED_GETTER,
1927 howToFix: "Try adding an implementation of '#{name}' or declaring " 2577 "'#{class}' doesn't implement the getter '#{name}'.",
1928 "'#{class}' to be 'abstract'.", 2578 howToFix: "Try adding an implementation of '#{name}' or declaring "
1929 examples: const [""" 2579 "'#{class}' to be 'abstract'.",
2580 examples: const ["""
1930 abstract class I { 2581 abstract class I {
1931 get m; 2582 get m;
1932 } 2583 }
1933 abstract class J { 2584 abstract class J {
1934 get m; 2585 get m;
1935 } 2586 }
1936 class C implements I, J {} 2587 class C implements I, J {}
1937 main() => new C(); 2588 main() => new C();
1938 """, """ 2589 """, """
1939 abstract class I { 2590 abstract class I {
1940 get m; 2591 get m;
1941 } 2592 }
1942 abstract class J { 2593 abstract class J {
1943 get m; 2594 get m;
1944 } 2595 }
1945 class C extends I implements J {} 2596 class C extends I implements J {}
1946 main() => new C(); 2597 main() => new C();
1947 """]); 2598 """]),
1948 2599
1949 static const MessageKind UNIMPLEMENTED_EXPLICIT_GETTER = const MessageKind( 2600 MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER:
1950 "The getter '#{name}' is declared here in class '#{class}'."); 2601 const MessageTemplate(MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER,
2602 "The getter '#{name}' is declared here in class '#{class}'."),
1951 2603
1952 static const MessageKind UNIMPLEMENTED_IMPLICIT_GETTER = const MessageKind( 2604 MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER:
1953 "The getter '#{name}' is implicitly declared by this field " 2605 const MessageTemplate(MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
1954 "in class '#{class}'."); 2606 "The getter '#{name}' is implicitly declared by this field "
2607 "in class '#{class}'."),
1955 2608
1956 static const MessageKind EQUAL_MAP_ENTRY_KEY = const MessageKind( 2609 MessageKind.EQUAL_MAP_ENTRY_KEY:
1957 "An entry with the same key already exists in the map.", 2610 const MessageTemplate(MessageKind.EQUAL_MAP_ENTRY_KEY,
1958 howToFix: "Try removing the previous entry or changing the key in one " 2611 "An entry with the same key already exists in the map.",
1959 "of the entries.", 2612 howToFix:
1960 examples: const [""" 2613 "Try removing the previous entry or changing the key in one "
2614 "of the entries.",
2615 examples: const ["""
1961 main() { 2616 main() {
1962 var m = const {'foo': 1, 'foo': 2}; 2617 var m = const {'foo': 1, 'foo': 2};
1963 }"""]); 2618 }"""]),
1964 2619
1965 static const MessageKind BAD_INPUT_CHARACTER = const MessageKind( 2620 MessageKind.BAD_INPUT_CHARACTER:
1966 "Character U+#{characterHex} isn't allowed here.", 2621 const MessageTemplate(MessageKind.BAD_INPUT_CHARACTER,
1967 howToFix: DONT_KNOW_HOW_TO_FIX, 2622 "Character U+#{characterHex} isn't allowed here.",
1968 examples: const [""" 2623 howToFix: DONT_KNOW_HOW_TO_FIX,
2624 examples: const ["""
1969 main() { 2625 main() {
1970 String x = ç; 2626 String x = ç;
1971 } 2627 }
1972 """]); 2628 """]),
1973 2629
1974 static const MessageKind UNTERMINATED_STRING = const MessageKind( 2630 MessageKind.UNTERMINATED_STRING:
1975 "String must end with #{quote}.", 2631 const MessageTemplate(MessageKind.UNTERMINATED_STRING,
1976 howToFix: DONT_KNOW_HOW_TO_FIX, 2632 "String must end with #{quote}.",
1977 examples: const [""" 2633 howToFix: DONT_KNOW_HOW_TO_FIX,
2634 examples: const ["""
1978 main() { 2635 main() {
1979 return ' 2636 return '
1980 ; 2637 ;
1981 } 2638 }
1982 """, 2639 """,
1983 """ 2640 """
1984 main() { 2641 main() {
1985 return \" 2642 return \"
1986 ; 2643 ;
1987 } 2644 }
(...skipping 14 matching lines...) Expand all
2002 main() => ''' 2659 main() => '''
2003 """, 2660 """,
2004 """ 2661 """
2005 main() => \"\"\" 2662 main() => \"\"\"
2006 """, 2663 """,
2007 """ 2664 """
2008 main() => r''' 2665 main() => r'''
2009 """, 2666 """,
2010 """ 2667 """
2011 main() => r\"\"\" 2668 main() => r\"\"\"
2012 """]); 2669 """]),
2013 2670
2014 static const MessageKind UNMATCHED_TOKEN = const MessageKind( 2671 MessageKind.UNMATCHED_TOKEN:
2015 "Can't find '#{end}' to match '#{begin}'.", 2672 const MessageTemplate(MessageKind.UNMATCHED_TOKEN,
2016 howToFix: DONT_KNOW_HOW_TO_FIX, 2673 "Can't find '#{end}' to match '#{begin}'.",
2017 examples: const[ 2674 howToFix: DONT_KNOW_HOW_TO_FIX,
2018 "main(", 2675 examples: const[
2019 "main(){", 2676 "main(",
2020 "main(){]}", 2677 "main(){",
2021 ]); 2678 "main(){]}",
2679 ]),
2022 2680
2023 static const MessageKind UNTERMINATED_TOKEN = const MessageKind( 2681 MessageKind.UNTERMINATED_TOKEN:
2024 // This is a fall-back message that shouldn't happen. 2682 const MessageTemplate(MessageKind.UNTERMINATED_TOKEN,
2025 "Incomplete token."); 2683 // This is a fall-back message that shouldn't happen.
2684 "Incomplete token."),
2026 2685
2027 static const MessageKind EXPONENT_MISSING = const MessageKind( 2686 MessageKind.EXPONENT_MISSING:
2028 "Numbers in exponential notation should always contain an exponent" 2687 const MessageTemplate(MessageKind.EXPONENT_MISSING,
2029 " (an integer number with an optional sign).", 2688 "Numbers in exponential notation should always contain an exponent"
2030 howToFix: "Make sure there is an exponent, and remove any whitespace " 2689 " (an integer number with an optional sign).",
2031 "before it.", 2690 howToFix:
2032 examples: const [""" 2691 "Make sure there is an exponent, and remove any whitespace "
2692 "before it.",
2693 examples: const ["""
2033 main() { 2694 main() {
2034 var i = 1e; 2695 var i = 1e;
2035 } 2696 }
2036 """]); 2697 """]),
2037 2698
2038 static const MessageKind HEX_DIGIT_EXPECTED = const MessageKind( 2699 MessageKind.HEX_DIGIT_EXPECTED:
2039 "A hex digit (0-9 or A-F) must follow '0x'.", 2700 const MessageTemplate(MessageKind.HEX_DIGIT_EXPECTED,
2040 howToFix: DONT_KNOW_HOW_TO_FIX, // Seems obvious from the error message. 2701 "A hex digit (0-9 or A-F) must follow '0x'.",
2041 examples: const [""" 2702 howToFix:
2703 DONT_KNOW_HOW_TO_FIX, // Seems obvious from the error message.
2704 examples: const ["""
2042 main() { 2705 main() {
2043 var i = 0x; 2706 var i = 0x;
2044 } 2707 }
2045 """]); 2708 """]),
2046 2709
2047 static const MessageKind MALFORMED_STRING_LITERAL = const MessageKind( 2710 MessageKind.MALFORMED_STRING_LITERAL:
2048 r"A '$' has special meaning inside a string, and must be followed by an" 2711 const MessageTemplate(MessageKind.MALFORMED_STRING_LITERAL,
2049 " identifier or an expression in curly braces ({}).", 2712 r"A '$' has special meaning inside a string, and must be followed by "
2050 howToFix: r"Try adding a backslash (\) to escape the '$'.", 2713 "an identifier or an expression in curly braces ({}).",
2051 examples: const [r""" 2714 howToFix: r"Try adding a backslash (\) to escape the '$'.",
2715 examples: const [r"""
2052 main() { 2716 main() {
2053 return '$'; 2717 return '$';
2054 } 2718 }
2055 """, 2719 """,
2056 r''' 2720 r'''
2057 main() { 2721 main() {
2058 return "$"; 2722 return "$";
2059 } 2723 }
2060 ''', 2724 ''',
2061 r""" 2725 r"""
2062 main() { 2726 main() {
2063 return '''$'''; 2727 return '''$''';
2064 } 2728 }
2065 """, 2729 """,
2066 r''' 2730 r'''
2067 main() { 2731 main() {
2068 return """$"""; 2732 return """$""";
2069 } 2733 }
2070 ''']); 2734 ''']),
2071 2735
2072 static const MessageKind UNTERMINATED_COMMENT = const MessageKind( 2736 MessageKind.UNTERMINATED_COMMENT:
2073 "Comment starting with '/*' must end with '*/'.", 2737 const MessageTemplate(MessageKind.UNTERMINATED_COMMENT,
2074 howToFix: DONT_KNOW_HOW_TO_FIX, 2738 "Comment starting with '/*' must end with '*/'.",
2075 examples: const [r""" 2739 howToFix: DONT_KNOW_HOW_TO_FIX,
2740 examples: const [r"""
2076 main() { 2741 main() {
2077 } 2742 }
2078 /*"""]); 2743 /*"""]),
2079 2744
2080 static const MessageKind MISSING_TOKEN_BEFORE_THIS = const MessageKind( 2745 MessageKind.MISSING_TOKEN_BEFORE_THIS:
2081 "Expected '#{token}' before this.", 2746 const MessageTemplate(MessageKind.MISSING_TOKEN_BEFORE_THIS,
2082 // Consider the second example below: the parser expects a ')' before 2747 "Expected '#{token}' before this.",
2083 // 'y', but a ',' would also have worked. We don't have enough 2748 // Consider the second example below: the parser expects a ')' before
2084 // information to give a good suggestion. 2749 // 'y', but a ',' would also have worked. We don't have enough
2085 howToFix: DONT_KNOW_HOW_TO_FIX, 2750 // information to give a good suggestion.
2086 examples: const [ 2751 howToFix: DONT_KNOW_HOW_TO_FIX,
2087 "main() => true ? 1;", 2752 examples: const [
2088 "main() => foo(x: 1 y: 2);", 2753 "main() => true ? 1;",
2089 ]); 2754 "main() => foo(x: 1 y: 2);",
2755 ]),
2090 2756
2091 static const MessageKind MISSING_TOKEN_AFTER_THIS = const MessageKind( 2757 MessageKind.MISSING_TOKEN_AFTER_THIS:
2092 "Expected '#{token}' after this.", 2758 const MessageTemplate(MessageKind.MISSING_TOKEN_AFTER_THIS,
2093 // See [MISSING_TOKEN_BEFORE_THIS], we don't have enough information to 2759 "Expected '#{token}' after this.",
2094 // give a good suggestion. 2760 // See [MISSING_TOKEN_BEFORE_THIS], we don't have enough information
2095 howToFix: DONT_KNOW_HOW_TO_FIX, 2761 // to give a good suggestion.
2096 examples: const [ 2762 howToFix: DONT_KNOW_HOW_TO_FIX,
2097 "main(x) {x}", 2763 examples: const [
2764 "main(x) {x}",
2098 """ 2765 """
2099 class S1 {} 2766 class S1 {}
2100 class S2 {} 2767 class S2 {}
2101 class S3 {} 2768 class S3 {}
2102 class A = S1 with S2, S3 2769 class A = S1 with S2, S3
2103 main() => new A(); 2770 main() => new A();
2104 """ 2771 """
2105 ]); 2772 ]),
2106 2773
2107 static const MessageKind CONSIDER_ANALYZE_ALL = const MessageKind( 2774 MessageKind.CONSIDER_ANALYZE_ALL:
2108 "Could not find '#{main}'. Nothing will be analyzed.", 2775 const MessageTemplate(MessageKind.CONSIDER_ANALYZE_ALL,
2109 howToFix: "Try using '--analyze-all' to analyze everything.", 2776 "Could not find '#{main}'. Nothing will be analyzed.",
2110 examples: const ['']); 2777 howToFix: "Try using '--analyze-all' to analyze everything.",
2778 examples: const ['']),
2111 2779
2112 static const MessageKind MISSING_MAIN = const MessageKind( 2780 MessageKind.MISSING_MAIN:
2113 "Could not find '#{main}'.", 2781 const MessageTemplate(MessageKind.MISSING_MAIN,
2114 howToFix: "Try adding a method named '#{main}' to your program." 2782 "Could not find '#{main}'.",
2115 /* No example, test uses '--analyze-only' which will produce the above 2783 howToFix: "Try adding a method named '#{main}' to your program."
2116 * message [CONSIDER_ANALYZE_ALL]. An example for a human operator would 2784 /* No example, test uses '--analyze-only' which will produce the above
2117 * be an empty file. */); 2785 * message [CONSIDER_ANALYZE_ALL]. An example for a human operator
2786 * would be an empty file.*/),
2118 2787
2119 static const MessageKind MAIN_NOT_A_FUNCTION = const MessageKind( 2788 MessageKind.MAIN_NOT_A_FUNCTION:
2120 "'#{main}' is not a function.", 2789 const MessageTemplate(MessageKind.MAIN_NOT_A_FUNCTION,
2121 howToFix: DONT_KNOW_HOW_TO_FIX, /* Don't state the obvious. */ 2790 "'#{main}' is not a function.",
2122 examples: const ['var main;']); 2791 howToFix: DONT_KNOW_HOW_TO_FIX, /* Don't state the obvious. */
2792 examples: const ['var main;']),
2123 2793
2124 static const MessageKind MAIN_WITH_EXTRA_PARAMETER = const MessageKind( 2794 MessageKind.MAIN_WITH_EXTRA_PARAMETER:
2125 "'#{main}' cannot have more than two parameters.", 2795 const MessageTemplate(MessageKind.MAIN_WITH_EXTRA_PARAMETER,
2126 howToFix: DONT_KNOW_HOW_TO_FIX, /* Don't state the obvious. */ 2796 "'#{main}' cannot have more than two parameters.",
2127 examples: const ['main(a, b, c) {}']); 2797 howToFix: DONT_KNOW_HOW_TO_FIX, /* Don't state the obvious. */
2798 examples: const ['main(a, b, c) {}']),
2128 2799
2129 static const MessageKind COMPILER_CRASHED = const MessageKind( 2800 MessageKind.COMPILER_CRASHED:
2130 "The compiler crashed when compiling this element."); 2801 const MessageTemplate(MessageKind.COMPILER_CRASHED,
2802 "The compiler crashed when compiling this element."),
2131 2803
2132 static const MessageKind PLEASE_REPORT_THE_CRASH = const MessageKind(''' 2804 MessageKind.PLEASE_REPORT_THE_CRASH:
2805 const MessageTemplate(MessageKind.PLEASE_REPORT_THE_CRASH, '''
2133 The compiler is broken. 2806 The compiler is broken.
2134 2807
2135 When compiling the above element, the compiler crashed. It is not 2808 When compiling the above element, the compiler crashed. It is not
2136 possible to tell if this is caused by a problem in your program or 2809 possible to tell if this is caused by a problem in your program or
2137 not. Regardless, the compiler should not crash. 2810 not. Regardless, the compiler should not crash.
2138 2811
2139 The Dart team would greatly appreciate if you would take a moment to 2812 The Dart team would greatly appreciate if you would take a moment to
2140 report this problem at http://dartbug.com/new. 2813 report this problem at http://dartbug.com/new.
2141 2814
2142 Please include the following information: 2815 Please include the following information:
2143 2816
2144 * the name and version of your operating system, 2817 * the name and version of your operating system,
2145 2818
2146 * the Dart SDK build number (#{buildId}), and 2819 * the Dart SDK build number (#{buildId}), and
2147 2820
2148 * the entire message you see here (including the full stack trace 2821 * the entire message you see here (including the full stack trace
2149 below as well as the source location above). 2822 below as well as the source location above).
2150 '''); 2823 '''),
2151 2824
2152 static const MessageKind POTENTIAL_MUTATION = const MessageKind( 2825 MessageKind.POTENTIAL_MUTATION:
2153 "Variable '#{variableName}' is not known to be of type " 2826 const MessageTemplate(MessageKind.POTENTIAL_MUTATION,
2154 "'#{shownType}' because it is potentially mutated in the scope for " 2827 "Variable '#{variableName}' is not known to be of type "
2155 "promotion."); 2828 "'#{shownType}' because it is potentially mutated in the scope for "
2829 "promotion."),
2156 2830
2157 static const MessageKind POTENTIAL_MUTATION_HERE = const MessageKind( 2831 MessageKind.POTENTIAL_MUTATION_HERE:
2158 "Variable '#{variableName}' is potentially mutated here."); 2832 const MessageTemplate(MessageKind.POTENTIAL_MUTATION_HERE,
2833 "Variable '#{variableName}' is potentially mutated here."),
2159 2834
2160 static const MessageKind POTENTIAL_MUTATION_IN_CLOSURE = const MessageKind( 2835 MessageKind.POTENTIAL_MUTATION_IN_CLOSURE:
2161 "Variable '#{variableName}' is not known to be of type " 2836 const MessageTemplate(MessageKind.POTENTIAL_MUTATION_IN_CLOSURE,
2162 "'#{shownType}' because it is potentially mutated within a closure."); 2837 "Variable '#{variableName}' is not known to be of type "
2838 "'#{shownType}' because it is potentially mutated within a closure."),
2163 2839
2164 static const MessageKind POTENTIAL_MUTATION_IN_CLOSURE_HERE = 2840 MessageKind.POTENTIAL_MUTATION_IN_CLOSURE_HERE:
2165 const MessageKind( 2841 const MessageTemplate(MessageKind.POTENTIAL_MUTATION_IN_CLOSURE_HERE,
2166 "Variable '#{variableName}' is potentially mutated in a " 2842 "Variable '#{variableName}' is potentially mutated in a "
2167 "closure here."); 2843 "closure here."),
2168 2844
2169 static const MessageKind ACCESSED_IN_CLOSURE = const MessageKind( 2845 MessageKind.ACCESSED_IN_CLOSURE:
2170 "Variable '#{variableName}' is not known to be of type " 2846 const MessageTemplate(MessageKind.ACCESSED_IN_CLOSURE,
2171 "'#{shownType}' because it is accessed by a closure in the scope for " 2847 "Variable '#{variableName}' is not known to be of type "
2172 "promotion and potentially mutated in the scope of '#{variableName}'."); 2848 "'#{shownType}' because it is accessed by a closure in the scope for "
2849 "promotion and potentially mutated in the scope of "
2850 "'#{variableName}'."),
2173 2851
2174 static const MessageKind ACCESSED_IN_CLOSURE_HERE = const MessageKind( 2852 MessageKind.ACCESSED_IN_CLOSURE_HERE:
2175 "Variable '#{variableName}' is accessed in a closure here."); 2853 const MessageTemplate(MessageKind.ACCESSED_IN_CLOSURE_HERE,
2854 "Variable '#{variableName}' is accessed in a closure here."),
2176 2855
2177 static const MessageKind NOT_MORE_SPECIFIC = const MessageKind( 2856 MessageKind.NOT_MORE_SPECIFIC:
2178 "Variable '#{variableName}' is not shown to have type " 2857 const MessageTemplate(MessageKind.NOT_MORE_SPECIFIC,
2179 "'#{shownType}' because '#{shownType}' is not more specific than the " 2858 "Variable '#{variableName}' is not shown to have type "
2180 "known type '#{knownType}' of '#{variableName}'."); 2859 "'#{shownType}' because '#{shownType}' is not more specific than the "
2860 "known type '#{knownType}' of '#{variableName}'."),
2181 2861
2182 static const MessageKind NOT_MORE_SPECIFIC_SUBTYPE = const MessageKind( 2862 MessageKind.NOT_MORE_SPECIFIC_SUBTYPE:
2183 "Variable '#{variableName}' is not shown to have type " 2863 const MessageTemplate(MessageKind.NOT_MORE_SPECIFIC_SUBTYPE,
2184 "'#{shownType}' because '#{shownType}' is not a subtype of the " 2864 "Variable '#{variableName}' is not shown to have type "
2185 "known type '#{knownType}' of '#{variableName}'."); 2865 "'#{shownType}' because '#{shownType}' is not a subtype of the "
2866 "known type '#{knownType}' of '#{variableName}'."),
2186 2867
2187 static const MessageKind NOT_MORE_SPECIFIC_SUGGESTION = const MessageKind( 2868 MessageKind.NOT_MORE_SPECIFIC_SUGGESTION:
2188 "Variable '#{variableName}' is not shown to have type " 2869 const MessageTemplate(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
2189 "'#{shownType}' because '#{shownType}' is not more specific than the " 2870 "Variable '#{variableName}' is not shown to have type "
2190 "known type '#{knownType}' of '#{variableName}'.", 2871 "'#{shownType}' because '#{shownType}' is not more specific than the "
2191 howToFix: "Try replacing '#{shownType}' with '#{shownTypeSuggestion}'."); 2872 "known type '#{knownType}' of '#{variableName}'.",
2873 howToFix:
2874 "Try replacing '#{shownType}' with '#{shownTypeSuggestion}'."),
2192 2875
2193 static const MessageKind HIDDEN_WARNINGS_HINTS = const MessageKind( 2876 MessageKind.HIDDEN_WARNINGS_HINTS:
2194 "#{warnings} warning(s) and #{hints} hint(s) suppressed in #{uri}."); 2877 const MessageTemplate(MessageKind.HIDDEN_WARNINGS_HINTS,
2878 "#{warnings} warning(s) and #{hints} hint(s) suppressed in #{uri}."),
2195 2879
2196 static const MessageKind HIDDEN_WARNINGS = const MessageKind( 2880 MessageKind.HIDDEN_WARNINGS:
2197 "#{warnings} warning(s) suppressed in #{uri}."); 2881 const MessageTemplate(MessageKind.HIDDEN_WARNINGS,
2882 "#{warnings} warning(s) suppressed in #{uri}."),
2198 2883
2199 static const MessageKind HIDDEN_HINTS = const MessageKind( 2884 MessageKind.HIDDEN_HINTS:
2200 "#{hints} hint(s) suppressed in #{uri}."); 2885 const MessageTemplate(MessageKind.HIDDEN_HINTS,
2886 "#{hints} hint(s) suppressed in #{uri}."),
2201 2887
2202 static const MessageKind PREAMBLE = const MessageKind( 2888 MessageKind.PREAMBLE:
2203 "When run on the command-line, the compiled output might" 2889 const MessageTemplate(MessageKind.PREAMBLE,
2204 " require a preamble file located in:\n" 2890 "When run on the command-line, the compiled output might"
2205 " <sdk>/lib/_internal/js_runtime/lib/preambles."); 2891 " require a preamble file located in:\n"
2892 " <sdk>/lib/_internal/js_runtime/lib/preambles."),
2206 2893
2207 static const MessageKind INVALID_SYNC_MODIFIER = const MessageKind( 2894 MessageKind.INVALID_SYNC_MODIFIER:
2208 "Invalid modifier 'sync'.", 2895 const MessageTemplate(MessageKind.INVALID_SYNC_MODIFIER,
2209 options: const ['--enable-async'], 2896 "Invalid modifier 'sync'.",
2210 howToFix: "Try replacing 'sync' with 'sync*'.", 2897 options: const ['--enable-async'],
2211 examples: const [ 2898 howToFix: "Try replacing 'sync' with 'sync*'.",
2212 "main() sync {}" 2899 examples: const [
2213 ]); 2900 "main() sync {}"
2901 ]),
2214 2902
2215 static const MessageKind INVALID_AWAIT_FOR = const MessageKind( 2903 MessageKind.INVALID_AWAIT_FOR:
2216 "'await' is only supported on for-in loops.", 2904 const MessageTemplate(MessageKind.INVALID_AWAIT_FOR,
2217 options: const ['--enable-async'], 2905 "'await' is only supported on for-in loops.",
2218 howToFix: "Try rewriting the loop as a for-in loop or removing the " 2906 options: const ['--enable-async'],
2219 "'await' keyword.", 2907 howToFix: "Try rewriting the loop as a for-in loop or removing the "
2220 examples: const [""" 2908 "'await' keyword.",
2909 examples: const ["""
2221 main() async* { 2910 main() async* {
2222 await for (int i = 0; i < 10; i++) {} 2911 await for (int i = 0; i < 10; i++) {}
2223 } 2912 }
2224 """]); 2913 """]),
2225 2914
2226 static const MessageKind ASYNC_MODIFIER_ON_ABSTRACT_METHOD = 2915 MessageKind.ASYNC_MODIFIER_ON_ABSTRACT_METHOD:
2227 const MessageKind( 2916 const MessageTemplate(MessageKind.ASYNC_MODIFIER_ON_ABSTRACT_METHOD,
2228 "The modifier '#{modifier}' is not allowed on an abstract method.", 2917 "The modifier '#{modifier}' is not allowed on an abstract method.",
2229 options: const ['--enable-async'], 2918 options: const ['--enable-async'],
2230 howToFix: "Try removing the '#{modifier}' modifier or adding a " 2919 howToFix: "Try removing the '#{modifier}' modifier or adding a "
2231 "body to the method.", 2920 "body to the method.",
2232 examples: const [""" 2921 examples: const ["""
2233 abstract class A { 2922 abstract class A {
2234 method() async; 2923 method() async;
2235 } 2924 }
2236 class B extends A { 2925 class B extends A {
2237 method() {} 2926 method() {}
2238 } 2927 }
2239 main() { 2928 main() {
2240 A a = new B(); 2929 A a = new B();
2241 a.method(); 2930 a.method();
2242 } 2931 }
2243 """]); 2932 """]),
2244 2933
2245 static const MessageKind ASYNC_MODIFIER_ON_CONSTRUCTOR = 2934 MessageKind.ASYNC_MODIFIER_ON_CONSTRUCTOR:
2246 const MessageKind( 2935 const MessageTemplate(MessageKind.ASYNC_MODIFIER_ON_CONSTRUCTOR,
2247 "The modifier '#{modifier}' is not allowed on constructors.", 2936 "The modifier '#{modifier}' is not allowed on constructors.",
2248 options: const ['--enable-async'], 2937 options: const ['--enable-async'],
2249 howToFix: "Try removing the '#{modifier}' modifier.", 2938 howToFix: "Try removing the '#{modifier}' modifier.",
2250 examples: const [""" 2939 examples: const ["""
2251 class A { 2940 class A {
2252 A() async; 2941 A() async;
2253 } 2942 }
2254 main() => new A();""", 2943 main() => new A();""",
2255 2944
2256 """ 2945 """
2257 class A { 2946 class A {
2258 A(); 2947 A();
2259 factory A.a() async* {} 2948 factory A.a() async* {}
2260 } 2949 }
2261 main() => new A.a();"""]); 2950 main() => new A.a();"""]),
2262 2951
2263 static const MessageKind ASYNC_MODIFIER_ON_SETTER = 2952 MessageKind.ASYNC_MODIFIER_ON_SETTER:
2264 const MessageKind( 2953 const MessageTemplate(MessageKind.ASYNC_MODIFIER_ON_SETTER,
2265 "The modifier '#{modifier}' is not allowed on setters.", 2954 "The modifier '#{modifier}' is not allowed on setters.",
2266 options: const ['--enable-async'], 2955 options: const ['--enable-async'],
2267 howToFix: "Try removing the '#{modifier}' modifier.", 2956 howToFix: "Try removing the '#{modifier}' modifier.",
2268 examples: const [""" 2957 examples: const ["""
2269 class A { 2958 class A {
2270 set foo(v) async {} 2959 set foo(v) async {}
2271 } 2960 }
2272 main() => new A().foo = 0;"""]); 2961 main() => new A().foo = 0;"""]),
2273 2962
2274 static const MessageKind YIELDING_MODIFIER_ON_ARROW_BODY = 2963 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY:
2275 const MessageKind( 2964 const MessageTemplate(MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY,
2276 "The modifier '#{modifier}' is not allowed on methods implemented " 2965 "The modifier '#{modifier}' is not allowed on methods implemented "
2277 "using '=>'.", 2966 "using '=>'.",
2278 options: const ['--enable-async'], 2967 options: const ['--enable-async'],
2279 howToFix: "Try removing the '#{modifier}' modifier or implementing " 2968 howToFix: "Try removing the '#{modifier}' modifier or implementing "
2280 "the method body using a block: '{ ... }'.", 2969 "the method body using a block: '{ ... }'.",
2281 examples: const ["main() sync* => null;", "main() async* => null;"]); 2970 examples: const ["main() sync* => null;", "main() async* => null;"]),
2282 2971
2283 // TODO(johnniwinther): Check for 'async' as identifier. 2972 // TODO(johnniwinther): Check for 'async' as identifier.
2284 static const MessageKind ASYNC_KEYWORD_AS_IDENTIFIER = const MessageKind( 2973 MessageKind.ASYNC_KEYWORD_AS_IDENTIFIER:
2285 "'#{keyword}' cannot be used as an identifier in a function body marked " 2974 const MessageTemplate(MessageKind.ASYNC_KEYWORD_AS_IDENTIFIER,
2286 "with '#{modifier}'.", 2975 "'#{keyword}' cannot be used as an identifier in a function body "
2287 options: const ['--enable-async'], 2976 "marked with '#{modifier}'.",
2288 howToFix: "Try removing the '#{modifier}' modifier or renaming the " 2977 options: const ['--enable-async'],
2289 "identifier.", 2978 howToFix: "Try removing the '#{modifier}' modifier or renaming the "
2290 examples: const [""" 2979 "identifier.",
2980 examples: const ["""
2291 main() async { 2981 main() async {
2292 var await; 2982 var await;
2293 }""", 2983 }""",
2294 """ 2984 """
2295 main() async* { 2985 main() async* {
2296 var yield; 2986 var yield;
2297 }""", 2987 }""",
2298 """ 2988 """
2299 main() sync* { 2989 main() sync* {
2300 var yield; 2990 var yield;
2301 }"""]); 2991 }"""]),
2302 2992
2303 static const MessageKind RETURN_IN_GENERATOR = 2993 MessageKind.RETURN_IN_GENERATOR:
2304 const MessageKind( 2994 const MessageTemplate(MessageKind.RETURN_IN_GENERATOR,
2305 "'return' with a value is not allowed in a method body using the " 2995 "'return' with a value is not allowed in a method body using the "
2306 "'#{modifier}' modifier.", 2996 "'#{modifier}' modifier.",
2307 howToFix: "Try removing the value, replacing 'return' with 'yield' " 2997 howToFix: "Try removing the value, replacing 'return' with 'yield' "
2308 "or changing the method body modifier.", 2998 "or changing the method body modifier.",
2309 examples: const [ 2999 examples: const [
2310 """ 3000 """
2311 foo() async* { return 0; } 3001 foo() async* { return 0; }
2312 main() => foo(); 3002 main() => foo();
2313 """, 3003 """,
2314 3004
2315 """ 3005 """
2316 foo() sync* { return 0; } 3006 foo() sync* { return 0; }
2317 main() => foo(); 3007 main() => foo();
2318 """]); 3008 """]),
2319 3009
2320 static const MessageKind NATIVE_NOT_SUPPORTED = const MessageKind( 3010 MessageKind.NATIVE_NOT_SUPPORTED:
2321 "'native' modifier is not supported.", 3011 const MessageTemplate(MessageKind.NATIVE_NOT_SUPPORTED,
2322 howToFix: "Try removing the 'native' implementation or analyzing the " 3012 "'native' modifier is not supported.",
2323 "code with the --allow-native-extensions option.", 3013 howToFix: "Try removing the 'native' implementation or analyzing the "
2324 examples: const [""" 3014 "code with the --allow-native-extensions option.",
3015 examples: const ["""
2325 main() native "Main"; 3016 main() native "Main";
2326 """]); 3017 """]),
2327 3018
2328 static const MessageKind DART_EXT_NOT_SUPPORTED = const MessageKind( 3019 MessageKind.DART_EXT_NOT_SUPPORTED:
2329 "The 'dart-ext' scheme is not supported.", 3020 const MessageTemplate(MessageKind.DART_EXT_NOT_SUPPORTED,
2330 howToFix: "Try analyzing the code with the --allow-native-extensions " 3021 "The 'dart-ext' scheme is not supported.",
2331 "option.", 3022 howToFix: "Try analyzing the code with the --allow-native-extensions "
2332 examples: const [""" 3023 "option.",
3024 examples: const ["""
2333 import 'dart-ext:main'; 3025 import 'dart-ext:main';
2334 3026
2335 main() {} 3027 main() {}
2336 """]); 3028 """]),
2337 3029
2338 static const MessageKind LIBRARY_TAG_MUST_BE_FIRST = const MessageKind( 3030 MessageKind.LIBRARY_TAG_MUST_BE_FIRST:
2339 "The library declaration should come before other declarations.", 3031 const MessageTemplate(MessageKind.LIBRARY_TAG_MUST_BE_FIRST,
2340 howToFix: "Try moving the declaration to the top of the file.", 3032 "The library declaration should come before other declarations.",
2341 examples: const [ 3033 howToFix: "Try moving the declaration to the top of the file.",
3034 examples: const [
2342 """ 3035 """
2343 import 'dart:core'; 3036 import 'dart:core';
2344 library foo; 3037 library foo;
2345 main() {} 3038 main() {}
2346 """, 3039 """,
2347 ]); 3040 ]),
2348 3041
2349 static const MessageKind ONLY_ONE_LIBRARY_TAG = const MessageKind( 3042 MessageKind.ONLY_ONE_LIBRARY_TAG:
2350 "There can only be one library declaration.", 3043 const MessageTemplate(MessageKind.ONLY_ONE_LIBRARY_TAG,
2351 howToFix: "Try removing all other library declarations.", 3044 "There can only be one library declaration.",
2352 examples: const [ 3045 howToFix: "Try removing all other library declarations.",
3046 examples: const [
2353 """ 3047 """
2354 library foo; 3048 library foo;
2355 library bar; 3049 library bar;
2356 main() {} 3050 main() {}
2357 """, 3051 """,
2358 """ 3052 """
2359 library foo; 3053 library foo;
2360 import 'dart:core'; 3054 import 'dart:core';
2361 library bar; 3055 library bar;
2362 main() {} 3056 main() {}
2363 """, 3057 """,
2364 ]); 3058 ]),
2365 3059
2366 static const MessageKind IMPORT_BEFORE_PARTS = const MessageKind( 3060 MessageKind.IMPORT_BEFORE_PARTS:
2367 "Import declarations should come before parts.", 3061 const MessageTemplate(MessageKind.IMPORT_BEFORE_PARTS,
2368 howToFix: "Try moving this import further up in the file.", 3062 "Import declarations should come before parts.",
2369 examples: const [ 3063 howToFix: "Try moving this import further up in the file.",
2370 const <String, String>{ 3064 examples: const [
2371 'main.dart': """ 3065 const <String, String>{
3066 'main.dart': """
2372 library test.main; 3067 library test.main;
2373 part 'part.dart'; 3068 part 'part.dart';
2374 import 'dart:core'; 3069 import 'dart:core';
2375 main() {} 3070 main() {}
2376 """, 3071 """,
2377 'part.dart': """ 3072 'part.dart': """
2378 part of test.main; 3073 part of test.main;
2379 """, 3074 """,
2380 }]); 3075 }]),
2381 3076
2382 static const MessageKind EXPORT_BEFORE_PARTS = const MessageKind( 3077 MessageKind.EXPORT_BEFORE_PARTS:
2383 "Export declarations should come before parts.", 3078 const MessageTemplate(MessageKind.EXPORT_BEFORE_PARTS,
2384 howToFix: "Try moving this export further up in the file.", 3079 "Export declarations should come before parts.",
2385 examples: const [ 3080 howToFix: "Try moving this export further up in the file.",
2386 const <String, String>{ 3081 examples: const [
2387 'main.dart': """ 3082 const <String, String>{
3083 'main.dart': """
2388 library test.main; 3084 library test.main;
2389 part 'part.dart'; 3085 part 'part.dart';
2390 export 'dart:core'; 3086 export 'dart:core';
2391 main() {} 3087 main() {}
2392 """, 3088 """,
2393 'part.dart': """ 3089 'part.dart': """
2394 part of test.main; 3090 part of test.main;
2395 """, 3091 """,
2396 }]); 3092 }]),
2397 3093
2398 ////////////////////////////////////////////////////////////////////////////// 3094 //////////////////////////////////////////////////////////////////////////////
2399 // Patch errors start. 3095 // Patch errors start.
2400 ////////////////////////////////////////////////////////////////////////////// 3096 //////////////////////////////////////////////////////////////////////////////
2401 3097
2402 static const MessageKind PATCH_RETURN_TYPE_MISMATCH = const MessageKind( 3098 MessageKind.PATCH_RETURN_TYPE_MISMATCH:
2403 "Patch return type '#{patchReturnType}' does not match " 3099 const MessageTemplate(MessageKind.PATCH_RETURN_TYPE_MISMATCH,
2404 "'#{originReturnType}' on origin method '#{methodName}'."); 3100 "Patch return type '#{patchReturnType}' does not match "
3101 "'#{originReturnType}' on origin method '#{methodName}'."),
2405 3102
2406 static const MessageKind PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH = 3103 MessageKind.PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH:
2407 const MessageKind( 3104 const MessageTemplate(
3105 MessageKind.PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH,
2408 "Required parameter count of patch method " 3106 "Required parameter count of patch method "
2409 "(#{patchParameterCount}) does not match parameter count on origin " 3107 "(#{patchParameterCount}) does not match parameter count on origin "
2410 "method '#{methodName}' (#{originParameterCount})."); 3108 "method '#{methodName}' (#{originParameterCount})."),
2411 3109
2412 static const MessageKind PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH = 3110 MessageKind.PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH:
2413 const MessageKind( 3111 const MessageTemplate(
3112 MessageKind.PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH,
2414 "Optional parameter count of patch method " 3113 "Optional parameter count of patch method "
2415 "(#{patchParameterCount}) does not match parameter count on origin " 3114 "(#{patchParameterCount}) does not match parameter count on origin "
2416 "method '#{methodName}' (#{originParameterCount})."); 3115 "method '#{methodName}' (#{originParameterCount})."),
2417 3116
2418 static const MessageKind PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH = 3117 MessageKind.PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH:
2419 const MessageKind( 3118 const MessageTemplate(
3119 MessageKind.PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH,
2420 "Optional parameters of origin and patch method " 3120 "Optional parameters of origin and patch method "
2421 "'#{methodName}' must both be either named or positional."); 3121 "'#{methodName}' must both be either named or positional."),
2422 3122
2423 static const MessageKind PATCH_PARAMETER_MISMATCH = const MessageKind( 3123 MessageKind.PATCH_PARAMETER_MISMATCH:
2424 "Patch method parameter '#{patchParameter}' does not match " 3124 const MessageTemplate(MessageKind.PATCH_PARAMETER_MISMATCH,
2425 "'#{originParameter}' on origin method '#{methodName}'."); 3125 "Patch method parameter '#{patchParameter}' does not match "
3126 "'#{originParameter}' on origin method '#{methodName}'."),
2426 3127
2427 static const MessageKind PATCH_PARAMETER_TYPE_MISMATCH = const MessageKind( 3128 MessageKind.PATCH_PARAMETER_TYPE_MISMATCH:
2428 "Patch method parameter '#{parameterName}' type " 3129 const MessageTemplate(MessageKind.PATCH_PARAMETER_TYPE_MISMATCH,
2429 "'#{patchParameterType}' does not match '#{originParameterType}' on " 3130 "Patch method parameter '#{parameterName}' type "
2430 "origin method '#{methodName}'."); 3131 "'#{patchParameterType}' does not match '#{originParameterType}' on "
3132 "origin method '#{methodName}'."),
2431 3133
2432 static const MessageKind PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION = 3134 MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION:
2433 const MessageKind("External method without an implementation."); 3135 const MessageTemplate(MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION,
3136 "External method without an implementation."),
2434 3137
2435 static const MessageKind PATCH_POINT_TO_FUNCTION = const MessageKind( 3138 MessageKind.PATCH_POINT_TO_FUNCTION:
2436 "This is the function patch '#{functionName}'."); 3139 const MessageTemplate(MessageKind.PATCH_POINT_TO_FUNCTION,
3140 "This is the function patch '#{functionName}'."),
2437 3141
2438 static const MessageKind PATCH_POINT_TO_CLASS = const MessageKind( 3142 MessageKind.PATCH_POINT_TO_CLASS:
2439 "This is the class patch '#{className}'."); 3143 const MessageTemplate(MessageKind.PATCH_POINT_TO_CLASS,
3144 "This is the class patch '#{className}'."),
2440 3145
2441 static const MessageKind PATCH_POINT_TO_GETTER = const MessageKind( 3146 MessageKind.PATCH_POINT_TO_GETTER:
2442 "This is the getter patch '#{getterName}'."); 3147 const MessageTemplate(MessageKind.PATCH_POINT_TO_GETTER,
3148 "This is the getter patch '#{getterName}'."),
2443 3149
2444 static const MessageKind PATCH_POINT_TO_SETTER = const MessageKind( 3150 MessageKind.PATCH_POINT_TO_SETTER:
2445 "This is the setter patch '#{setterName}'."); 3151 const MessageTemplate(MessageKind.PATCH_POINT_TO_SETTER,
3152 "This is the setter patch '#{setterName}'."),
2446 3153
2447 static const MessageKind PATCH_POINT_TO_CONSTRUCTOR = const MessageKind( 3154 MessageKind.PATCH_POINT_TO_CONSTRUCTOR:
2448 "This is the constructor patch '#{constructorName}'."); 3155 const MessageTemplate(MessageKind.PATCH_POINT_TO_CONSTRUCTOR,
3156 "This is the constructor patch '#{constructorName}'."),
2449 3157
2450 static const MessageKind PATCH_POINT_TO_PARAMETER = const MessageKind( 3158 MessageKind.PATCH_POINT_TO_PARAMETER:
2451 "This is the patch parameter '#{parameterName}'."); 3159 const MessageTemplate(MessageKind.PATCH_POINT_TO_PARAMETER,
3160 "This is the patch parameter '#{parameterName}'."),
2452 3161
2453 static const MessageKind PATCH_NON_EXISTING = const MessageKind( 3162 MessageKind.PATCH_NON_EXISTING:
2454 "Origin does not exist for patch '#{name}'."); 3163 const MessageTemplate(MessageKind.PATCH_NON_EXISTING,
3164 "Origin does not exist for patch '#{name}'."),
2455 3165
2456 // TODO(ahe): Eventually, this error should be removed as it will be handled 3166 // TODO(ahe): Eventually, this error should be removed as it will be
2457 // by the regular parser. 3167 // handled by the regular parser.
2458 static const MessageKind PATCH_NONPATCHABLE = const MessageKind( 3168 MessageKind.PATCH_NONPATCHABLE:
2459 "Only classes and functions can be patched."); 3169 const MessageTemplate(MessageKind.PATCH_NONPATCHABLE,
3170 "Only classes and functions can be patched."),
2460 3171
2461 static const MessageKind PATCH_NON_EXTERNAL = const MessageKind( 3172 MessageKind.PATCH_NON_EXTERNAL:
2462 "Only external functions can be patched."); 3173 const MessageTemplate(MessageKind.PATCH_NON_EXTERNAL,
3174 "Only external functions can be patched."),
2463 3175
2464 static const MessageKind PATCH_NON_CLASS = const MessageKind( 3176 MessageKind.PATCH_NON_CLASS:
2465 "Patching non-class with class patch '#{className}'."); 3177 const MessageTemplate(MessageKind.PATCH_NON_CLASS,
3178 "Patching non-class with class patch '#{className}'."),
2466 3179
2467 static const MessageKind PATCH_NON_GETTER = const MessageKind( 3180 MessageKind.PATCH_NON_GETTER:
2468 "Cannot patch non-getter '#{name}' with getter patch."); 3181 const MessageTemplate(MessageKind.PATCH_NON_GETTER,
3182 "Cannot patch non-getter '#{name}' with getter patch."),
2469 3183
2470 static const MessageKind PATCH_NO_GETTER = const MessageKind( 3184 MessageKind.PATCH_NO_GETTER:
2471 "No getter found for getter patch '#{getterName}'."); 3185 const MessageTemplate(MessageKind.PATCH_NO_GETTER,
3186 "No getter found for getter patch '#{getterName}'."),
2472 3187
2473 static const MessageKind PATCH_NON_SETTER = const MessageKind( 3188 MessageKind.PATCH_NON_SETTER:
2474 "Cannot patch non-setter '#{name}' with setter patch."); 3189 const MessageTemplate(MessageKind.PATCH_NON_SETTER,
3190 "Cannot patch non-setter '#{name}' with setter patch."),
2475 3191
2476 static const MessageKind PATCH_NO_SETTER = const MessageKind( 3192 MessageKind.PATCH_NO_SETTER:
2477 "No setter found for setter patch '#{setterName}'."); 3193 const MessageTemplate(MessageKind.PATCH_NO_SETTER,
3194 "No setter found for setter patch '#{setterName}'."),
2478 3195
2479 static const MessageKind PATCH_NON_CONSTRUCTOR = const MessageKind( 3196 MessageKind.PATCH_NON_CONSTRUCTOR:
2480 "Cannot patch non-constructor with constructor patch " 3197 const MessageTemplate(MessageKind.PATCH_NON_CONSTRUCTOR,
2481 "'#{constructorName}'."); 3198 "Cannot patch non-constructor with constructor patch "
3199 "'#{constructorName}'."),
2482 3200
2483 static const MessageKind PATCH_NON_FUNCTION = const MessageKind( 3201 MessageKind.PATCH_NON_FUNCTION:
2484 "Cannot patch non-function with function patch " 3202 const MessageTemplate(MessageKind.PATCH_NON_FUNCTION,
2485 "'#{functionName}'."); 3203 "Cannot patch non-function with function patch "
3204 "'#{functionName}'."),
2486 3205
2487 static const MessageKind EXTERNAL_WITH_BODY = const MessageKind( 3206 MessageKind.EXTERNAL_WITH_BODY:
2488 "External function '#{functionName}' cannot have a function body.", 3207 const MessageTemplate(MessageKind.EXTERNAL_WITH_BODY,
2489 options: const ["--output-type=dart"], 3208 "External function '#{functionName}' cannot have a function body.",
2490 howToFix: "Try removing the 'external' modifier or the function body.", 3209 options: const ["--output-type=dart"],
2491 examples: const [""" 3210 howToFix:
3211 "Try removing the 'external' modifier or the function body.",
3212 examples: const ["""
2492 external foo() => 0; 3213 external foo() => 0;
2493 main() => foo(); 3214 main() => foo();
2494 """, """ 3215 """, """
2495 external foo() {} 3216 external foo() {}
2496 main() => foo(); 3217 main() => foo();
2497 """]); 3218 """]),
2498 3219
2499 ////////////////////////////////////////////////////////////////////////////// 3220 //////////////////////////////////////////////////////////////////////////////
2500 // Patch errors end. 3221 // Patch errors end.
2501 ////////////////////////////////////////////////////////////////////////////// 3222 //////////////////////////////////////////////////////////////////////////////
2502 3223
2503 static const String IMPORT_EXPERIMENTAL_MIRRORS_PADDING = '\n* '; 3224 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS:
2504 3225 const MessageTemplate(MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, r'''
2505 static const MessageKind IMPORT_EXPERIMENTAL_MIRRORS =
2506 const MessageKind(r'''
2507 3226
2508 **************************************************************** 3227 ****************************************************************
2509 * WARNING: dart:mirrors support in dart2js is experimental, 3228 * WARNING: dart:mirrors support in dart2js is experimental,
2510 * and not recommended. 3229 * and not recommended.
2511 * This implementation of mirrors is incomplete, 3230 * This implementation of mirrors is incomplete,
2512 * and often greatly increases the size of the generated 3231 * and often greatly increases the size of the generated
2513 * JavaScript code. 3232 * JavaScript code.
2514 * 3233 *
2515 * Your app imports dart:mirrors via:'''''' 3234 * Your app imports dart:mirrors via:''''''
2516 $IMPORT_EXPERIMENTAL_MIRRORS_PADDING#{importChain} 3235 $IMPORT_EXPERIMENTAL_MIRRORS_PADDING#{importChain}
2517 * 3236 *
2518 * You can disable this message by using the --enable-experimental-mirrors 3237 * You can disable this message by using the --enable-experimental-mirrors
2519 * command-line flag. 3238 * command-line flag.
2520 * 3239 *
2521 * To learn what to do next, please visit: 3240 * To learn what to do next, please visit:
2522 * http://dartlang.org/dart2js-reflection 3241 * http://dartlang.org/dart2js-reflection
2523 **************************************************************** 3242 ****************************************************************
2524 '''); 3243 '''),
2525 3244
2526 3245
2527 static const MessageKind MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND = 3246 MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND:
2528 const MessageKind( 3247 const MessageTemplate(
2529 "dart:mirrors library is not supported when using this backend."); 3248 MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND,
3249 "dart:mirrors library is not supported when using this backend."),
2530 3250
2531 static const MessageKind CALL_NOT_SUPPORTED_ON_NATIVE_CLASS = 3251 MessageKind.CALL_NOT_SUPPORTED_ON_NATIVE_CLASS:
2532 const MessageKind( 3252 const MessageTemplate(MessageKind.CALL_NOT_SUPPORTED_ON_NATIVE_CLASS,
2533 "Non-supported 'call' member on a native class, or a " 3253 "Non-supported 'call' member on a native class, or a "
2534 "subclass of a native class."); 3254 "subclass of a native class."),
2535 3255
2536 static const MessageKind DIRECTLY_THROWING_NSM = 3256 MessageKind.DIRECTLY_THROWING_NSM:
2537 const MessageKind( 3257 const MessageTemplate(MessageKind.DIRECTLY_THROWING_NSM,
2538 "This 'noSuchMethod' implementation is guaranteed to throw an " 3258 "This 'noSuchMethod' implementation is guaranteed to throw an "
2539 "exception. The generated code will be smaller if it is " 3259 "exception. The generated code will be smaller if it is "
2540 "rewritten.", 3260 "rewritten.",
2541 howToFix: "Rewrite to " 3261 howToFix: "Rewrite to "
2542 "'noSuchMethod(Invocation i) => super.noSuchMethod(i);'."); 3262 "'noSuchMethod(Invocation i) => super.noSuchMethod(i);'."),
2543 3263
2544 static const MessageKind COMPLEX_THROWING_NSM = 3264 MessageKind.COMPLEX_THROWING_NSM:
2545 const MessageKind( 3265 const MessageTemplate(MessageKind.COMPLEX_THROWING_NSM,
2546 "This 'noSuchMethod' implementation is guaranteed to throw an " 3266 "This 'noSuchMethod' implementation is guaranteed to throw an "
2547 "exception. The generated code will be smaller and the compiler " 3267 "exception. The generated code will be smaller and the compiler "
2548 "will be able to perform more optimizations if it is rewritten.", 3268 "will be able to perform more optimizations if it is rewritten.",
2549 howToFix: "Rewrite to " 3269 howToFix: "Rewrite to "
2550 "'noSuchMethod(Invocation i) => super.noSuchMethod(i);'."); 3270 "'noSuchMethod(Invocation i) => super.noSuchMethod(i);'."),
2551 3271
2552 static const MessageKind COMPLEX_RETURNING_NSM = 3272 MessageKind.COMPLEX_RETURNING_NSM:
2553 const MessageKind( 3273 const MessageTemplate(MessageKind.COMPLEX_RETURNING_NSM,
2554 "Overriding 'noSuchMethod' causes the compiler to generate " 3274 "Overriding 'noSuchMethod' causes the compiler to generate "
2555 "more code and prevents the compiler from doing some optimizations.", 3275 "more code and prevents the compiler from doing some optimizations.",
2556 howToFix: "Consider removing this 'noSuchMethod' implementation."); 3276 howToFix: "Consider removing this 'noSuchMethod' implementation."),
3277
3278
3279 }; // End of TEMPLATES.
3280
3281 static const String IMPORT_EXPERIMENTAL_MIRRORS_PADDING = '\n* ';
2557 3282
2558 toString() => template; 3283 toString() => template;
2559 3284
2560 Message message([Map arguments = const {}, bool terse = false]) { 3285 Message message([Map arguments = const {}, bool terse = false]) {
2561 return new Message(this, arguments, terse); 3286 return new Message(this, arguments, terse);
2562 } 3287 }
2563 3288
2564 bool get hasHowToFix => howToFix != null && howToFix != DONT_KNOW_HOW_TO_FIX; 3289 bool get hasHowToFix => howToFix != null && howToFix != DONT_KNOW_HOW_TO_FIX;
2565 } 3290 }
2566 3291
2567 class Message { 3292 class Message {
2568 final MessageKind kind; 3293 final MessageTemplate template;
2569 final Map arguments; 3294 final Map arguments;
2570 final bool terse; 3295 final bool terse;
2571 String message; 3296 String message;
2572 3297
2573 Message(this.kind, this.arguments, this.terse) { 3298 Message(this.template, this.arguments, this.terse) {
2574 assert(() { computeMessage(); return true; }); 3299 assert(() { computeMessage(); return true; });
2575 } 3300 }
2576 3301
3302 MessageKind get kind => template.kind;
3303
2577 String computeMessage() { 3304 String computeMessage() {
2578 if (message == null) { 3305 if (message == null) {
2579 message = kind.template; 3306 message = template.template;
2580 arguments.forEach((key, value) { 3307 arguments.forEach((key, value) {
2581 message = message.replaceAll('#{${key}}', convertToString(value)); 3308 message = message.replaceAll('#{${key}}', convertToString(value));
2582 }); 3309 });
2583 assert(invariant( 3310 assert(invariant(
2584 CURRENT_ELEMENT_SPANNABLE, 3311 CURRENT_ELEMENT_SPANNABLE,
2585 kind == MessageKind.GENERIC || 3312 kind == MessageKind.GENERIC ||
2586 !message.contains(new RegExp(r'#\{.+\}')), 3313 !message.contains(new RegExp(r'#\{.+\}')),
2587 message: 'Missing arguments in error message: "$message"')); 3314 message: 'Missing arguments in error message: "$message"'));
2588 if (!terse && kind.hasHowToFix) { 3315 if (!terse && template.hasHowToFix) {
2589 String howToFix = kind.howToFix; 3316 String howToFix = template.howToFix;
2590 arguments.forEach((key, value) { 3317 arguments.forEach((key, value) {
2591 howToFix = howToFix.replaceAll('#{${key}}', convertToString(value)); 3318 howToFix = howToFix.replaceAll('#{${key}}', convertToString(value));
2592 }); 3319 });
2593 message = '$message\n$howToFix'; 3320 message = '$message\n$howToFix';
2594 } 3321 }
2595 } 3322 }
2596 return message; 3323 return message;
2597 } 3324 }
2598 3325
2599 String toString() { 3326 String toString() {
2600 return computeMessage(); 3327 return computeMessage();
2601 } 3328 }
2602 3329
2603 bool operator==(other) { 3330 bool operator==(other) {
2604 if (other is !Message) return false; 3331 if (other is !Message) return false;
2605 return (kind == other.kind) && (toString() == other.toString()); 3332 return (template == other.template) && (toString() == other.toString());
2606 } 3333 }
2607 3334
2608 int get hashCode => throw new UnsupportedError('Message.hashCode'); 3335 int get hashCode => throw new UnsupportedError('Message.hashCode');
2609 3336
2610 static String convertToString(value) { 3337 static String convertToString(value) {
2611 if (value is ErrorToken) { 3338 if (value is ErrorToken) {
2612 // Shouldn't happen. 3339 // Shouldn't happen.
2613 return value.assertionMessage; 3340 return value.assertionMessage;
2614 } else if (value is Token) { 3341 } else if (value is Token) {
2615 value = value.value; 3342 value = value.value;
2616 } 3343 }
2617 return '$value'; 3344 return '$value';
2618 } 3345 }
2619 } 3346 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | tests/compiler/dart2js/analyze_only_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698