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

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

Powered by Google App Engine
This is Rietveld 408576698