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