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