OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 part of dart2js; | |
6 | |
7 const DONT_KNOW_HOW_TO_FIX = ""; | |
8 | |
9 /** | |
10 * The messages in this file should meet the following guide lines: | |
11 * | |
12 * 1. The message should be a complete sentence starting with an uppercase | |
13 * letter, and ending with a period. | |
14 * | |
15 * 2. Reserved words and embedded identifiers should be in single quotes, so | |
16 * prefer double quotes for the complete message. For example, "The | |
17 * class '#{className}' can't use 'super'." Notice that the word 'class' in the | |
18 * preceding message is not quoted as it refers to the concept 'class', not the | |
19 * reserved word. On the other hand, 'super' refers to the reserved word. Do | |
20 * not quote 'null' and numeric literals. | |
21 * | |
22 * 3. Do not try to compose messages, as it can make translating them hard. | |
23 * | |
24 * 4. Try to keep the error messages short, but informative. | |
25 * | |
26 * 5. Use simple words and terminology, assume the reader of the message | |
27 * doesn't have an advanced degree in math, and that English is not the | |
28 * reader's native language. Do not assume any formal computer science | |
29 * training. For example, do not use Latin abbreviations (prefer "that is" over | |
30 * "i.e.", and "for example" over "e.g."). Also avoid phrases such as "if and | |
31 * only if" and "iff", that level of precision is unnecessary. | |
32 * | |
33 * 6. Prefer contractions when they are in common use, for example, prefer | |
34 * "can't" over "cannot". Using "cannot", "must not", "shall not", etc. is | |
35 * off-putting to people new to programming. | |
36 * | |
37 * 7. Use common terminology, preferably from the Dart Language | |
38 * Specification. This increases the user's chance of finding a good | |
39 * explanation on the web. | |
40 * | |
41 * 8. Do not try to be cute or funny. It is extremely frustrating to work on a | |
42 * product that crashes with a "tongue-in-cheek" message, especially if you did | |
43 * not want to use this product to begin with with. | |
44 * | |
45 * 9. Do not lie, that is, do not write error messages containing phrases like | |
46 * "can't happen". If the user ever saw this message, it would be a | |
47 * lie. Prefer messages like: "Internal error: This function should not be | |
48 * called when 'x' is null.". | |
49 * | |
50 * 10. Prefer to not use imperative tone. That is, the message should not sound | |
51 * accusing or like it is ordering the user around. The computer should | |
52 * describe the problem, not criticize for violating the specification. | |
53 * | |
54 * Other things to keep in mind: | |
55 * | |
56 * 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 | |
58 * message. For example, consider duplicated elements. First report a WARNING | |
59 * or ERROR about the duplicated element, and then report an INFO about the | |
60 * location of the existing element. | |
61 * | |
62 * 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 | |
64 * combine the first two in [template] and the last in [howToFix]. | |
65 */ | |
66 // TODO(johnnniwinther): For Infos, consider adding a reference to the | |
67 // error/warning/hint that they belong to. | |
68 class MessageKind { | |
69 /// Should describe what is wrong and why. | |
70 final String template; | |
71 | |
72 /// Should describe how to fix the problem. Elided when using --terse option. | |
73 final String howToFix; | |
74 | |
75 /** | |
76 * Examples will be checked by | |
77 * tests/compiler/dart2js/message_kind_test.dart. | |
78 * | |
79 * 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 | |
81 * main library code must be 'main.dart'. | |
82 */ | |
83 final List examples; | |
84 | |
85 /// Additional options needed for the examples to work. | |
86 final List<String> options; | |
87 | |
88 const MessageKind(this.template, | |
89 {this.howToFix, | |
90 this.examples, | |
91 this.options: const <String>[]}); | |
92 | |
93 /// Do not use this. It is here for legacy and debugging. It violates item 4 | |
94 /// above. | |
95 static const MessageKind GENERIC = const MessageKind('#{text}'); | |
96 | |
97 static const MessageKind NOT_ASSIGNABLE = const MessageKind( | |
98 "'#{fromType}' is not assignable to '#{toType}'."); | |
99 | |
100 static const MessageKind VOID_EXPRESSION = const MessageKind( | |
101 "Expression does not yield a value."); | |
102 | |
103 static const MessageKind VOID_VARIABLE = const MessageKind( | |
104 "Variable cannot be of type void."); | |
105 | |
106 static const MessageKind RETURN_VALUE_IN_VOID = const MessageKind( | |
107 "Cannot return value from void function."); | |
108 | |
109 static const MessageKind RETURN_NOTHING = const MessageKind( | |
110 "Value of type '#{returnType}' expected."); | |
111 | |
112 static const MessageKind MISSING_ARGUMENT = const MessageKind( | |
113 "Missing argument of type '#{argumentType}'."); | |
114 | |
115 static const MessageKind ADDITIONAL_ARGUMENT = const MessageKind( | |
116 "Additional argument."); | |
117 | |
118 static const MessageKind NAMED_ARGUMENT_NOT_FOUND = const MessageKind( | |
119 "No named argument '#{argumentName}' found on method."); | |
120 | |
121 static const MessageKind MEMBER_NOT_FOUND = const MessageKind( | |
122 "No member named '#{memberName}' in class '#{className}'."); | |
123 | |
124 static const MessageKind METHOD_NOT_FOUND = const MessageKind( | |
125 "No method named '#{memberName}' in class '#{className}'."); | |
126 | |
127 static const MessageKind OPERATOR_NOT_FOUND = const MessageKind( | |
128 "No operator '#{memberName}' in class '#{className}'."); | |
129 | |
130 static const MessageKind SETTER_NOT_FOUND = const MessageKind( | |
131 "No setter named '#{memberName}' in class '#{className}'."); | |
132 | |
133 static const MessageKind GETTER_NOT_FOUND = const MessageKind( | |
134 "No getter named '#{memberName}' in class '#{className}'."); | |
135 | |
136 static const MessageKind NOT_CALLABLE = const MessageKind( | |
137 "'#{elementName}' is not callable."); | |
138 | |
139 static const MessageKind MEMBER_NOT_STATIC = const MessageKind( | |
140 "'#{className}.#{memberName}' is not static."); | |
141 | |
142 static const MessageKind NO_INSTANCE_AVAILABLE = const MessageKind( | |
143 "'#{name}' is only available in instance methods."); | |
144 | |
145 static const MessageKind PRIVATE_ACCESS = const MessageKind( | |
146 "'#{name}' is declared private within library " | |
147 "'#{libraryName}'."); | |
148 | |
149 static const MessageKind THIS_IS_THE_DECLARATION = const MessageKind( | |
150 "This is the declaration of '#{name}'."); | |
151 | |
152 static const MessageKind THIS_IS_THE_METHOD = const MessageKind( | |
153 "This is the method declaration."); | |
154 | |
155 static const MessageKind CANNOT_RESOLVE = const MessageKind( | |
156 "Cannot resolve '#{name}'."); | |
157 | |
158 static const MessageKind CANNOT_RESOLVE_CONSTRUCTOR = const MessageKind( | |
159 "Cannot resolve constructor '#{constructorName}'."); | |
160 | |
161 static const MessageKind CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT = | |
162 const MessageKind("cannot resolve constructor '#{constructorName}'" | |
163 " for implicit super call.", | |
164 howToFix: "Try explicitly invoking a constructor of the super class", | |
165 examples: const [""" | |
166 class A { | |
167 A.foo() {} | |
168 } | |
169 class B extends A { | |
170 B(); | |
171 } | |
172 main() => new B(); | |
173 """]); | |
174 | |
175 static const MessageKind INVALID_UNNAMED_CONSTRUCTOR_NAME = const MessageKind( | |
176 "Unnamed constructor name must be '#{name}'."); | |
177 | |
178 static const MessageKind INVALID_CONSTRUCTOR_NAME = const MessageKind( | |
179 "Constructor name must start with '#{name}'."); | |
180 | |
181 static const MessageKind CANNOT_RESOLVE_TYPE = const MessageKind( | |
182 "Cannot resolve type '#{typeName}'."); | |
183 | |
184 static const MessageKind DUPLICATE_DEFINITION = const MessageKind( | |
185 "Duplicate definition of '#{name}'."); | |
186 | |
187 static const MessageKind EXISTING_DEFINITION = const MessageKind( | |
188 "Existing definition of '#{name}'."); | |
189 | |
190 static const MessageKind DUPLICATE_IMPORT = const MessageKind( | |
191 "Duplicate import of '#{name}'."); | |
192 | |
193 static const MessageKind HIDDEN_IMPORT = const MessageKind( | |
194 "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' " | |
195 "from library '#{hidingUri}'.", | |
196 howToFix: "Try adding 'hide #{name}' to the import of '#{hiddenUri}'.", | |
197 examples: const [ | |
198 const { | |
199 'main.dart': | |
200 """ | |
201 import 'dart:async'; // This imports a class Future. | |
202 import 'future.dart'; | |
203 | |
204 void main() => new Future();""", | |
205 | |
206 'future.dart': | |
207 """ | |
208 library future; | |
209 | |
210 class Future {}"""}, | |
211 | |
212 const { | |
213 'main.dart': | |
214 """ | |
215 import 'future.dart'; | |
216 import 'dart:async'; // This imports a class Future. | |
217 | |
218 void main() => new Future();""", | |
219 | |
220 'future.dart': | |
221 """ | |
222 library future; | |
223 | |
224 class Future {}"""}, | |
225 | |
226 const { | |
227 'main.dart': | |
228 """ | |
229 import 'export.dart'; | |
230 import 'dart:async'; // This imports a class Future. | |
231 | |
232 void main() => new Future();""", | |
233 | |
234 'future.dart': | |
235 """ | |
236 library future; | |
237 | |
238 class Future {}""", | |
239 | |
240 'export.dart': | |
241 """ | |
242 library export; | |
243 | |
244 export 'future.dart';"""}, | |
245 | |
246 const { | |
247 'main.dart': | |
248 """ | |
249 import 'future.dart' as prefix; | |
250 import 'dart:async' as prefix; // This imports a class Future. | |
251 | |
252 void main() => new prefix.Future();""", | |
253 | |
254 'future.dart': | |
255 """ | |
256 library future; | |
257 | |
258 class Future {}"""}]); | |
259 | |
260 | |
261 static const MessageKind HIDDEN_IMPLICIT_IMPORT = const MessageKind( | |
262 "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' " | |
263 "from library '#{hidingUri}'.", | |
264 howToFix: "Try adding an explicit " | |
265 "'import \"#{hiddenUri}\" hide #{name}'.", | |
266 examples: const [ | |
267 const { | |
268 'main.dart': | |
269 """ | |
270 // This hides the implicit import of class Type from dart:core. | |
271 import 'type.dart'; | |
272 | |
273 void main() => new Type();""", | |
274 | |
275 'type.dart': | |
276 """ | |
277 library type; | |
278 | |
279 class Type {}"""}, | |
280 const { | |
281 'conflictsWithDart.dart': | |
282 """ | |
283 library conflictsWithDart; | |
284 | |
285 class Duration { | |
286 static var x = 100; | |
287 } | |
288 """, | |
289 | |
290 'conflictsWithDartAsWell.dart': | |
291 """ | |
292 library conflictsWithDartAsWell; | |
293 | |
294 class Duration { | |
295 static var x = 100; | |
296 } | |
297 """, | |
298 | |
299 'main.dart': | |
300 r""" | |
301 library testDartConflicts; | |
302 | |
303 import 'conflictsWithDart.dart'; | |
304 import 'conflictsWithDartAsWell.dart'; | |
305 | |
306 main() { | |
307 print("Hail Caesar ${Duration.x}"); | |
308 } | |
309 """}]); | |
310 | |
311 static const MessageKind DUPLICATE_EXPORT = const MessageKind( | |
312 "Duplicate export of '#{name}'.", | |
313 howToFix: "Trying adding 'hide #{name}' to one of the exports.", | |
314 examples: const [const { | |
315 'main.dart': """ | |
316 export 'decl1.dart'; | |
317 export 'decl2.dart'; | |
318 | |
319 main() {}""", | |
320 'decl1.dart': "class Class {}", | |
321 'decl2.dart': "class Class {}"}]); | |
322 | |
323 static const MessageKind DUPLICATE_EXPORT_CONT = const MessageKind( | |
324 "This is another export of '#{name}'."); | |
325 | |
326 static const MessageKind DUPLICATE_EXPORT_DECL = const MessageKind( | |
327 "The exported '#{name}' from export #{uriString} is defined here."); | |
328 | |
329 static const MessageKind NOT_A_TYPE = const MessageKind( | |
330 "'#{node}' is not a type."); | |
331 | |
332 static const MessageKind NOT_A_PREFIX = const MessageKind( | |
333 "'#{node}' is not a prefix."); | |
334 | |
335 static const MessageKind CANNOT_FIND_CONSTRUCTOR = const MessageKind( | |
336 "Cannot find constructor '#{constructorName}'."); | |
337 | |
338 static const MessageKind CYCLIC_CLASS_HIERARCHY = const MessageKind( | |
339 "'#{className}' creates a cycle in the class hierarchy."); | |
340 | |
341 static const MessageKind CYCLIC_REDIRECTING_FACTORY = const MessageKind( | |
342 'Redirecting factory leads to a cyclic redirection.'); | |
343 | |
344 static const MessageKind INVALID_RECEIVER_IN_INITIALIZER = const MessageKind( | |
345 "Field initializer expected."); | |
346 | |
347 static const MessageKind NO_SUPER_IN_STATIC = const MessageKind( | |
348 "'super' is only available in instance methods."); | |
349 | |
350 static const MessageKind DUPLICATE_INITIALIZER = const MessageKind( | |
351 "Field '#{fieldName}' is initialized more than once."); | |
352 | |
353 static const MessageKind ALREADY_INITIALIZED = const MessageKind( | |
354 "'#{fieldName}' was already initialized here."); | |
355 | |
356 static const MessageKind INIT_STATIC_FIELD = const MessageKind( | |
357 "Cannot initialize static field '#{fieldName}'."); | |
358 | |
359 static const MessageKind NOT_A_FIELD = const MessageKind( | |
360 "'#{fieldName}' is not a field."); | |
361 | |
362 static const MessageKind CONSTRUCTOR_CALL_EXPECTED = const MessageKind( | |
363 "only call to 'this' or 'super' constructor allowed."); | |
364 | |
365 static const MessageKind INVALID_FOR_IN = const MessageKind( | |
366 "Invalid for-in variable declaration."); | |
367 | |
368 static const MessageKind INVALID_INITIALIZER = const MessageKind( | |
369 "Invalid initializer."); | |
370 | |
371 static const MessageKind FUNCTION_WITH_INITIALIZER = const MessageKind( | |
372 "Only constructors can have initializers."); | |
373 | |
374 static const MessageKind REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind( | |
375 "Cyclic constructor redirection."); | |
376 | |
377 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind( | |
378 "Redirecting constructor can't have a body."); | |
379 | |
380 static const MessageKind CONST_CONSTRUCTOR_HAS_BODY = const MessageKind( | |
381 "Const constructor or factory can't have a body.", | |
382 howToFix: "Remove the 'const' keyword or the body", | |
383 examples: const [""" | |
384 class C { | |
385 const C() {} | |
386 } | |
387 | |
388 main() => new C();"""]); | |
389 | |
390 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER = | |
391 const MessageKind( | |
392 "Redirecting constructor cannot have other initializers."); | |
393 | |
394 static const MessageKind SUPER_INITIALIZER_IN_OBJECT = const MessageKind( | |
395 "'Object' cannot have a super initializer."); | |
396 | |
397 static const MessageKind DUPLICATE_SUPER_INITIALIZER = const MessageKind( | |
398 "Cannot have more than one super initializer."); | |
399 | |
400 static const MessageKind INVALID_CONSTRUCTOR_ARGUMENTS = const MessageKind( | |
401 "Arguments do not match the expected parameters of constructor " | |
402 "'#{constructorName}'."); | |
403 | |
404 static const MessageKind NO_MATCHING_CONSTRUCTOR = const MessageKind( | |
405 "'super' call arguments and constructor parameters do not match."); | |
406 | |
407 static const MessageKind NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT = | |
408 const MessageKind( | |
409 "Implicit 'super' call arguments and constructor parameters " | |
410 "do not match."); | |
411 | |
412 static const MessageKind CONST_CALLS_NON_CONST = const MessageKind( | |
413 "'const' constructor cannot call a non-const constructor."); | |
414 | |
415 static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS = | |
416 const MessageKind( | |
417 "Can't declare constructor 'const' on class #{className} " | |
418 "because the class contains non-final instance fields.", | |
419 howToFix: "Try making all fields final.", | |
420 examples: const [""" | |
421 class C { | |
422 // 'a' must be declared final to allow for the const constructor. | |
423 var a; | |
424 const C(this.a); | |
425 } | |
426 | |
427 main() => new C(0);"""]); | |
428 | |
429 static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD = | |
430 const MessageKind("This non-final field prevents using const " | |
431 "constructors."); | |
432 | |
433 static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR = | |
434 const MessageKind("This const constructor is not allowed due to " | |
435 "non-final fields."); | |
436 | |
437 | |
438 static const MessageKind INITIALIZING_FORMAL_NOT_ALLOWED = const MessageKind( | |
439 "Initializing formal parameter only allowed in generative " | |
440 "constructor."); | |
441 | |
442 static const MessageKind INVALID_PARAMETER = const MessageKind( | |
443 "Cannot resolve parameter."); | |
444 | |
445 static const MessageKind NOT_INSTANCE_FIELD = const MessageKind( | |
446 "'#{fieldName}' is not an instance field."); | |
447 | |
448 static const MessageKind NO_CATCH_NOR_FINALLY = const MessageKind( | |
449 "Expected 'catch' or 'finally'."); | |
450 | |
451 static const MessageKind EMPTY_CATCH_DECLARATION = const MessageKind( | |
452 "Expected an identifier in catch declaration."); | |
453 | |
454 static const MessageKind EXTRA_CATCH_DECLARATION = const MessageKind( | |
455 "Extra parameter in catch declaration."); | |
456 | |
457 static const MessageKind PARAMETER_WITH_TYPE_IN_CATCH = const MessageKind( | |
458 "Cannot use type annotations in catch."); | |
459 | |
460 static const MessageKind PARAMETER_WITH_MODIFIER_IN_CATCH = const MessageKind( | |
461 "Cannot use modifiers in catch."); | |
462 | |
463 static const MessageKind OPTIONAL_PARAMETER_IN_CATCH = const MessageKind( | |
464 "Cannot use optional parameters in catch."); | |
465 | |
466 static const MessageKind THROW_WITHOUT_EXPRESSION = const MessageKind( | |
467 "Cannot use re-throw outside of catch block " | |
468 "(expression expected after 'throw')."); | |
469 | |
470 static const MessageKind UNBOUND_LABEL = const MessageKind( | |
471 "Cannot resolve label '#{labelName}'."); | |
472 | |
473 static const MessageKind NO_BREAK_TARGET = const MessageKind( | |
474 "'break' statement not inside switch or loop."); | |
475 | |
476 static const MessageKind NO_CONTINUE_TARGET = const MessageKind( | |
477 "'continue' statement not inside loop."); | |
478 | |
479 static const MessageKind EXISTING_LABEL = const MessageKind( | |
480 "Original declaration of duplicate label '#{labelName}'."); | |
481 | |
482 static const MessageKind DUPLICATE_LABEL = const MessageKind( | |
483 "Duplicate declaration of label '#{labelName}'."); | |
484 | |
485 static const MessageKind UNUSED_LABEL = const MessageKind( | |
486 "Unused label '#{labelName}'."); | |
487 | |
488 static const MessageKind INVALID_CONTINUE = const MessageKind( | |
489 "Target of continue is not a loop or switch case."); | |
490 | |
491 static const MessageKind INVALID_BREAK = const MessageKind( | |
492 "Target of break is not a statement."); | |
493 | |
494 static const MessageKind DUPLICATE_TYPE_VARIABLE_NAME = const MessageKind( | |
495 "Type variable '#{typeVariableName}' already declared."); | |
496 | |
497 static const MessageKind TYPE_VARIABLE_WITHIN_STATIC_MEMBER = | |
498 const MessageKind( | |
499 "Cannot refer to type variable '#{typeVariableName}' " | |
500 "within a static member."); | |
501 | |
502 static const MessageKind TYPE_VARIABLE_IN_CONSTANT = const MessageKind( | |
503 "Constant expressions can't refer to type variables.", | |
504 howToFix: "Try removing the type variable or replacing it with a " | |
505 "concrete type.", | |
506 examples: const [""" | |
507 class C<T> { | |
508 const C(); | |
509 | |
510 m(T t) => const C<T>(); | |
511 } | |
512 | |
513 void main() => new C().m(null); | |
514 """ | |
515 ]); | |
516 | |
517 | |
518 static const MessageKind INVALID_TYPE_VARIABLE_BOUND = const MessageKind( | |
519 "'#{typeArgument}' is not a subtype of bound '#{bound}' for " | |
520 "type variable '#{typeVariable}' of type '#{thisType}'.", | |
521 howToFix: "Try to change or remove the type argument.", | |
522 examples: const [""" | |
523 class C<T extends num> {} | |
524 | |
525 // 'String' is not a valid instantiation of T with bound num.'. | |
526 main() => new C<String>(); | |
527 """]); | |
528 | |
529 static const MessageKind INVALID_USE_OF_SUPER = const MessageKind( | |
530 "'super' not allowed here."); | |
531 | |
532 static const MessageKind INVALID_CASE_DEFAULT = const MessageKind( | |
533 "'default' only allowed on last case of a switch."); | |
534 | |
535 static const MessageKind SWITCH_CASE_TYPES_NOT_EQUAL = const MessageKind( | |
536 "'case' expressions do not all have type '#{type}'."); | |
537 | |
538 static const MessageKind SWITCH_CASE_TYPES_NOT_EQUAL_CASE = const MessageKind( | |
539 "'case' expression of type '#{type}'."); | |
540 | |
541 static const MessageKind SWITCH_CASE_FORBIDDEN = const MessageKind( | |
542 "'case' expression may not be of type '#{type}'."); | |
543 | |
544 static const MessageKind SWITCH_CASE_VALUE_OVERRIDES_EQUALS = | |
545 const MessageKind( | |
546 "'case' expression type '#{type}' overrides 'operator =='."); | |
547 | |
548 static const MessageKind INVALID_ARGUMENT_AFTER_NAMED = const MessageKind( | |
549 "Unnamed argument after named argument."); | |
550 | |
551 static const MessageKind NOT_A_COMPILE_TIME_CONSTANT = const MessageKind( | |
552 "Not a compile-time constant."); | |
553 | |
554 static const MessageKind DEFERRED_COMPILE_TIME_CONSTANT = const MessageKind( | |
555 "A Deferred value cannot be used as a compile-time constant."); | |
556 | |
557 static const MessageKind DEFERRED_COMPILE_TIME_CONSTANT_CONSTRUCTION = | |
558 const MessageKind("A deferred class cannot be used to create a" | |
559 "compile-time constant."); | |
560 | |
561 static const MessageKind CYCLIC_COMPILE_TIME_CONSTANTS = const MessageKind( | |
562 "Cycle in the compile-time constant computation."); | |
563 | |
564 static const MessageKind CONSTRUCTOR_IS_NOT_CONST = const MessageKind( | |
565 "Constructor is not a 'const' constructor."); | |
566 | |
567 static const MessageKind CONST_MAP_KEY_OVERRIDES_EQUALS = | |
568 const MessageKind( | |
569 "Const-map key type '#{type}' overrides 'operator =='."); | |
570 | |
571 static const MessageKind NO_SUCH_LIBRARY_MEMBER = const MessageKind( | |
572 "'#{libraryName}' has no member named '#{memberName}'."); | |
573 | |
574 static const MessageKind CANNOT_INSTANTIATE_TYPEDEF = const MessageKind( | |
575 "Cannot instantiate typedef '#{typedefName}'."); | |
576 | |
577 static const MessageKind REQUIRED_PARAMETER_WITH_DEFAULT = const MessageKind( | |
578 "Non-optional parameters can't have a default value.", | |
579 howToFix: | |
580 "Try removing the default value or making the parameter optional.", | |
581 examples: const [""" | |
582 main() { | |
583 foo(a: 1) => print(a); | |
584 foo(2); | |
585 }""", """ | |
586 main() { | |
587 foo(a = 1) => print(a); | |
588 foo(2); | |
589 }"""]); | |
590 | |
591 static const MessageKind NAMED_PARAMETER_WITH_EQUALS = const MessageKind( | |
592 "Named optional parameters can't use '=' to specify a default " | |
593 "value.", | |
594 howToFix: "Try replacing '=' with ':'.", | |
595 examples: const [""" | |
596 main() { | |
597 foo({a = 1}) => print(a); | |
598 foo(a: 2); | |
599 }"""]); | |
600 | |
601 static const MessageKind POSITIONAL_PARAMETER_WITH_EQUALS = const MessageKind( | |
602 "Positional optional parameters can't use ':' to specify a " | |
603 "default value.", | |
604 howToFix: "Try replacing ':' with '='.", | |
605 examples: const [""" | |
606 main() { | |
607 foo([a: 1]) => print(a); | |
608 foo(2); | |
609 }"""]); | |
610 | |
611 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind( | |
612 "A parameter of a typedef can't specify a default value.", | |
613 howToFix: | |
614 "Try removing the default value.", | |
615 examples: const [""" | |
616 typedef void F([int arg = 0]); | |
617 | |
618 main() { | |
619 F f; | |
620 }""", """ | |
621 typedef void F({int arg: 0}); | |
622 | |
623 main() { | |
624 F f; | |
625 }"""]); | |
626 | |
627 static const MessageKind FUNCTION_TYPE_FORMAL_WITH_DEFAULT = const MessageKind
( | |
628 "A function type parameter can't specify a default value.", | |
629 howToFix: | |
630 "Try removing the default value.", | |
631 examples: const [""" | |
632 foo(f(int i, [a = 1])) {} | |
633 | |
634 main() { | |
635 foo(1, 2); | |
636 }""", """ | |
637 foo(f(int i, {a: 1})) {} | |
638 | |
639 main() { | |
640 foo(1, a: 2); | |
641 }"""]); | |
642 | |
643 static const MessageKind REDIRECTING_FACTORY_WITH_DEFAULT = const MessageKind( | |
644 "A parameter of a redirecting factory constructor can't specify a " | |
645 "default value.", | |
646 howToFix: | |
647 "Try removing the default value.", | |
648 examples: const [""" | |
649 class A { | |
650 A([a]); | |
651 factory A.foo([a = 1]) = A; | |
652 } | |
653 | |
654 main() { | |
655 new A.foo(1); | |
656 }""", """ | |
657 class A { | |
658 A({a}); | |
659 factory A.foo({a: 1}) = A; | |
660 } | |
661 | |
662 main() { | |
663 new A.foo(a: 1); | |
664 }"""]); | |
665 | |
666 static const MessageKind FORMAL_DECLARED_CONST = const MessageKind( | |
667 "A formal parameter can't be declared const.", | |
668 howToFix: "Try removing 'const'.", | |
669 examples: const [""" | |
670 foo(const x) {} | |
671 main() => foo(42); | |
672 """, """ | |
673 foo({const x}) {} | |
674 main() => foo(42); | |
675 """, """ | |
676 foo([const x]) {} | |
677 main() => foo(42); | |
678 """]); | |
679 | |
680 static const MessageKind FORMAL_DECLARED_STATIC = const MessageKind( | |
681 "A formal parameter can't be declared static.", | |
682 howToFix: "Try removing 'static'.", | |
683 examples: const [""" | |
684 foo(static x) {} | |
685 main() => foo(42); | |
686 """, """ | |
687 foo({static x}) {} | |
688 main() => foo(42); | |
689 """, """ | |
690 foo([static x]) {} | |
691 main() => foo(42); | |
692 """]); | |
693 | |
694 static const MessageKind FINAL_FUNCTION_TYPE_PARAMETER = const MessageKind( | |
695 "A function type parameter can't be declared final.", | |
696 howToFix: "Try removing 'final'.", | |
697 examples: const [""" | |
698 foo(final int x(int a)) {} | |
699 main() => foo((y) => 42); | |
700 """, """ | |
701 foo({final int x(int a)}) {} | |
702 main() => foo((y) => 42); | |
703 """, """ | |
704 foo([final int x(int a)]) {} | |
705 main() => foo((y) => 42); | |
706 """]); | |
707 | |
708 static const MessageKind VAR_FUNCTION_TYPE_PARAMETER = const MessageKind( | |
709 "A function type parameter can't be declared with 'var'.", | |
710 howToFix: "Try removing 'var'.", | |
711 examples: const [""" | |
712 foo(var int x(int a)) {} | |
713 main() => foo((y) => 42); | |
714 """, """ | |
715 foo({var int x(int a)}) {} | |
716 main() => foo((y) => 42); | |
717 """, """ | |
718 foo([var int x(int a)]) {} | |
719 main() => foo((y) => 42); | |
720 """]); | |
721 | |
722 static const MessageKind CANNOT_INSTANTIATE_TYPE_VARIABLE = const MessageKind( | |
723 "Cannot instantiate type variable '#{typeVariableName}'."); | |
724 | |
725 static const MessageKind CYCLIC_TYPE_VARIABLE = const MessageKind( | |
726 "Type variable '#{typeVariableName}' is a supertype of itself."); | |
727 | |
728 static const CYCLIC_TYPEDEF = const MessageKind( | |
729 "A typedef can't refer to itself.", | |
730 howToFix: "Try removing all references to '#{typedefName}' " | |
731 "in the definition of '#{typedefName}'.", | |
732 examples: const [""" | |
733 typedef F F(); // The return type 'F' is a self-reference. | |
734 main() { F f = null; }"""]); | |
735 | |
736 static const CYCLIC_TYPEDEF_ONE = const MessageKind( | |
737 "A typedef can't refer to itself through another typedef.", | |
738 howToFix: "Try removing all references to " | |
739 "'#{otherTypedefName}' in the definition of '#{typedefName}'.", | |
740 examples: const [""" | |
741 typedef G F(); // The return type 'G' is a self-reference through typedef 'G'. | |
742 typedef F G(); // The return type 'F' is a self-reference through typedef 'F'. | |
743 main() { F f = null; }""", | |
744 """ | |
745 typedef G F(); // The return type 'G' creates a self-reference. | |
746 typedef H G(); // The return type 'H' creates a self-reference. | |
747 typedef H(F f); // The argument type 'F' creates a self-reference. | |
748 main() { F f = null; }"""]); | |
749 | |
750 static const MessageKind CLASS_NAME_EXPECTED = const MessageKind( | |
751 "Class name expected."); | |
752 | |
753 static const MessageKind CANNOT_EXTEND = const MessageKind( | |
754 "'#{type}' cannot be extended."); | |
755 | |
756 static const MessageKind CANNOT_IMPLEMENT = const MessageKind( | |
757 "'#{type}' cannot be implemented."); | |
758 | |
759 // TODO(johnnwinther): Split messages into reasons for malformedness. | |
760 static const MessageKind CANNOT_EXTEND_MALFORMED = const MessageKind( | |
761 "Class '#{className}' can't extend the type '#{malformedType}' because " | |
762 "it is malformed.", | |
763 howToFix: "Try correcting the malformed type annotation or removing the " | |
764 "'extends' clause.", | |
765 examples: const [""" | |
766 class A extends Malformed {} | |
767 main() => new A();"""]); | |
768 | |
769 static const MessageKind CANNOT_IMPLEMENT_MALFORMED = const MessageKind( | |
770 "Class '#{className}' can't implement the type '#{malformedType}' " | |
771 "because it is malformed.", | |
772 howToFix: "Try correcting the malformed type annotation or removing the " | |
773 "type from the 'implements' clause.", | |
774 examples: const [""" | |
775 class A implements Malformed {} | |
776 main() => new A();"""]); | |
777 | |
778 static const MessageKind CANNOT_MIXIN_MALFORMED = const MessageKind( | |
779 "Class '#{className}' can't mixin the type '#{malformedType}' because it " | |
780 "is malformed.", | |
781 howToFix: "Try correcting the malformed type annotation or removing the " | |
782 "type from the 'with' clause.", | |
783 examples: const [""" | |
784 class A extends Object with Malformed {} | |
785 main() => new A();"""]); | |
786 | |
787 static const MessageKind CANNOT_MIXIN = const MessageKind( | |
788 "The type '#{type}' can't be mixed in.", | |
789 howToFix: "Try removing '#{type}' from the 'with' clause.", | |
790 examples: const [""" | |
791 class C extends Object with String {} | |
792 | |
793 main() => new C(); | |
794 """, """ | |
795 typedef C = Object with String; | |
796 | |
797 main() => new C(); | |
798 """]); | |
799 | |
800 static const MessageKind DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind( | |
801 "'#{type}' can not be both extended and implemented."); | |
802 | |
803 static const MessageKind DUPLICATE_IMPLEMENTS = const MessageKind( | |
804 "'#{type}' must not occur more than once " | |
805 "in the implements clause."); | |
806 | |
807 static const MessageKind MULTI_INHERITANCE = const MessageKind( | |
808 "Dart2js does not currently support inheritance of the same class with " | |
809 "different type arguments: Both #{firstType} and #{secondType} are " | |
810 "supertypes of #{thisType}."); | |
811 | |
812 static const MessageKind ILLEGAL_SUPER_SEND = const MessageKind( | |
813 "'#{name}' cannot be called on super."); | |
814 | |
815 static const MessageKind NO_SUCH_SUPER_MEMBER = const MessageKind( | |
816 "Cannot resolve '#{memberName}' in a superclass of '#{className}'."); | |
817 | |
818 static const MessageKind ADDITIONAL_TYPE_ARGUMENT = const MessageKind( | |
819 "Additional type argument."); | |
820 | |
821 static const MessageKind MISSING_TYPE_ARGUMENT = const MessageKind( | |
822 "Missing type argument."); | |
823 | |
824 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or MISSING_TYPE_ARGUMENT | |
825 // instead. | |
826 static const MessageKind TYPE_ARGUMENT_COUNT_MISMATCH = const MessageKind( | |
827 "Incorrect number of type arguments on '#{type}'."); | |
828 | |
829 static const MessageKind GETTER_MISMATCH = const MessageKind( | |
830 "Setter disagrees on: '#{modifiers}'."); | |
831 | |
832 static const MessageKind SETTER_MISMATCH = const MessageKind( | |
833 "Getter disagrees on: '#{modifiers}'."); | |
834 | |
835 static const MessageKind ILLEGAL_SETTER_FORMALS = const MessageKind( | |
836 "A setter must have exactly one argument."); | |
837 | |
838 static const MessageKind NO_STATIC_OVERRIDE = const MessageKind( | |
839 "Static member cannot override instance member '#{memberName}' of " | |
840 "'#{className}'."); | |
841 | |
842 static const MessageKind NO_STATIC_OVERRIDE_CONT = const MessageKind( | |
843 "This is the instance member that cannot be overridden " | |
844 "by a static member."); | |
845 | |
846 static const MessageKind INSTANCE_STATIC_SAME_NAME = const MessageKind( | |
847 "Instance member '#{memberName}' and static member of " | |
848 "superclass '#{className}' have the same name."); | |
849 | |
850 static const MessageKind INSTANCE_STATIC_SAME_NAME_CONT = const MessageKind( | |
851 "This is the static member with the same name."); | |
852 | |
853 static const MessageKind INVALID_OVERRIDE_METHOD = const MessageKind( | |
854 "The type '#{declaredType}' of method '#{name}' declared in " | |
855 "'#{class}' is not a subtype of the overridden method type " | |
856 "'#{inheritedType}' inherited from '#{inheritedClass}'."); | |
857 | |
858 static const MessageKind INVALID_OVERRIDDEN_METHOD = const MessageKind( | |
859 "This is the overridden method '#{name}' declared in class " | |
860 "'#{class}'."); | |
861 | |
862 static const MessageKind INVALID_OVERRIDE_GETTER = const MessageKind( | |
863 "The type '#{declaredType}' of getter '#{name}' declared in " | |
864 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
865 "overridden getter inherited from '#{inheritedClass}'."); | |
866 | |
867 static const MessageKind INVALID_OVERRIDDEN_GETTER = const MessageKind( | |
868 "This is the overridden getter '#{name}' declared in class " | |
869 "'#{class}'."); | |
870 | |
871 static const MessageKind INVALID_OVERRIDE_GETTER_WITH_FIELD = | |
872 const MessageKind( | |
873 "The type '#{declaredType}' of field '#{name}' declared in " | |
874 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
875 "overridden getter inherited from '#{inheritedClass}'."); | |
876 | |
877 static const MessageKind INVALID_OVERRIDE_FIELD_WITH_GETTER = | |
878 const MessageKind( | |
879 "The type '#{declaredType}' of getter '#{name}' declared in " | |
880 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
881 "overridden field inherited from '#{inheritedClass}'."); | |
882 | |
883 static const MessageKind INVALID_OVERRIDE_SETTER = const MessageKind( | |
884 "The type '#{declaredType}' of setter '#{name}' declared in " | |
885 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
886 "overridden setter inherited from '#{inheritedClass}'."); | |
887 | |
888 static const MessageKind INVALID_OVERRIDDEN_SETTER = const MessageKind( | |
889 "This is the overridden setter '#{name}' declared in class " | |
890 "'#{class}'."); | |
891 | |
892 static const MessageKind INVALID_OVERRIDE_SETTER_WITH_FIELD = | |
893 const MessageKind( | |
894 "The type '#{declaredType}' of field '#{name}' declared in " | |
895 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
896 "overridden setter inherited from '#{inheritedClass}'."); | |
897 | |
898 static const MessageKind INVALID_OVERRIDE_FIELD_WITH_SETTER = | |
899 const MessageKind( | |
900 "The type '#{declaredType}' of setter '#{name}' declared in " | |
901 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
902 "overridden field inherited from '#{inheritedClass}'."); | |
903 | |
904 static const MessageKind INVALID_OVERRIDE_FIELD = const MessageKind( | |
905 "The type '#{declaredType}' of field '#{name}' declared in " | |
906 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
907 "overridden field inherited from '#{inheritedClass}'."); | |
908 | |
909 static const MessageKind INVALID_OVERRIDDEN_FIELD = const MessageKind( | |
910 "This is the overridden field '#{name}' declared in class " | |
911 "'#{class}'."); | |
912 | |
913 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD = | |
914 const MessageKind( | |
915 "Method '#{name}' in '#{class}' can't override field from " | |
916 "'#{inheritedClass}'."); | |
917 | |
918 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT = | |
919 const MessageKind( | |
920 "This is the field that cannot be overridden by a method."); | |
921 | |
922 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD = | |
923 const MessageKind( | |
924 "Field '#{name}' in '#{class}' can't override method from " | |
925 "'#{inheritedClass}'."); | |
926 | |
927 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT = | |
928 const MessageKind( | |
929 "This is the method that cannot be overridden by a field."); | |
930 | |
931 static const MessageKind CANNOT_OVERRIDE_GETTER_WITH_METHOD = | |
932 const MessageKind( | |
933 "Method '#{name}' in '#{class}' can't override getter from " | |
934 "'#{inheritedClass}'."); | |
935 | |
936 static const MessageKind CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT = | |
937 const MessageKind( | |
938 "This is the getter that cannot be overridden by a method."); | |
939 | |
940 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_GETTER = | |
941 const MessageKind( | |
942 "Getter '#{name}' in '#{class}' can't override method from " | |
943 "'#{inheritedClass}'."); | |
944 | |
945 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT = | |
946 const MessageKind( | |
947 "This is the method that cannot be overridden by a getter."); | |
948 | |
949 static const MessageKind MISSING_FORMALS = const MessageKind( | |
950 "Formal parameters are missing."); | |
951 | |
952 static const MessageKind EXTRA_FORMALS = const MessageKind( | |
953 "Formal parameters are not allowed here."); | |
954 | |
955 static const MessageKind UNARY_OPERATOR_BAD_ARITY = const MessageKind( | |
956 "Operator '#{operatorName}' must have no parameters."); | |
957 | |
958 static const MessageKind MINUS_OPERATOR_BAD_ARITY = const MessageKind( | |
959 "Operator '-' must have 0 or 1 parameters."); | |
960 | |
961 static const MessageKind BINARY_OPERATOR_BAD_ARITY = const MessageKind( | |
962 "Operator '#{operatorName}' must have exactly 1 parameter."); | |
963 | |
964 static const MessageKind TERNARY_OPERATOR_BAD_ARITY = const MessageKind( | |
965 "Operator '#{operatorName}' must have exactly 2 parameters."); | |
966 | |
967 static const MessageKind OPERATOR_OPTIONAL_PARAMETERS = const MessageKind( | |
968 "Operator '#{operatorName}' cannot have optional parameters."); | |
969 | |
970 static const MessageKind OPERATOR_NAMED_PARAMETERS = const MessageKind( | |
971 "Operator '#{operatorName}' cannot have named parameters."); | |
972 | |
973 static const MessageKind CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind( | |
974 "Cannot have return type for constructor."); | |
975 | |
976 static const MessageKind CANNOT_RETURN_FROM_CONSTRUCTOR = const MessageKind( | |
977 "Constructors can't return values.", | |
978 howToFix: "Remove the return statement or use a factory constructor.", | |
979 examples: const [""" | |
980 class C { | |
981 C() { | |
982 return 1; | |
983 } | |
984 } | |
985 | |
986 main() => new C();"""]); | |
987 | |
988 static const MessageKind ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind( | |
989 "Cannot have final modifier on method."); | |
990 | |
991 static const MessageKind ILLEGAL_CONST_FIELD_MODIFIER = const MessageKind( | |
992 "Cannot have const modifier on non-static field.", | |
993 howToFix: "Try adding a static modifier, or removing the const modifier.", | |
994 examples: const [""" | |
995 class C { | |
996 const int a = 1; | |
997 } | |
998 | |
999 main() => new C();"""]); | |
1000 | |
1001 static const MessageKind ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind( | |
1002 "Illegal constructor modifiers: '#{modifiers}'."); | |
1003 | |
1004 static const MessageKind ILLEGAL_MIXIN_APPLICATION_MODIFIERS = | |
1005 const MessageKind( | |
1006 "Illegal mixin application modifiers: '#{modifiers}'."); | |
1007 | |
1008 static const MessageKind ILLEGAL_MIXIN_SUPERCLASS = const MessageKind( | |
1009 "Class used as mixin must have Object as superclass."); | |
1010 | |
1011 static const MessageKind ILLEGAL_MIXIN_OBJECT = const MessageKind( | |
1012 "Cannot use Object as mixin."); | |
1013 | |
1014 static const MessageKind ILLEGAL_MIXIN_CONSTRUCTOR = const MessageKind( | |
1015 "Class used as mixin cannot have non-factory constructor."); | |
1016 | |
1017 static const MessageKind ILLEGAL_MIXIN_CYCLE = const MessageKind( | |
1018 "Class used as mixin introduces mixin cycle: " | |
1019 "'#{mixinName1}' <-> '#{mixinName2}'."); | |
1020 | |
1021 static const MessageKind ILLEGAL_MIXIN_WITH_SUPER = const MessageKind( | |
1022 "Cannot use class '#{className}' as a mixin because it uses " | |
1023 "'super'."); | |
1024 | |
1025 static const MessageKind ILLEGAL_MIXIN_SUPER_USE = const MessageKind( | |
1026 "Use of 'super' in class used as mixin."); | |
1027 | |
1028 static const MessageKind PARAMETER_NAME_EXPECTED = const MessageKind( | |
1029 "parameter name expected."); | |
1030 | |
1031 static const MessageKind CANNOT_RESOLVE_GETTER = const MessageKind( | |
1032 "Cannot resolve getter."); | |
1033 | |
1034 static const MessageKind CANNOT_RESOLVE_SETTER = const MessageKind( | |
1035 "Cannot resolve setter."); | |
1036 | |
1037 static const MessageKind ASSIGNING_METHOD = const MessageKind( | |
1038 "Cannot assign a value to a method."); | |
1039 | |
1040 static const MessageKind ASSIGNING_TYPE = const MessageKind( | |
1041 "Cannot assign a value to a type."); | |
1042 | |
1043 static const MessageKind VOID_NOT_ALLOWED = const MessageKind( | |
1044 "Type 'void' can't be used here because it isn't a return type.", | |
1045 howToFix: "Try removing 'void' keyword or replace it with 'var', 'final'," | |
1046 " or a type.", | |
1047 examples: const [ | |
1048 "void x; main() {}", | |
1049 "foo(void x) {} main() { foo(null); }", | |
1050 ]); | |
1051 | |
1052 static const MessageKind NULL_NOT_ALLOWED = const MessageKind( | |
1053 "`null` can't be used here."); | |
1054 | |
1055 static const MessageKind BEFORE_TOP_LEVEL = const MessageKind( | |
1056 "Part header must come before top-level definitions."); | |
1057 | |
1058 static const MessageKind LIBRARY_NAME_MISMATCH = const MessageKind( | |
1059 "Expected part of library name '#{libraryName}'.", | |
1060 howToFix: "Trying changing the directive to 'part of #{libraryName};'.", | |
1061 examples: const [const { | |
1062 'main.dart': """ | |
1063 library lib.foo; | |
1064 | |
1065 part 'part.dart'; | |
1066 | |
1067 main() {} | |
1068 """, | |
1069 | |
1070 'part.dart': """ | |
1071 part of lib.bar; | |
1072 """}]); | |
1073 | |
1074 static const MessageKind MISSING_LIBRARY_NAME = const MessageKind( | |
1075 "Library has no name. Part directive expected library name " | |
1076 "to be '#{libraryName}'.", | |
1077 howToFix: "Trying adding 'library #{libraryName};' to the library.", | |
1078 examples: const [const { | |
1079 'main.dart': """ | |
1080 part 'part.dart'; | |
1081 | |
1082 main() {} | |
1083 """, | |
1084 | |
1085 'part.dart': """ | |
1086 part of lib.foo; | |
1087 """}]); | |
1088 | |
1089 static const MessageKind THIS_IS_THE_PART_OF_TAG = const MessageKind( | |
1090 "This is the part of directive."); | |
1091 | |
1092 static const MessageKind MISSING_PART_OF_TAG = const MessageKind( | |
1093 "This file has no part-of tag, but it is being used as a part."); | |
1094 | |
1095 static const MessageKind DUPLICATED_PART_OF = const MessageKind( | |
1096 "Duplicated part-of directive."); | |
1097 | |
1098 static const MessageKind ILLEGAL_DIRECTIVE = const MessageKind( | |
1099 "Directive not allowed here."); | |
1100 | |
1101 static const MessageKind DUPLICATED_LIBRARY_NAME = const MessageKind( | |
1102 "Duplicated library name '#{libraryName}'."); | |
1103 | |
1104 static const MessageKind DUPLICATED_RESOURCE = const MessageKind( | |
1105 "The resource '#{resourceUri}' is loaded through both " | |
1106 "'#{canonicalUri1}' and '#{canonicalUri2}'."); | |
1107 | |
1108 static const MessageKind DUPLICATED_LIBRARY_RESOURCE = | |
1109 const MessageKind( | |
1110 "The library '#{libraryName}' in '#{resourceUri}' is loaded through " | |
1111 "both '#{canonicalUri1}' and '#{canonicalUri2}'."); | |
1112 | |
1113 // This is used as an exception. | |
1114 static const MessageKind INVALID_SOURCE_FILE_LOCATION = const MessageKind(''' | |
1115 Invalid offset (#{offset}) in source map. | |
1116 File: #{fileName} | |
1117 Length: #{length}'''); | |
1118 | |
1119 static const MessageKind TOP_LEVEL_VARIABLE_DECLARED_STATIC = | |
1120 const MessageKind( | |
1121 "Top-level variable cannot be declared static."); | |
1122 | |
1123 static const MessageKind REFERENCE_IN_INITIALIZATION = const MessageKind( | |
1124 "Variable '#{variableName}' is referenced during its " | |
1125 "initialization.", | |
1126 howToFix: "If you are trying to reference a shadowed variable, rename" | |
1127 " one of the variables.", | |
1128 examples: const [""" | |
1129 foo(t) { | |
1130 var t = t; | |
1131 return t; | |
1132 } | |
1133 | |
1134 main() => foo(1); | |
1135 """]); | |
1136 | |
1137 static const MessageKind CONST_WITHOUT_INITIALIZER = const MessageKind( | |
1138 "A constant variable must be initialized.", | |
1139 howToFix: "Try adding an initializer or " | |
1140 "removing the 'const' modifier.", | |
1141 examples: const [""" | |
1142 void main() { | |
1143 const c; // This constant variable must be initialized. | |
1144 }"""]); | |
1145 | |
1146 static const MessageKind FINAL_WITHOUT_INITIALIZER = const MessageKind( | |
1147 "A final variable must be initialized.", | |
1148 howToFix: "Try adding an initializer or " | |
1149 "removing the 'final' modifier.", | |
1150 examples: const [ | |
1151 "class C { static final field; } main() => C.field;"]); | |
1152 | |
1153 static const MessageKind MEMBER_USES_CLASS_NAME = const MessageKind( | |
1154 "Member variable can't have the same name as the class it is " | |
1155 "declared in.", | |
1156 howToFix: "Try renaming the variable.", | |
1157 examples: const [""" | |
1158 class A { var A; } | |
1159 main() { | |
1160 var a = new A(); | |
1161 a.A = 1; | |
1162 } | |
1163 """, """ | |
1164 class A { static var A; } | |
1165 main() => A.A = 1; | |
1166 """]); | |
1167 | |
1168 static const MessageKind WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT = | |
1169 const MessageKind( | |
1170 "Wrong number of arguments to assert. Should be 1, but given " | |
1171 "#{argumentCount}."); | |
1172 | |
1173 static const MessageKind ASSERT_IS_GIVEN_NAMED_ARGUMENTS = const MessageKind( | |
1174 "'assert' takes no named arguments, but given #{argumentCount}."); | |
1175 | |
1176 static const MessageKind FACTORY_REDIRECTION_IN_NON_FACTORY = | |
1177 const MessageKind( | |
1178 "Factory redirection only allowed in factories."); | |
1179 | |
1180 static const MessageKind MISSING_FACTORY_KEYWORD = const MessageKind( | |
1181 "Did you forget a factory keyword here?"); | |
1182 | |
1183 static const MessageKind DEFERRED_LIBRARY_DART_2_DART = | |
1184 const MessageKind( | |
1185 "Deferred loading is not supported by the dart backend yet." | |
1186 "The output will not be split."); | |
1187 | |
1188 static const MessageKind DEFERRED_LIBRARY_WITHOUT_PREFIX = | |
1189 const MessageKind( | |
1190 "This import is deferred but there is no prefix keyword.", | |
1191 howToFix: | |
1192 "Try adding a prefix to the import."); | |
1193 | |
1194 static const MessageKind DEFERRED_OLD_SYNTAX = | |
1195 const MessageKind( | |
1196 "The DeferredLibrary annotation is obsolete.", | |
1197 howToFix: | |
1198 "Use the \"import 'lib.dart' deferred as prefix\" syntax instead."); | |
1199 | |
1200 static const MessageKind DEFERRED_LIBRARY_DUPLICATE_PREFIX = | |
1201 const MessageKind( | |
1202 "The prefix of this deferred import is not unique.", | |
1203 howToFix: | |
1204 "Try changing the import prefix."); | |
1205 | |
1206 static const MessageKind DEFERRED_TYPE_ANNOTATION = | |
1207 const MessageKind( | |
1208 "The type #{node} is deferred. " | |
1209 "Deferred types are not valid as type annotations.", | |
1210 howToFix: | |
1211 "Try using a non-deferred abstract class as an interface."); | |
1212 | |
1213 static const MessageKind ILLEGAL_STATIC = const MessageKind( | |
1214 "Modifier static is only allowed on functions declared in " | |
1215 "a class."); | |
1216 | |
1217 static const MessageKind STATIC_FUNCTION_BLOAT = const MessageKind( | |
1218 "Using '#{class}.#{name}' may lead to unnecessarily large " | |
1219 "generated code.", | |
1220 howToFix: | |
1221 "Try adding '@MirrorsUsed(...)' as described at " | |
1222 "https://goo.gl/Akrrog."); | |
1223 | |
1224 static const MessageKind NON_CONST_BLOAT = const MessageKind( | |
1225 "Using 'new #{name}' may lead to unnecessarily large generated " | |
1226 "code.", | |
1227 howToFix: | |
1228 "Try using 'const #{name}' or adding '@MirrorsUsed(...)' as " | |
1229 "described at https://goo.gl/Akrrog."); | |
1230 | |
1231 static const MessageKind STRING_EXPECTED = const MessageKind( | |
1232 "Expected a 'String', but got an instance of '#{type}'."); | |
1233 | |
1234 static const MessageKind PRIVATE_IDENTIFIER = const MessageKind( | |
1235 "'#{value}' is not a valid Symbol name because it starts with " | |
1236 "'_'."); | |
1237 | |
1238 static const MessageKind PRIVATE_NAMED_PARAMETER = const MessageKind( | |
1239 "Named optional parameter can't have a library private name.", | |
1240 howToFix: "Try removing the '_' or making the parameter positional or " | |
1241 "required.", | |
1242 examples: const ["""foo({int _p}) {} main() => foo();"""] | |
1243 ); | |
1244 | |
1245 static const MessageKind UNSUPPORTED_LITERAL_SYMBOL = const MessageKind( | |
1246 "Symbol literal '##{value}' is currently unsupported by dart2js."); | |
1247 | |
1248 static const MessageKind INVALID_SYMBOL = const MessageKind(''' | |
1249 '#{value}' is not a valid Symbol name because is not: | |
1250 * an empty String, | |
1251 * a user defined operator, | |
1252 * a qualified non-private identifier optionally followed by '=', or | |
1253 * a qualified non-private identifier followed by '.' and a user-defined ''' | |
1254 "operator."); | |
1255 | |
1256 static const MessageKind AMBIGUOUS_REEXPORT = const MessageKind( | |
1257 "'#{name}' is (re)exported by multiple libraries."); | |
1258 | |
1259 static const MessageKind AMBIGUOUS_LOCATION = const MessageKind( | |
1260 "'#{name}' is defined here."); | |
1261 | |
1262 static const MessageKind IMPORTED_HERE = const MessageKind( | |
1263 "'#{name}' is imported here."); | |
1264 | |
1265 static const MessageKind OVERRIDE_EQUALS_NOT_HASH_CODE = const MessageKind( | |
1266 "The class '#{class}' overrides 'operator==', " | |
1267 "but not 'get hashCode'."); | |
1268 | |
1269 static const MessageKind PACKAGE_ROOT_NOT_SET = const MessageKind( | |
1270 "Cannot resolve '#{uri}'. Package root has not been set."); | |
1271 | |
1272 static const MessageKind INTERNAL_LIBRARY_FROM = const MessageKind( | |
1273 "Internal library '#{resolvedUri}' is not accessible from " | |
1274 "'#{importingUri}'."); | |
1275 | |
1276 static const MessageKind INTERNAL_LIBRARY = const MessageKind( | |
1277 "Internal library '#{resolvedUri}' is not accessible."); | |
1278 | |
1279 static const MessageKind LIBRARY_NOT_FOUND = const MessageKind( | |
1280 "Library not found '#{resolvedUri}'."); | |
1281 | |
1282 static const MessageKind UNSUPPORTED_EQ_EQ_EQ = const MessageKind( | |
1283 "'===' is not an operator. " | |
1284 "Did you mean '#{lhs} == #{rhs}' or 'identical(#{lhs}, #{rhs})'?"); | |
1285 | |
1286 static const MessageKind UNSUPPORTED_BANG_EQ_EQ = const MessageKind( | |
1287 "'!==' is not an operator. " | |
1288 "Did you mean '#{lhs} != #{rhs}' or '!identical(#{lhs}, #{rhs})'?"); | |
1289 | |
1290 static const MessageKind UNSUPPORTED_PREFIX_PLUS = const MessageKind( | |
1291 "'+' is not a prefix operator. ", | |
1292 howToFix: "Try removing '+'.", | |
1293 examples: const [ | |
1294 "main() => +2; // No longer a valid way to write '2'" | |
1295 ]); | |
1296 | |
1297 static const MessageKind UNSUPPORTED_THROW_WITHOUT_EXP = const MessageKind( | |
1298 "No expression after 'throw'. " | |
1299 "Did you mean 'rethrow'?"); | |
1300 | |
1301 static const MessageKind DEPRECATED_TYPEDEF_MIXIN_SYNTAX = const MessageKind( | |
1302 "'typedef' not allowed here. ", | |
1303 howToFix: "Try replacing 'typedef' with 'class'.", | |
1304 examples: const [ | |
1305 """ | |
1306 class B { } | |
1307 class M1 { } | |
1308 typedef C = B with M1; // Need to replace 'typedef' with 'class'. | |
1309 main() { new C(); } | |
1310 """] | |
1311 ); | |
1312 | |
1313 static const MessageKind MIRRORS_EXPECTED_STRING = const MessageKind( | |
1314 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
1315 "and a 'String' value is expected.", | |
1316 howToFix: "Did you forget to add quotes?", | |
1317 examples: const [ | |
1318 """ | |
1319 // 'Foo' is a type literal, not a string. | |
1320 @MirrorsUsed(symbols: const [Foo]) | |
1321 import 'dart:mirrors'; | |
1322 | |
1323 class Foo {} | |
1324 | |
1325 main() {} | |
1326 """]); | |
1327 | |
1328 static const MessageKind MIRRORS_EXPECTED_STRING_OR_TYPE = const MessageKind( | |
1329 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
1330 "and a 'String' or 'Type' value is expected.", | |
1331 howToFix: "Did you forget to add quotes?", | |
1332 examples: const [ | |
1333 """ | |
1334 // 'main' is a method, not a class. | |
1335 @MirrorsUsed(targets: const [main]) | |
1336 import 'dart:mirrors'; | |
1337 | |
1338 main() {} | |
1339 """]); | |
1340 | |
1341 static const MessageKind MIRRORS_EXPECTED_STRING_OR_LIST = const MessageKind( | |
1342 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
1343 "and a 'String' or 'List' value is expected.", | |
1344 howToFix: "Did you forget to add quotes?", | |
1345 examples: const [ | |
1346 """ | |
1347 // 'Foo' is not a string. | |
1348 @MirrorsUsed(symbols: Foo) | |
1349 import 'dart:mirrors'; | |
1350 | |
1351 class Foo {} | |
1352 | |
1353 main() {} | |
1354 """]); | |
1355 | |
1356 static const MessageKind MIRRORS_EXPECTED_STRING_TYPE_OR_LIST = | |
1357 const MessageKind( | |
1358 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
1359 "but a 'String', 'Type', or 'List' value is expected.", | |
1360 howToFix: "Did you forget to add quotes?", | |
1361 examples: const [ | |
1362 """ | |
1363 // '1' is not a string. | |
1364 @MirrorsUsed(targets: 1) | |
1365 import 'dart:mirrors'; | |
1366 | |
1367 main() {} | |
1368 """]); | |
1369 | |
1370 static const MessageKind MIRRORS_CANNOT_RESOLVE_IN_CURRENT_LIBRARY = | |
1371 const MessageKind( | |
1372 "Can't find '#{name}' in the current library.", | |
1373 // TODO(ahe): The closest identifiers in edit distance would be nice. | |
1374 howToFix: "Did you forget to add an import?", | |
1375 examples: const [ | |
1376 """ | |
1377 // 'window' is not in scope because dart:html isn't imported. | |
1378 @MirrorsUsed(targets: 'window') | |
1379 import 'dart:mirrors'; | |
1380 | |
1381 main() {} | |
1382 """]); | |
1383 | |
1384 static const MessageKind MIRRORS_CANNOT_RESOLVE_IN_LIBRARY = | |
1385 const MessageKind( | |
1386 "Can't find '#{name}' in the library '#{library}'.", | |
1387 // TODO(ahe): The closest identifiers in edit distance would be nice. | |
1388 howToFix: "Is '#{name}' spelled right?", | |
1389 examples: const [ | |
1390 """ | |
1391 // 'List' is misspelled. | |
1392 @MirrorsUsed(targets: 'dart.core.Lsit') | |
1393 import 'dart:mirrors'; | |
1394 | |
1395 main() {} | |
1396 """]); | |
1397 | |
1398 static const MessageKind MIRRORS_CANNOT_FIND_IN_ELEMENT = | |
1399 const MessageKind( | |
1400 "Can't find '#{name}' in '#{element}'.", | |
1401 // TODO(ahe): The closest identifiers in edit distance would be nice. | |
1402 howToFix: "Is '#{name}' spelled right?", | |
1403 examples: const [ | |
1404 """ | |
1405 // 'addAll' is misspelled. | |
1406 @MirrorsUsed(targets: 'dart.core.List.addAl') | |
1407 import 'dart:mirrors'; | |
1408 | |
1409 main() {} | |
1410 """]); | |
1411 | |
1412 static const MessageKind READ_SCRIPT_ERROR = const MessageKind( | |
1413 "Can't read '#{uri}' (#{exception}).", | |
1414 // Don't know how to fix since the underlying error is unknown. | |
1415 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1416 examples: const [ | |
1417 """ | |
1418 // 'foo.dart' does not exist. | |
1419 import 'foo.dart'; | |
1420 | |
1421 main() {} | |
1422 """]); | |
1423 | |
1424 static const MessageKind EXTRANEOUS_MODIFIER = const MessageKind( | |
1425 "Can't have modifier '#{modifier}' here.", | |
1426 howToFix: "Try removing '#{modifier}'.", | |
1427 examples: const [ | |
1428 "var String foo; main(){}", | |
1429 // "var get foo; main(){}", | |
1430 "var set foo; main(){}", | |
1431 "var final foo; main(){}", | |
1432 "var var foo; main(){}", | |
1433 "var const foo; main(){}", | |
1434 "var abstract foo; main(){}", | |
1435 "var static foo; main(){}", | |
1436 "var external foo; main(){}", | |
1437 "get var foo; main(){}", | |
1438 "set var foo; main(){}", | |
1439 "final var foo; main(){}", | |
1440 "var var foo; main(){}", | |
1441 "const var foo; main(){}", | |
1442 "abstract var foo; main(){}", | |
1443 "static var foo; main(){}", | |
1444 "external var foo; main(){}"]); | |
1445 | |
1446 static const MessageKind EXTRANEOUS_MODIFIER_REPLACE = const MessageKind( | |
1447 "Can't have modifier '#{modifier}' here.", | |
1448 howToFix: "Try replacing modifier '#{modifier}' with 'var', 'final'," | |
1449 " or a type.", | |
1450 examples: const [ | |
1451 // "get foo; main(){}", | |
1452 "set foo; main(){}", | |
1453 "abstract foo; main(){}", | |
1454 "static foo; main(){}", | |
1455 "external foo; main(){}"]); | |
1456 | |
1457 static const MessageKind ABSTRACT_CLASS_INSTANTIATION = const MessageKind( | |
1458 "Can't instantiate abstract class.", | |
1459 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1460 examples: const ["abstract class A {} main() { new A(); }"]); | |
1461 | |
1462 static const MessageKind BODY_EXPECTED = const MessageKind( | |
1463 "Expected a function body or '=>'.", | |
1464 // TODO(ahe): In some scenarios, we can suggest removing the 'static' | |
1465 // keyword. | |
1466 howToFix: "Try adding {}.", | |
1467 examples: const [ | |
1468 "main();"]); | |
1469 | |
1470 static const MessageKind MIRROR_BLOAT = const MessageKind( | |
1471 "#{count} methods retained for use by dart:mirrors out of #{total}" | |
1472 " total methods (#{percentage}%)."); | |
1473 | |
1474 static const MessageKind MIRROR_IMPORT = const MessageKind( | |
1475 "Import of 'dart:mirrors'."); | |
1476 | |
1477 static const MessageKind MIRROR_IMPORT_NO_USAGE = const MessageKind( | |
1478 "This import is not annotated with @MirrorsUsed, which may lead to " | |
1479 "unnecessarily large generated code.", | |
1480 howToFix: | |
1481 "Try adding '@MirrorsUsed(...)' as described at " | |
1482 "https://goo.gl/Akrrog."); | |
1483 | |
1484 static const MessageKind WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT = | |
1485 const MessageKind( | |
1486 "Argument for 'JS_INTERCEPTOR_CONSTANT' must be a type constant."); | |
1487 | |
1488 static const MessageKind EXPECTED_IDENTIFIER_NOT_RESERVED_WORD = | |
1489 const MessageKind( | |
1490 "'#{keyword}' is a reserved word and can't be used here.", | |
1491 howToFix: "Try using a different name.", | |
1492 examples: const ["do() {} main() {}"]); | |
1493 | |
1494 static const MessageKind NAMED_FUNCTION_EXPRESSION = | |
1495 const MessageKind("Function expression '#{name}' cannot be named.", | |
1496 howToFix: "Try removing the name.", | |
1497 examples: const ["main() { var f = func() {}; }"]); | |
1498 | |
1499 static const MessageKind UNUSED_METHOD = const MessageKind( | |
1500 "The method '#{name}' is never called.", | |
1501 howToFix: "Consider deleting it.", | |
1502 examples: const ["deadCode() {} main() {}"]); | |
1503 | |
1504 static const MessageKind UNUSED_CLASS = const MessageKind( | |
1505 "The class '#{name}' is never used.", | |
1506 howToFix: "Consider deleting it.", | |
1507 examples: const ["class DeadCode {} main() {}"]); | |
1508 | |
1509 static const MessageKind UNUSED_TYPEDEF = const MessageKind( | |
1510 "The typedef '#{name}' is never used.", | |
1511 howToFix: "Consider deleting it.", | |
1512 examples: const ["typedef DeadCode(); main() {}"]); | |
1513 | |
1514 static const MessageKind ABSTRACT_METHOD = const MessageKind( | |
1515 "The method '#{name}' has no implementation in " | |
1516 "class '#{class}'.", | |
1517 howToFix: "Try adding a body to '#{name}' or declaring " | |
1518 "'#{class}' to be 'abstract'.", | |
1519 examples: const [""" | |
1520 class Class { | |
1521 method(); | |
1522 } | |
1523 main() => new Class().method(); | |
1524 """]); | |
1525 | |
1526 static const MessageKind ABSTRACT_GETTER = const MessageKind( | |
1527 "The getter '#{name}' has no implementation in " | |
1528 "class '#{class}'.", | |
1529 howToFix: "Try adding a body to '#{name}' or declaring " | |
1530 "'#{class}' to be 'abstract'.", | |
1531 examples: const [""" | |
1532 class Class { | |
1533 get getter; | |
1534 } | |
1535 main() => new Class(); | |
1536 """]); | |
1537 | |
1538 static const MessageKind ABSTRACT_SETTER = const MessageKind( | |
1539 "The setter '#{name}' has no implementation in " | |
1540 "class '#{class}'.", | |
1541 howToFix: "Try adding a body to '#{name}' or declaring " | |
1542 "'#{class}' to be 'abstract'.", | |
1543 examples: const [""" | |
1544 class Class { | |
1545 set setter(_); | |
1546 } | |
1547 main() => new Class(); | |
1548 """]); | |
1549 | |
1550 static const MessageKind INHERIT_GETTER_AND_METHOD = const MessageKind( | |
1551 "The class '#{class}' can't inherit both getters and methods " | |
1552 "by the named '#{name}'.", | |
1553 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1554 examples: const [""" | |
1555 class A { | |
1556 get member => null; | |
1557 } | |
1558 class B { | |
1559 member() {} | |
1560 } | |
1561 class Class implements A, B { | |
1562 } | |
1563 main() => new Class(); | |
1564 """]); | |
1565 | |
1566 static const MessageKind INHERITED_METHOD = const MessageKind( | |
1567 "The inherited method '#{name}' is declared here in class " | |
1568 "'#{class}'."); | |
1569 | |
1570 static const MessageKind INHERITED_EXPLICIT_GETTER = const MessageKind( | |
1571 "The inherited getter '#{name}' is declared here in class " | |
1572 "'#{class}'."); | |
1573 | |
1574 static const MessageKind INHERITED_IMPLICIT_GETTER = const MessageKind( | |
1575 "The inherited getter '#{name}' is implicitly declared by this " | |
1576 "field in class '#{class}'."); | |
1577 | |
1578 static const MessageKind UNIMPLEMENTED_METHOD_ONE = const MessageKind( | |
1579 "'#{class}' doesn't implement '#{method}' " | |
1580 "declared in '#{declarer}'.", | |
1581 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1582 "'#{class}' to be 'abstract'.", | |
1583 examples: const [""" | |
1584 abstract class I { | |
1585 m(); | |
1586 } | |
1587 class C implements I {} | |
1588 main() => new C(); | |
1589 """, """ | |
1590 abstract class I { | |
1591 m(); | |
1592 } | |
1593 class C extends I {} | |
1594 main() => new C(); | |
1595 """]); | |
1596 | |
1597 static const MessageKind UNIMPLEMENTED_METHOD = const MessageKind( | |
1598 "'#{class}' doesn't implement '#{method}'.", | |
1599 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1600 "'#{class}' to be 'abstract'.", | |
1601 examples: const [""" | |
1602 abstract class I { | |
1603 m(); | |
1604 } | |
1605 | |
1606 abstract class J { | |
1607 m(); | |
1608 } | |
1609 | |
1610 class C implements I, J {} | |
1611 | |
1612 main() { | |
1613 new C(); | |
1614 } | |
1615 """, """ | |
1616 abstract class I { | |
1617 m(); | |
1618 } | |
1619 | |
1620 abstract class J { | |
1621 m(); | |
1622 } | |
1623 | |
1624 class C extends I implements J {} | |
1625 | |
1626 main() { | |
1627 new C(); | |
1628 } | |
1629 """]); | |
1630 | |
1631 static const MessageKind UNIMPLEMENTED_METHOD_CONT = const MessageKind( | |
1632 "The method '#{name}' is declared here in class '#{class}'."); | |
1633 | |
1634 static const MessageKind UNIMPLEMENTED_SETTER_ONE = const MessageKind( | |
1635 "'#{class}' doesn't implement the setter '#{name}' " | |
1636 "declared in '#{declarer}'.", | |
1637 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1638 "'#{class}' to be 'abstract'.", | |
1639 examples: const [""" | |
1640 abstract class I { | |
1641 set m(_); | |
1642 } | |
1643 class C implements I {} | |
1644 class D implements I { | |
1645 set m(_) {} | |
1646 } | |
1647 main() { | |
1648 new D().m = 0; | |
1649 new C(); | |
1650 } | |
1651 """]); | |
1652 | |
1653 static const MessageKind UNIMPLEMENTED_SETTER = const MessageKind( | |
1654 "'#{class}' doesn't implement the setter '#{name}'.", | |
1655 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1656 "'#{class}' to be 'abstract'.", | |
1657 examples: const [""" | |
1658 abstract class I { | |
1659 set m(_); | |
1660 } | |
1661 abstract class J { | |
1662 set m(_); | |
1663 } | |
1664 class C implements I, J {} | |
1665 main() => new C(); | |
1666 """, """ | |
1667 abstract class I { | |
1668 set m(_); | |
1669 } | |
1670 abstract class J { | |
1671 set m(_); | |
1672 } | |
1673 class C extends I implements J {} | |
1674 main() => new C(); | |
1675 """]); | |
1676 | |
1677 static const MessageKind UNIMPLEMENTED_EXPLICIT_SETTER = const MessageKind( | |
1678 "The setter '#{name}' is declared here in class '#{class}'."); | |
1679 | |
1680 static const MessageKind UNIMPLEMENTED_IMPLICIT_SETTER = const MessageKind( | |
1681 "The setter '#{name}' is implicitly declared by this field " | |
1682 "in class '#{class}'."); | |
1683 | |
1684 static const MessageKind UNIMPLEMENTED_GETTER_ONE = const MessageKind( | |
1685 "'#{class}' doesn't implement the getter '#{name}' " | |
1686 "declared in '#{declarer}'.", | |
1687 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1688 "'#{class}' to be 'abstract'.", | |
1689 examples: const [""" | |
1690 abstract class I { | |
1691 get m; | |
1692 } | |
1693 class C implements I {} | |
1694 main() => new C(); | |
1695 """, """ | |
1696 abstract class I { | |
1697 get m; | |
1698 } | |
1699 class C extends I {} | |
1700 main() => new C(); | |
1701 """]); | |
1702 | |
1703 static const MessageKind UNIMPLEMENTED_GETTER = const MessageKind( | |
1704 "'#{class}' doesn't implement the getter '#{name}'.", | |
1705 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1706 "'#{class}' to be 'abstract'.", | |
1707 examples: const [""" | |
1708 abstract class I { | |
1709 get m; | |
1710 } | |
1711 abstract class J { | |
1712 get m; | |
1713 } | |
1714 class C implements I, J {} | |
1715 main() => new C(); | |
1716 """, """ | |
1717 abstract class I { | |
1718 get m; | |
1719 } | |
1720 abstract class J { | |
1721 get m; | |
1722 } | |
1723 class C extends I implements J {} | |
1724 main() => new C(); | |
1725 """]); | |
1726 | |
1727 static const MessageKind UNIMPLEMENTED_EXPLICIT_GETTER = const MessageKind( | |
1728 "The getter '#{name}' is declared here in class '#{class}'."); | |
1729 | |
1730 static const MessageKind UNIMPLEMENTED_IMPLICIT_GETTER = const MessageKind( | |
1731 "The getter '#{name}' is implicitly declared by this field " | |
1732 "in class '#{class}'."); | |
1733 | |
1734 static const MessageKind EQUAL_MAP_ENTRY_KEY = const MessageKind( | |
1735 "An entry with the same key already exists in the map.", | |
1736 howToFix: "Try removing the previous entry or changing the key in one " | |
1737 "of the entries.", | |
1738 examples: const [""" | |
1739 main() { | |
1740 var m = const {'foo': 1, 'foo': 2}; | |
1741 }"""]); | |
1742 | |
1743 static const MessageKind BAD_INPUT_CHARACTER = const MessageKind( | |
1744 "Character U+#{characterHex} isn't allowed here.", | |
1745 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1746 examples: const [""" | |
1747 main() { | |
1748 String x = ç; | |
1749 } | |
1750 """]); | |
1751 | |
1752 static const MessageKind UNTERMINATED_STRING = const MessageKind( | |
1753 "String must end with #{quote}.", | |
1754 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1755 examples: const [""" | |
1756 main() { | |
1757 return ' | |
1758 ; | |
1759 } | |
1760 """, | |
1761 """ | |
1762 main() { | |
1763 return \" | |
1764 ; | |
1765 } | |
1766 """, | |
1767 """ | |
1768 main() { | |
1769 return r' | |
1770 ; | |
1771 } | |
1772 """, | |
1773 """ | |
1774 main() { | |
1775 return r\" | |
1776 ; | |
1777 } | |
1778 """, | |
1779 """ | |
1780 main() => ''' | |
1781 """, | |
1782 """ | |
1783 main() => \"\"\" | |
1784 """, | |
1785 """ | |
1786 main() => r''' | |
1787 """, | |
1788 """ | |
1789 main() => r\"\"\" | |
1790 """]); | |
1791 | |
1792 static const MessageKind UNMATCHED_TOKEN = const MessageKind( | |
1793 "Can't find '#{end}' to match '#{begin}'.", | |
1794 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1795 examples: const[ | |
1796 "main(", | |
1797 "main(){", | |
1798 "main(){]}", | |
1799 ]); | |
1800 | |
1801 static const MessageKind UNTERMINATED_TOKEN = const MessageKind( | |
1802 // This is a fall-back message that shouldn't happen. | |
1803 "Incomplete token."); | |
1804 | |
1805 static const MessageKind EXPONENT_MISSING = const MessageKind( | |
1806 "Numbers in exponential notation should always contain an exponent" | |
1807 " (an integer number with an optional sign).", | |
1808 howToFix: "Make sure there is an exponent, and remove any whitespace " | |
1809 "before it.", | |
1810 examples: const [""" | |
1811 main() { | |
1812 var i = 1e; | |
1813 } | |
1814 """]); | |
1815 | |
1816 static const MessageKind HEX_DIGIT_EXPECTED = const MessageKind( | |
1817 "A hex digit (0-9 or A-F) must follow '0x'.", | |
1818 howToFix: DONT_KNOW_HOW_TO_FIX, // Seems obvious from the error message. | |
1819 examples: const [""" | |
1820 main() { | |
1821 var i = 0x; | |
1822 } | |
1823 """]); | |
1824 | |
1825 static const MessageKind MALFORMED_STRING_LITERAL = const MessageKind( | |
1826 r"A '$' has special meaning inside a string, and must be followed by an" | |
1827 " identifier or an expression in curly braces ({}).", | |
1828 howToFix: r"Try adding a backslash (\) to escape the '$'.", | |
1829 examples: const [r""" | |
1830 main() { | |
1831 return '$'; | |
1832 } | |
1833 """, | |
1834 r''' | |
1835 main() { | |
1836 return "$"; | |
1837 } | |
1838 ''', | |
1839 r""" | |
1840 main() { | |
1841 return '''$'''; | |
1842 } | |
1843 """, | |
1844 r''' | |
1845 main() { | |
1846 return """$"""; | |
1847 } | |
1848 ''']); | |
1849 | |
1850 static const MessageKind UNTERMINATED_COMMENT = const MessageKind( | |
1851 "Comment starting with '/*' must end with '*/'.", | |
1852 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1853 examples: const [r""" | |
1854 main() { | |
1855 } | |
1856 /*"""]); | |
1857 | |
1858 static const MessageKind MISSING_TOKEN_BEFORE_THIS = const MessageKind( | |
1859 "Expected '#{token}' before this.", | |
1860 // Consider the second example below: the parser expects a ')' before | |
1861 // 'y', but a ',' would also have worked. We don't have enough | |
1862 // information to give a good suggestion. | |
1863 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1864 examples: const [ | |
1865 "main() => true ? 1;", | |
1866 "main() => foo(x: 1 y: 2);", | |
1867 ]); | |
1868 | |
1869 static const MessageKind MISSING_TOKEN_AFTER_THIS = const MessageKind( | |
1870 "Expected '#{token}' after this.", | |
1871 // See [MISSING_TOKEN_BEFORE_THIS], we don't have enough information to | |
1872 // give a good suggestion. | |
1873 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1874 examples: const [ | |
1875 "main(x) {x}", | |
1876 """ | |
1877 class S1 {} | |
1878 class S2 {} | |
1879 class S3 {} | |
1880 class A = S1 with S2, S3 | |
1881 main() => new A(); | |
1882 """ | |
1883 ]); | |
1884 | |
1885 static const MessageKind CONSIDER_ANALYZE_ALL = const MessageKind( | |
1886 "Could not find '#{main}'. Nothing will be analyzed.", | |
1887 howToFix: "Try using '--analyze-all' to analyze everything.", | |
1888 examples: const ['']); | |
1889 | |
1890 static const MessageKind MISSING_MAIN = const MessageKind( | |
1891 "Could not find '#{main}'.", | |
1892 howToFix: "Try adding a method named '#{main}' to your program." | |
1893 /* No example, test uses '--analyze-only' which will produce the above | |
1894 * message [CONSIDER_ANALYZE_ALL]. An example for a human operator would | |
1895 * be an empty file. */); | |
1896 | |
1897 static const MessageKind MAIN_NOT_A_FUNCTION = const MessageKind( | |
1898 "'#{main}' is not a function.", | |
1899 howToFix: DONT_KNOW_HOW_TO_FIX, /* Don't state the obvious. */ | |
1900 examples: const ['var main;']); | |
1901 | |
1902 static const MessageKind MAIN_WITH_EXTRA_PARAMETER = const MessageKind( | |
1903 "'#{main}' cannot have more than two parameters.", | |
1904 howToFix: DONT_KNOW_HOW_TO_FIX, /* Don't state the obvious. */ | |
1905 examples: const ['main(a, b, c) {}']); | |
1906 | |
1907 static const MessageKind COMPILER_CRASHED = const MessageKind( | |
1908 "The compiler crashed when compiling this element."); | |
1909 | |
1910 static const MessageKind PLEASE_REPORT_THE_CRASH = const MessageKind(''' | |
1911 The compiler is broken. | |
1912 | |
1913 When compiling the above element, the compiler crashed. It is not | |
1914 possible to tell if this is caused by a problem in your program or | |
1915 not. Regardless, the compiler should not crash. | |
1916 | |
1917 The Dart team would greatly appreciate if you would take a moment to | |
1918 report this problem at http://dartbug.com/new. | |
1919 | |
1920 Please include the following information: | |
1921 | |
1922 * the name and version of your operating system, | |
1923 | |
1924 * the Dart SDK build number (#{buildId}), and | |
1925 | |
1926 * the entire message you see here (including the full stack trace | |
1927 below as well as the source location above). | |
1928 '''); | |
1929 | |
1930 static const MessageKind POTENTIAL_MUTATION = const MessageKind( | |
1931 "Variable '#{variableName}' is not known to be of type " | |
1932 "'#{shownType}' because it is potentially mutated in the scope for " | |
1933 "promotion."); | |
1934 | |
1935 static const MessageKind POTENTIAL_MUTATION_HERE = const MessageKind( | |
1936 "Variable '#{variableName}' is potentially mutated here."); | |
1937 | |
1938 static const MessageKind POTENTIAL_MUTATION_IN_CLOSURE = const MessageKind( | |
1939 "Variable '#{variableName}' is not known to be of type " | |
1940 "'#{shownType}' because it is potentially mutated within a closure."); | |
1941 | |
1942 static const MessageKind POTENTIAL_MUTATION_IN_CLOSURE_HERE = | |
1943 const MessageKind( | |
1944 "Variable '#{variableName}' is potentially mutated in a " | |
1945 "closure here."); | |
1946 | |
1947 static const MessageKind ACCESSED_IN_CLOSURE = const MessageKind( | |
1948 "Variable '#{variableName}' is not known to be of type " | |
1949 "'#{shownType}' because it is accessed by a closure in the scope for " | |
1950 "promotion and potentially mutated in the scope of '#{variableName}'."); | |
1951 | |
1952 static const MessageKind ACCESSED_IN_CLOSURE_HERE = const MessageKind( | |
1953 "Variable '#{variableName}' is accessed in a closure here."); | |
1954 | |
1955 static const MessageKind NOT_MORE_SPECIFIC = const MessageKind( | |
1956 "Variable '#{variableName}' is not shown to have type " | |
1957 "'#{shownType}' because '#{shownType}' is not more specific than the " | |
1958 "known type '#{knownType}' of '#{variableName}'."); | |
1959 | |
1960 static const MessageKind NOT_MORE_SPECIFIC_SUBTYPE = const MessageKind( | |
1961 "Variable '#{variableName}' is not shown to have type " | |
1962 "'#{shownType}' because '#{shownType}' is not a subtype of the " | |
1963 "known type '#{knownType}' of '#{variableName}'."); | |
1964 | |
1965 static const MessageKind NOT_MORE_SPECIFIC_SUGGESTION = const MessageKind( | |
1966 "Variable '#{variableName}' is not shown to have type " | |
1967 "'#{shownType}' because '#{shownType}' is not more specific than the " | |
1968 "known type '#{knownType}' of '#{variableName}'.", | |
1969 howToFix: "Try replacing '#{shownType}' with '#{shownTypeSuggestion}'."); | |
1970 | |
1971 static const MessageKind HIDDEN_WARNINGS_HINTS = const MessageKind( | |
1972 "#{warnings} warning(s) and #{hints} hint(s) suppressed in #{uri}."); | |
1973 | |
1974 static const MessageKind HIDDEN_WARNINGS = const MessageKind( | |
1975 "#{warnings} warning(s) suppressed in #{uri}."); | |
1976 | |
1977 static const MessageKind HIDDEN_HINTS = const MessageKind( | |
1978 "#{hints} hint(s) suppressed in #{uri}."); | |
1979 | |
1980 static const MessageKind PREAMBLE = const MessageKind( | |
1981 "When run on the command-line, the compiled output might" | |
1982 " require a preamble file located in:\n" | |
1983 " <sdk>/lib/_internal/compiler/js_lib/preambles."); | |
1984 | |
1985 | |
1986 static const MessageKind EXPERIMENTAL_ASYNC_AWAIT = const MessageKind( | |
1987 "Experimental language feature 'async/await' is not supported."); | |
1988 | |
1989 static const MessageKind INVALID_STARRED_KEYWORD = const MessageKind( | |
1990 "Invalid '#{keyword}' keyword.", | |
1991 options: const ['--enable-async'], | |
1992 howToFix: "Try removing whitespace between '#{keyword}' and '*'.", | |
1993 examples: const [ | |
1994 "main() async * {}", | |
1995 "main() sync * {}", | |
1996 "main() async* { yield * 0; }" | |
1997 ]); | |
1998 | |
1999 static const MessageKind INVALID_SYNC_MODIFIER = const MessageKind( | |
2000 "Invalid modifier 'sync'.", | |
2001 options: const ['--enable-async'], | |
2002 howToFix: "Try replacing 'sync' with 'sync*'.", | |
2003 examples: const [ | |
2004 "main() sync {}" | |
2005 ]); | |
2006 | |
2007 static const MessageKind INVALID_AWAIT_FOR = const MessageKind( | |
2008 "'await' is only supported on for-in loops.", | |
2009 options: const ['--enable-async'], | |
2010 howToFix: "Try rewriting the loop as a for-in loop or removing the " | |
2011 "'await' keyword.", | |
2012 examples: const [""" | |
2013 main() async* { | |
2014 await for (int i = 0; i < 10; i++) {} | |
2015 } | |
2016 """]); | |
2017 | |
2018 static const MessageKind ASYNC_MODIFIER_ON_ABSTRACT_METHOD = | |
2019 const MessageKind( | |
2020 "The modifier '#{modifier}' is not allowed on an abstract method.", | |
2021 options: const ['--enable-async'], | |
2022 howToFix: "Try removing the '#{modifier}' modifier or adding a " | |
2023 "body to the method.", | |
2024 examples: const [""" | |
2025 abstract class A { | |
2026 method() async; | |
2027 } | |
2028 class B extends A { | |
2029 method() {} | |
2030 } | |
2031 main() { | |
2032 A a = new B(); | |
2033 a.method(); | |
2034 } | |
2035 """]); | |
2036 | |
2037 static const MessageKind ASYNC_MODIFIER_ON_CONSTRUCTOR = | |
2038 const MessageKind( | |
2039 "The modifier '#{modifier}' is not allowed on constructors.", | |
2040 options: const ['--enable-async'], | |
2041 howToFix: "Try removing the '#{modifier}' modifier.", | |
2042 examples: const [""" | |
2043 class A { | |
2044 A() async; | |
2045 } | |
2046 main() => new A();""", | |
2047 | |
2048 """ | |
2049 class A { | |
2050 A(); | |
2051 factory A.a() async* => new A(); | |
2052 } | |
2053 main() => new A.a();"""]); | |
2054 | |
2055 static const MessageKind YIELDING_MODIFIER_ON_ARROW_BODY = | |
2056 const MessageKind( | |
2057 "The modifier '#{modifier}' is not allowed on methods implemented " | |
2058 "using '=>'.", | |
2059 options: const ['--enable-async'], | |
2060 howToFix: "Try removing the '#{modifier}' modifier or implementing " | |
2061 "the method body using a block: '{ ... }'.", | |
2062 examples: const ["main() sync* => null;", "main() async* => null;"]); | |
2063 | |
2064 // TODO(johnniwinther): Check for 'async' as identifier. | |
2065 static const MessageKind ASYNC_KEYWORD_AS_IDENTIFIER = const MessageKind( | |
2066 "'#{keyword}' cannot be used as an identifier in a function body marked " | |
2067 "with '#{modifier}'.", | |
2068 options: const ['--enable-async'], | |
2069 howToFix: "Try removing the '#{modifier}' modifier or renaming the " | |
2070 "identifier.", | |
2071 examples: const [""" | |
2072 main() async { | |
2073 var await; | |
2074 }""", | |
2075 """ | |
2076 main() async* { | |
2077 var yield; | |
2078 }""", | |
2079 """ | |
2080 main() sync* { | |
2081 var yield; | |
2082 }"""]); | |
2083 | |
2084 ////////////////////////////////////////////////////////////////////////////// | |
2085 // Patch errors start. | |
2086 ////////////////////////////////////////////////////////////////////////////// | |
2087 | |
2088 static const MessageKind PATCH_RETURN_TYPE_MISMATCH = const MessageKind( | |
2089 "Patch return type '#{patchReturnType}' does not match " | |
2090 "'#{originReturnType}' on origin method '#{methodName}'."); | |
2091 | |
2092 static const MessageKind PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH = | |
2093 const MessageKind( | |
2094 "Required parameter count of patch method " | |
2095 "(#{patchParameterCount}) does not match parameter count on origin " | |
2096 "method '#{methodName}' (#{originParameterCount})."); | |
2097 | |
2098 static const MessageKind PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH = | |
2099 const MessageKind( | |
2100 "Optional parameter count of patch method " | |
2101 "(#{patchParameterCount}) does not match parameter count on origin " | |
2102 "method '#{methodName}' (#{originParameterCount})."); | |
2103 | |
2104 static const MessageKind PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH = | |
2105 const MessageKind( | |
2106 "Optional parameters of origin and patch method " | |
2107 "'#{methodName}' must both be either named or positional."); | |
2108 | |
2109 static const MessageKind PATCH_PARAMETER_MISMATCH = const MessageKind( | |
2110 "Patch method parameter '#{patchParameter}' does not match " | |
2111 "'#{originParameter}' on origin method '#{methodName}'."); | |
2112 | |
2113 static const MessageKind PATCH_PARAMETER_TYPE_MISMATCH = const MessageKind( | |
2114 "Patch method parameter '#{parameterName}' type " | |
2115 "'#{patchParameterType}' does not match '#{originParameterType}' on " | |
2116 "origin method '#{methodName}'."); | |
2117 | |
2118 static const MessageKind PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION = | |
2119 const MessageKind("External method without an implementation."); | |
2120 | |
2121 static const MessageKind PATCH_POINT_TO_FUNCTION = const MessageKind( | |
2122 "This is the function patch '#{functionName}'."); | |
2123 | |
2124 static const MessageKind PATCH_POINT_TO_CLASS = const MessageKind( | |
2125 "This is the class patch '#{className}'."); | |
2126 | |
2127 static const MessageKind PATCH_POINT_TO_GETTER = const MessageKind( | |
2128 "This is the getter patch '#{getterName}'."); | |
2129 | |
2130 static const MessageKind PATCH_POINT_TO_SETTER = const MessageKind( | |
2131 "This is the setter patch '#{setterName}'."); | |
2132 | |
2133 static const MessageKind PATCH_POINT_TO_CONSTRUCTOR = const MessageKind( | |
2134 "This is the constructor patch '#{constructorName}'."); | |
2135 | |
2136 static const MessageKind PATCH_POINT_TO_PARAMETER = const MessageKind( | |
2137 "This is the patch parameter '#{parameterName}'."); | |
2138 | |
2139 static const MessageKind PATCH_NON_EXISTING = const MessageKind( | |
2140 "Origin does not exist for patch '#{name}'."); | |
2141 | |
2142 // TODO(ahe): Eventually, this error should be removed as it will be handled | |
2143 // by the regular parser. | |
2144 static const MessageKind PATCH_NONPATCHABLE = const MessageKind( | |
2145 "Only classes and functions can be patched."); | |
2146 | |
2147 static const MessageKind PATCH_NON_EXTERNAL = const MessageKind( | |
2148 "Only external functions can be patched."); | |
2149 | |
2150 static const MessageKind PATCH_NON_CLASS = const MessageKind( | |
2151 "Patching non-class with class patch '#{className}'."); | |
2152 | |
2153 static const MessageKind PATCH_NON_GETTER = const MessageKind( | |
2154 "Cannot patch non-getter '#{name}' with getter patch."); | |
2155 | |
2156 static const MessageKind PATCH_NO_GETTER = const MessageKind( | |
2157 "No getter found for getter patch '#{getterName}'."); | |
2158 | |
2159 static const MessageKind PATCH_NON_SETTER = const MessageKind( | |
2160 "Cannot patch non-setter '#{name}' with setter patch."); | |
2161 | |
2162 static const MessageKind PATCH_NO_SETTER = const MessageKind( | |
2163 "No setter found for setter patch '#{setterName}'."); | |
2164 | |
2165 static const MessageKind PATCH_NON_CONSTRUCTOR = const MessageKind( | |
2166 "Cannot patch non-constructor with constructor patch " | |
2167 "'#{constructorName}'."); | |
2168 | |
2169 static const MessageKind PATCH_NON_FUNCTION = const MessageKind( | |
2170 "Cannot patch non-function with function patch " | |
2171 "'#{functionName}'."); | |
2172 | |
2173 ////////////////////////////////////////////////////////////////////////////// | |
2174 // Patch errors end. | |
2175 ////////////////////////////////////////////////////////////////////////////// | |
2176 | |
2177 static const MessageKind CALL_NOT_SUPPORTED_ON_NATIVE_CLASS = | |
2178 const MessageKind( | |
2179 "Non-supported 'call' member on a native class, or a " | |
2180 "subclass of a native class."); | |
2181 | |
2182 toString() => template; | |
2183 | |
2184 Message message([Map arguments = const {}, bool terse = false]) { | |
2185 return new Message(this, arguments, terse); | |
2186 } | |
2187 | |
2188 bool get hasHowToFix => howToFix != null && howToFix != DONT_KNOW_HOW_TO_FIX; | |
2189 } | |
2190 | |
2191 class Message { | |
2192 final MessageKind kind; | |
2193 final Map arguments; | |
2194 final bool terse; | |
2195 String message; | |
2196 | |
2197 Message(this.kind, this.arguments, this.terse) { | |
2198 assert(() { computeMessage(); return true; }); | |
2199 } | |
2200 | |
2201 String computeMessage() { | |
2202 if (message == null) { | |
2203 message = kind.template; | |
2204 arguments.forEach((key, value) { | |
2205 message = message.replaceAll('#{${key}}', convertToString(value)); | |
2206 }); | |
2207 assert(invariant( | |
2208 CURRENT_ELEMENT_SPANNABLE, | |
2209 kind == MessageKind.GENERIC || | |
2210 !message.contains(new RegExp(r'#\{.+\}')), | |
2211 message: 'Missing arguments in error message: "$message"')); | |
2212 if (!terse && kind.hasHowToFix) { | |
2213 String howToFix = kind.howToFix; | |
2214 arguments.forEach((key, value) { | |
2215 howToFix = howToFix.replaceAll('#{${key}}', convertToString(value)); | |
2216 }); | |
2217 message = '$message\n$howToFix'; | |
2218 } | |
2219 } | |
2220 return message; | |
2221 } | |
2222 | |
2223 String toString() { | |
2224 return computeMessage(); | |
2225 } | |
2226 | |
2227 bool operator==(other) { | |
2228 if (other is !Message) return false; | |
2229 return (kind == other.kind) && (toString() == other.toString()); | |
2230 } | |
2231 | |
2232 int get hashCode => throw new UnsupportedError('Message.hashCode'); | |
2233 | |
2234 static String convertToString(value) { | |
2235 if (value is ErrorToken) { | |
2236 // Shouldn't happen. | |
2237 return value.assertionMessage; | |
2238 } else if (value is Token) { | |
2239 value = value.value; | |
2240 } | |
2241 return '$value'; | |
2242 } | |
2243 } | |
OLD | NEW |