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