OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 const DONT_KNOW_HOW_TO_FIX = ""; | 7 const DONT_KNOW_HOW_TO_FIX = ""; |
8 | 8 |
9 /** | 9 /** |
10 * The messages in this file should meet the following guide lines: | 10 * The messages in this file should meet the following guide lines: |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
858 "Error: A setter must have exactly one argument."); | 858 "Error: A setter must have exactly one argument."); |
859 | 859 |
860 static const MessageKind NO_STATIC_OVERRIDE = const MessageKind( | 860 static const MessageKind NO_STATIC_OVERRIDE = const MessageKind( |
861 "Error: Static member cannot override instance member '#{memberName}' of " | 861 "Error: Static member cannot override instance member '#{memberName}' of " |
862 "'#{className}'."); | 862 "'#{className}'."); |
863 | 863 |
864 static const MessageKind NO_STATIC_OVERRIDE_CONT = const MessageKind( | 864 static const MessageKind NO_STATIC_OVERRIDE_CONT = const MessageKind( |
865 "Info: This is the instance member that cannot be overridden " | 865 "Info: This is the instance member that cannot be overridden " |
866 "by a static member."); | 866 "by a static member."); |
867 | 867 |
868 static const MessageKind INSTANCE_STATIC_SAME_NAME = const MessageKind( | |
869 "Warning: Instance member '#{memberName}' and static member of " | |
870 "superclass '#{className}' have the same name."); | |
871 | |
872 static const MessageKind INSTANCE_STATIC_SAME_NAME_CONT = const MessageKind( | |
873 "Info: This is the static member with the same name."); | |
874 | |
875 static const MessageKind INVALID_OVERRIDE_METHOD = const MessageKind( | |
876 "Warning: The type '#{declaredType}' of method '#{name}' declared in " | |
877 "'#{class}' is not a subtype of the overridden method type " | |
878 "'#{inheritedType}' inherited from '#{inheritedClass}'."); | |
879 | |
880 static const MessageKind INVALID_OVERRIDDEN_METHOD = const MessageKind( | |
881 "Info: This is the overridden method '#{name}' declared in class " | |
882 "'#{class}'."); | |
883 | |
884 static const MessageKind INVALID_OVERRIDE_GETTER = const MessageKind( | |
885 "Warning: The type '#{declaredType}' of getter '#{name}' declared in " | |
886 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
887 "overridden getter inherited from '#{inheritedClass}'."); | |
888 | |
889 static const MessageKind INVALID_OVERRIDDEN_GETTER = const MessageKind( | |
890 "Info: This is the overridden getter '#{name}' declared in class " | |
891 "'#{class}'."); | |
892 | |
893 static const MessageKind INVALID_OVERRIDE_GETTER_WITH_FIELD = | |
894 const MessageKind( | |
895 "Warning: The type '#{declaredType}' of field '#{name}' declared in " | |
896 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
897 "overridden getter inherited from '#{inheritedClass}'."); | |
898 | |
899 static const MessageKind INVALID_OVERRIDE_FIELD_WITH_GETTER = | |
900 const MessageKind( | |
901 "Warning: The type '#{declaredType}' of getter '#{name}' declared in " | |
902 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
903 "overridden field inherited from '#{inheritedClass}'."); | |
904 | |
905 static const MessageKind INVALID_OVERRIDE_SETTER = const MessageKind( | |
906 "Warning: The type '#{declaredType}' of setter '#{name}' declared in " | |
907 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
908 "overridden setter inherited from '#{inheritedClass}'."); | |
909 | |
910 static const MessageKind INVALID_OVERRIDDEN_SETTER = const MessageKind( | |
911 "Info: This is the overridden setter '#{name}' declared in class " | |
912 "'#{class}'."); | |
913 | |
914 static const MessageKind INVALID_OVERRIDE_SETTER_WITH_FIELD = | |
915 const MessageKind( | |
916 "Warning: The type '#{declaredType}' of field '#{name}' declared in " | |
917 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
918 "overridden setter inherited from '#{inheritedClass}'."); | |
919 | |
920 static const MessageKind INVALID_OVERRIDE_FIELD_WITH_SETTER = | |
921 const MessageKind( | |
922 "Warning: The type '#{declaredType}' of setter '#{name}' declared in " | |
923 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
924 "overridden field inherited from '#{inheritedClass}'."); | |
925 | |
926 static const MessageKind INVALID_OVERRIDE_FIELD = const MessageKind( | |
927 "Warning: The type '#{declaredType}' of field '#{name}' declared in " | |
928 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
929 "overridden field inherited from '#{inheritedClass}'."); | |
930 | |
931 static const MessageKind INVALID_OVERRIDDEN_FIELD = const MessageKind( | |
932 "Info: This is the overridden field '#{name}' declared in class " | |
933 "'#{class}'."); | |
934 | |
868 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD = | 935 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD = |
869 const MessageKind( | 936 const MessageKind( |
870 "Error: Method cannot override field '#{memberName}' of " | 937 "Error: Method '#{name}' in '#{class}' can't override field from " |
871 "'#{className}'."); | 938 "'#{inheritedClass}'."); |
872 | 939 |
873 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT = | 940 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT = |
874 const MessageKind( | 941 const MessageKind( |
875 "Info: This is the field that cannot be overridden by a method."); | 942 "Info: This is the field that cannot be overridden by a method."); |
876 | 943 |
877 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD = | 944 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD = |
878 const MessageKind( | 945 const MessageKind( |
879 "Error: Field cannot override method '#{memberName}' of " | 946 "Error: Field '#{name}' in '#{class}' can't override method from " |
880 "'#{className}'."); | 947 "'#{inheritedClass}'."); |
881 | 948 |
882 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT = | 949 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT = |
883 const MessageKind( | 950 const MessageKind( |
884 "Info: This is the method that cannot be overridden by a field."); | 951 "Info: This is the method that cannot be overridden by a field."); |
885 | 952 |
886 static const MessageKind BAD_ARITY_OVERRIDE = const MessageKind( | 953 static const MessageKind CANNOT_OVERRIDE_GETTER_WITH_METHOD = |
887 "Error: Cannot override method '#{memberName}' in '#{className}'; " | 954 const MessageKind( |
888 "the parameters do not match."); | 955 "Error: Method '#{name}' in '#{class}' can't override getter from " |
956 "'#{inheritedClass}'."); | |
889 | 957 |
890 static const MessageKind BAD_ARITY_OVERRIDE_CONT = const MessageKind( | 958 static const MessageKind CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT = |
891 "Info: This is the method whose parameters do not match."); | 959 const MessageKind( |
960 "Info: This is the getter that cannot be overridden by a method."); | |
961 | |
962 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_GETTER = | |
963 const MessageKind( | |
964 "Error: Getter '#{name}' in '#{class}' can't override method from " | |
965 "'#{inheritedClass}'."); | |
966 | |
967 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT = | |
968 const MessageKind( | |
969 "Info: This is the method that cannot be overridden by a getter."); | |
892 | 970 |
893 static const MessageKind MISSING_FORMALS = const MessageKind( | 971 static const MessageKind MISSING_FORMALS = const MessageKind( |
894 "Error: Formal parameters are missing."); | 972 "Error: Formal parameters are missing."); |
895 | 973 |
896 static const MessageKind EXTRA_FORMALS = const MessageKind( | 974 static const MessageKind EXTRA_FORMALS = const MessageKind( |
897 "Error: Formal parameters are not allowed here."); | 975 "Error: Formal parameters are not allowed here."); |
898 | 976 |
899 static const MessageKind UNARY_OPERATOR_BAD_ARITY = const MessageKind( | 977 static const MessageKind UNARY_OPERATOR_BAD_ARITY = const MessageKind( |
900 "Error: Operator '#{operatorName}' must have no parameters."); | 978 "Error: Operator '#{operatorName}' must have no parameters."); |
901 | 979 |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1366 const MessageKind( | 1444 const MessageKind( |
1367 "Error: '#{keyword}' is a reserved word and can't be used here.", | 1445 "Error: '#{keyword}' is a reserved word and can't be used here.", |
1368 howToFix: "Try using a different name.", | 1446 howToFix: "Try using a different name.", |
1369 examples: const ["do() {} main() {}"]); | 1447 examples: const ["do() {} main() {}"]); |
1370 | 1448 |
1371 static const MessageKind UNUSED_METHOD = const MessageKind( | 1449 static const MessageKind UNUSED_METHOD = const MessageKind( |
1372 "Hint: The method '#{method_name}' is never called.", | 1450 "Hint: The method '#{method_name}' is never called.", |
1373 howToFix: "Consider deleting it.", | 1451 howToFix: "Consider deleting it.", |
1374 examples: const ["deadCode() {} main() {}"]); | 1452 examples: const ["deadCode() {} main() {}"]); |
1375 | 1453 |
1454 static const MessageKind ABSTRACT_METHOD = const MessageKind( | |
1455 "Warning: The method '#{name}' has no implementation in " | |
1456 "class '#{class}'.", | |
1457 howToFix: "Try adding a body to '#{name}' or declaring " | |
1458 "'#{class}' to be 'abstract'.", | |
1459 examples: const [""" | |
1460 class Class { | |
1461 method(); | |
1462 } | |
1463 main() => new Class(); | |
1464 """]); | |
1465 | |
1466 static const MessageKind ABSTRACT_GETTER = const MessageKind( | |
1467 "Warning: The getter '#{name}' has no implementation in " | |
1468 "class '#{class}'.", | |
1469 howToFix: "Try adding a body to '#{name}' or declaring " | |
1470 "'#{class}' to be 'abstract'.", | |
1471 examples: const [""" | |
1472 class Class { | |
1473 get getter; | |
1474 } | |
1475 main() => new Class(); | |
1476 """]); | |
1477 | |
1478 static const MessageKind ABSTRACT_SETTER = const MessageKind( | |
1479 "Warning: The setter '#{name}' has no implementation in " | |
1480 "class '#{class}'.", | |
1481 howToFix: "Try adding a body to '#{name}' or declaring " | |
1482 "'#{class}' to be 'abstract'.", | |
1483 examples: const [""" | |
1484 class Class { | |
1485 set setter(_); | |
1486 } | |
1487 main() => new Class(); | |
1488 """]); | |
1489 | |
1490 static const MessageKind INHERIT_GETTER_AND_METHOD = const MessageKind( | |
1491 "Warning: The class '#{class}' can't inherit both getters and methods " | |
1492 "by the named '#{name}'.", | |
1493 howToFix: DONT_KNOW_HOW_TO_FIX, | |
1494 examples: const [""" | |
1495 class A { | |
1496 get member => null; | |
1497 } | |
1498 class B { | |
1499 member() {} | |
1500 } | |
1501 class Class implements A, B { | |
1502 } | |
1503 main() => new Class(); | |
1504 """]); | |
1505 | |
1506 static const MessageKind INHERITED_METHOD = const MessageKind( | |
1507 "Info: The inherited method '#{name}' is declared here in class " | |
1508 "'#{class}'."); | |
1509 | |
1510 static const MessageKind INHERITED_EXPLICIT_GETTER = const MessageKind( | |
1511 "Info: The inherited getter '#{name}' is declared here in class " | |
1512 "'#{class}'."); | |
1513 | |
1514 static const MessageKind INHERITED_IMPLICIT_GETTER = const MessageKind( | |
1515 "Info: The inherited getter '#{name}' is implicitly declared by this " | |
1516 "field in class '#{class}'."); | |
1517 | |
1518 static const MessageKind UNIMPLEMENTED_METHOD_ONE = const MessageKind( | |
1519 "Warning: '#{class}' doesn't implement '#{method}' " | |
1520 "declared in '#{declarer}'.", | |
1521 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1522 "'#{class}' to be 'abstract'.", | |
1523 examples: const [""" | |
1524 abstract class I { | |
1525 m(); | |
1526 } | |
1527 | |
karlklose
2014/01/28 12:27:45
I would prefer shortening the examples - at least
Johnni Winther
2014/01/31 12:29:30
Done.
| |
1528 class C implements I {} | |
1529 | |
1530 main() { | |
1531 new C(); | |
1532 } | |
1533 """, """ | |
1534 abstract class I { | |
1535 m(); | |
1536 } | |
1537 | |
1538 class C extends I {} | |
1539 | |
1540 main() { | |
1541 new C(); | |
1542 } | |
1543 """]); | |
1544 | |
1376 static const MessageKind UNIMPLEMENTED_METHOD = const MessageKind( | 1545 static const MessageKind UNIMPLEMENTED_METHOD = const MessageKind( |
1377 "Warning: '#{class_name}' doesn't implement '#{member_name}'.", | 1546 "Warning: '#{class}' doesn't implement '#{method}'.", |
1378 howToFix: "Try adding an implementation of '#{member_name}'.", | 1547 howToFix: "Try adding an implementation of '#{name}' or declaring " |
1379 examples: const [""" | 1548 "'#{class}' to be 'abstract'.", |
1380 abstract class I { | 1549 examples: const [""" |
1381 m(); | 1550 abstract class I { |
1551 m(); | |
1552 } | |
1553 | |
1554 abstract class J { | |
1555 m(); | |
1556 } | |
1557 | |
1558 class C implements I, J {} | |
1559 | |
1560 main() { | |
1561 new C(); | |
1562 } | |
1563 """, """ | |
1564 abstract class I { | |
1565 m(); | |
1566 } | |
1567 | |
1568 abstract class J { | |
1569 m(); | |
1570 } | |
1571 | |
1572 class C extends I implements J {} | |
1573 | |
1574 main() { | |
1575 new C(); | |
1576 } | |
1577 """]); | |
1578 | |
1579 static const MessageKind UNIMPLEMENTED_METHOD_CONT = const MessageKind( | |
1580 "Info: The method '#{name}' is declared here in class '#{class}'."); | |
1581 | |
1582 static const MessageKind UNIMPLEMENTED_SETTER_ONE = const MessageKind( | |
1583 "Warning: '#{class}' doesn't implement the setter '#{name}' " | |
1584 "declared in '#{declarer}'.", | |
1585 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1586 "'#{class}' to be 'abstract'.", | |
1587 examples: const [""" | |
1588 abstract class I { | |
1589 set m(_); | |
1382 } | 1590 } |
1383 | 1591 |
1384 class C implements I {} | 1592 class C implements I {} |
1385 | 1593 |
1386 class D implements I { | 1594 class D implements I { |
1387 m() {} | 1595 set m(_) {} |
1388 } | 1596 } |
1389 | 1597 |
1390 main() { | 1598 main() { |
1391 new D().m(); | 1599 new D().m = 0; |
1392 new C(); | 1600 new C(); |
1393 } | 1601 } |
1394 """, """ | 1602 """]); |
1395 abstract class I { | 1603 |
1396 m(); | 1604 static const MessageKind UNIMPLEMENTED_SETTER = const MessageKind( |
1605 "Warning: '#{class}' doesn't implement the setter '#{name}'.", | |
1606 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1607 "'#{class}' to be 'abstract'.", | |
1608 examples: const [""" | |
1609 abstract class I { | |
1610 set m(_); | |
1611 } | |
1612 | |
1613 abstract class J { | |
1614 set m(_); | |
1615 } | |
1616 | |
1617 class C implements I, J {} | |
1618 | |
1619 main() { | |
1620 new C(); | |
1621 } | |
1622 """, """ | |
1623 abstract class I { | |
1624 set m(_); | |
1625 } | |
1626 | |
1627 abstract class J { | |
1628 set m(_); | |
1629 } | |
1630 | |
1631 class C extends I implements J {} | |
1632 | |
1633 main() { | |
1634 new C(); | |
1635 } | |
1636 """]); | |
1637 | |
1638 static const MessageKind UNIMPLEMENTED_EXPLICIT_SETTER = const MessageKind( | |
1639 "Info: The setter '#{name}' is declared here in class '#{class}'."); | |
1640 | |
1641 static const MessageKind UNIMPLEMENTED_IMPLICIT_SETTER = const MessageKind( | |
1642 "Info: The setter '#{name}' is implicitly declared by this field " | |
1643 "in class '#{class}'."); | |
1644 | |
1645 static const MessageKind UNIMPLEMENTED_GETTER_ONE = const MessageKind( | |
1646 "Warning: '#{class}' doesn't implement the getter '#{name}' " | |
1647 "declared in '#{declarer}'.", | |
1648 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
1649 "'#{class}' to be 'abstract'.", | |
1650 examples: const [""" | |
1651 abstract class I { | |
1652 get m; | |
1653 } | |
1654 | |
1655 class C implements I {} | |
1656 | |
1657 main() { | |
1658 new C(); | |
1659 } | |
1660 """, """ | |
1661 abstract class I { | |
1662 get m; | |
1397 } | 1663 } |
1398 | 1664 |
1399 class C extends I {} | 1665 class C extends I {} |
1400 | 1666 |
1401 class D extends I { | 1667 main() { |
1402 m() {} | 1668 new C(); |
1403 } | 1669 } |
1404 | 1670 """]); |
1405 main() { | 1671 |
1406 new D().m(); | 1672 static const MessageKind UNIMPLEMENTED_GETTER = const MessageKind( |
1407 new C(); | 1673 "Warning: '#{class}' doesn't implement the getter '#{name}'.", |
1408 } | 1674 howToFix: "Try adding an implementation of '#{name}' or declaring " |
1409 """]); | 1675 "'#{class}' to be 'abstract'.", |
1676 examples: const [""" | |
1677 abstract class I { | |
1678 get m; | |
1679 } | |
1680 | |
1681 abstract class J { | |
1682 get m; | |
1683 } | |
1684 | |
1685 class C implements I, J {} | |
1686 | |
1687 main() { | |
1688 new C(); | |
1689 } | |
1690 """, """ | |
1691 abstract class I { | |
1692 get m; | |
1693 } | |
1694 | |
1695 abstract class J { | |
1696 get m; | |
1697 } | |
1698 | |
1699 class C extends I implements J {} | |
1700 | |
1701 main() { | |
1702 new C(); | |
1703 } | |
1704 """]); | |
1705 | |
1706 static const MessageKind UNIMPLEMENTED_EXPLICIT_GETTER = const MessageKind( | |
1707 "Info: The getter '#{name}' is declared here in class '#{class}'."); | |
1708 | |
1709 static const MessageKind UNIMPLEMENTED_IMPLICIT_GETTER = const MessageKind( | |
1710 "Info: The getter '#{name}' is implicitly declared by this field " | |
1711 "in class '#{class}'."); | |
1410 | 1712 |
1411 static const MessageKind COMPILER_CRASHED = const MessageKind( | 1713 static const MessageKind COMPILER_CRASHED = const MessageKind( |
1412 "Error: The compiler crashed when compiling this element."); | 1714 "Error: The compiler crashed when compiling this element."); |
1413 | 1715 |
1414 static const MessageKind PLEASE_REPORT_THE_CRASH = const MessageKind(''' | 1716 static const MessageKind PLEASE_REPORT_THE_CRASH = const MessageKind(''' |
1415 The compiler is broken. | 1717 The compiler is broken. |
1416 | 1718 |
1417 When compiling the above element, the compiler crashed. It is not | 1719 When compiling the above element, the compiler crashed. It is not |
1418 possible to tell if this is caused by a problem in your program or | 1720 possible to tell if this is caused by a problem in your program or |
1419 not. Regardless, the compiler should not crash. | 1721 not. Regardless, the compiler should not crash. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1601 } | 1903 } |
1602 | 1904 |
1603 String computeMessage() { | 1905 String computeMessage() { |
1604 if (message == null) { | 1906 if (message == null) { |
1605 message = kind.template; | 1907 message = kind.template; |
1606 arguments.forEach((key, value) { | 1908 arguments.forEach((key, value) { |
1607 message = message.replaceAll('#{${key}}', value.toString()); | 1909 message = message.replaceAll('#{${key}}', value.toString()); |
1608 }); | 1910 }); |
1609 assert(invariant( | 1911 assert(invariant( |
1610 CURRENT_ELEMENT_SPANNABLE, | 1912 CURRENT_ELEMENT_SPANNABLE, |
1611 !message.contains(new RegExp(r'#\{.+\}')), | 1913 kind == MessageKind.GENERIC || |
1914 !message.contains(new RegExp(r'#\{.+\}')), | |
1612 message: 'Missing arguments in error message: "$message"')); | 1915 message: 'Missing arguments in error message: "$message"')); |
1613 if (!terse && kind.hasHowToFix) { | 1916 if (!terse && kind.hasHowToFix) { |
1614 String howToFix = kind.howToFix; | 1917 String howToFix = kind.howToFix; |
1615 arguments.forEach((key, value) { | 1918 arguments.forEach((key, value) { |
1616 howToFix = howToFix.replaceAll('#{${key}}', value.toString()); | 1919 howToFix = howToFix.replaceAll('#{${key}}', value.toString()); |
1617 }); | 1920 }); |
1618 message = '$message\n$howToFix'; | 1921 message = '$message\n$howToFix'; |
1619 } | 1922 } |
1620 } | 1923 } |
1621 return message; | 1924 return message; |
(...skipping 30 matching lines...) Expand all Loading... | |
1652 | 1955 |
1653 class CompileTimeConstantError extends Diagnostic { | 1956 class CompileTimeConstantError extends Diagnostic { |
1654 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse) | 1957 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse) |
1655 : super(kind, arguments, terse); | 1958 : super(kind, arguments, terse); |
1656 } | 1959 } |
1657 | 1960 |
1658 class CompilationError extends Diagnostic { | 1961 class CompilationError extends Diagnostic { |
1659 CompilationError(MessageKind kind, Map arguments, bool terse) | 1962 CompilationError(MessageKind kind, Map arguments, bool terse) |
1660 : super(kind, arguments, terse); | 1963 : super(kind, arguments, terse); |
1661 } | 1964 } |
OLD | NEW |