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