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

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

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

Powered by Google App Engine
This is Rietveld 408576698