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

Side by Side Diff: pkg/compiler/lib/src/diagnostics/messages.dart

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

Powered by Google App Engine
This is Rietveld 408576698