OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 library dart2js.parser.element_listener; | 5 library dart2js.parser.element_listener; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../diagnostics/messages.dart' show MessageTemplate; | 8 import '../diagnostics/messages.dart' show MessageTemplate; |
9 import '../elements/elements.dart' | 9 import '../elements/elements.dart' |
10 show Element, LibraryElement, MetadataAnnotation; | 10 show Element, LibraryElement, MetadataAnnotation; |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 | 734 |
735 case ErrorKind.BuiltInIdentifierAsType: | 735 case ErrorKind.BuiltInIdentifierAsType: |
736 errorCode = MessageKind.GENERIC; | 736 errorCode = MessageKind.GENERIC; |
737 arguments = {"text": "Can't use '${token.lexeme}' as a type."}; | 737 arguments = {"text": "Can't use '${token.lexeme}' as a type."}; |
738 break; | 738 break; |
739 | 739 |
740 case ErrorKind.BuiltInIdentifierInDeclaration: | 740 case ErrorKind.BuiltInIdentifierInDeclaration: |
741 errorCode = MessageKind.GENERIC; | 741 errorCode = MessageKind.GENERIC; |
742 arguments = {"text": "Can't use '${token.lexeme}' as a name here."}; | 742 arguments = {"text": "Can't use '${token.lexeme}' as a name here."}; |
743 break; | 743 break; |
| 744 |
| 745 case ErrorKind.AbstractNotSync: |
| 746 errorCode = MessageKind.GENERIC; |
| 747 arguments = { |
| 748 "text": "Abstract methods can't use 'async', 'async*', or 'sync*'." |
| 749 }; |
| 750 return; // Ignored. This error is already implemented elsewhere. |
| 751 |
| 752 case ErrorKind.SetterNotSync: |
| 753 errorCode = MessageKind.GENERIC; |
| 754 arguments = { |
| 755 "text": "Setters can't use 'async', 'async*', or 'sync*'." |
| 756 }; |
| 757 return; // Ignored. This error is already implemented elsewhere. |
| 758 |
| 759 case ErrorKind.FactoryNotSync: |
| 760 errorCode = MessageKind.GENERIC; |
| 761 arguments = { |
| 762 "text": "Factories can't use 'async', 'async*', or 'sync*'." |
| 763 }; |
| 764 return; // Ignored. This error is already implemented elsewhere. |
| 765 |
| 766 case ErrorKind.AwaitForNotAsync: |
| 767 errorCode = MessageKind.GENERIC; |
| 768 arguments = { |
| 769 "text": "Asynchronous for-loop can only be used " |
| 770 "in 'async' or 'async*' methods." |
| 771 }; |
| 772 return; // Ignored. This error is already implemented elsewhere. |
| 773 |
| 774 case ErrorKind.AsyncAsIdentifier: |
| 775 errorCode = MessageKind.GENERIC; |
| 776 arguments = { |
| 777 "text": "'async' can't be used as an identifier in " |
| 778 "'async', 'async*', or 'sync*' methods." |
| 779 }; |
| 780 break; |
| 781 |
| 782 case ErrorKind.YieldNotGenerator: |
| 783 errorCode = MessageKind.GENERIC; |
| 784 arguments = { |
| 785 "text": "'yield' can only be used in 'sync*' or 'async*' methods." |
| 786 }; |
| 787 return; // Ignored. This error is already implemented elsewhere. |
| 788 |
| 789 case ErrorKind.YieldAsIdentifier: |
| 790 errorCode = MessageKind.GENERIC; |
| 791 arguments = { |
| 792 "text": "'yield' can't be used as an identifier in " |
| 793 "'async', 'async*', or 'sync*' methods." |
| 794 }; |
| 795 return; // Ignored. This error is already implemented elsewhere. |
| 796 |
| 797 case ErrorKind.GeneratorReturnsValue: |
| 798 errorCode = MessageKind.GENERIC; |
| 799 arguments = {"text": "'sync*' and 'async*' can't return a value."}; |
| 800 return; // Ignored. This error is already implemented elsewhere. |
| 801 |
| 802 case ErrorKind.AwaitNotAsync: |
| 803 errorCode = MessageKind.GENERIC; |
| 804 arguments = { |
| 805 "text": "'await' can only be used in 'async' or 'async*' methods." |
| 806 }; |
| 807 return; // Ignored. This error is already implemented elsewhere. |
| 808 |
| 809 case ErrorKind.AwaitAsIdentifier: |
| 810 errorCode = MessageKind.GENERIC; |
| 811 arguments = { |
| 812 "text": "'await' can't be used as an identifier in " |
| 813 "'async', 'async*', or 'sync*' methods." |
| 814 }; |
| 815 return; // Ignored. This error is already implemented elsewhere. |
744 } | 816 } |
745 SourceSpan span = reporter.spanFromToken(token); | 817 SourceSpan span = reporter.spanFromToken(token); |
746 reportError(span, errorCode, arguments); | 818 reportError(span, errorCode, arguments); |
747 } | 819 } |
748 | 820 |
749 /// Finds the preceding token via the begin token of the last AST node pushed | 821 /// Finds the preceding token via the begin token of the last AST node pushed |
750 /// on the [nodes] stack. | 822 /// on the [nodes] stack. |
751 Token findPrecedingToken(Token token) { | 823 Token findPrecedingToken(Token token) { |
752 Token result; | 824 Token result; |
753 Link<Node> nodes = this.nodes; | 825 Link<Node> nodes = this.nodes; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 memberErrors = memberErrors.tail.prepend(true); | 1041 memberErrors = memberErrors.tail.prepend(true); |
970 } | 1042 } |
971 reporter.reportErrorMessage(spannable, errorCode, arguments); | 1043 reporter.reportErrorMessage(spannable, errorCode, arguments); |
972 } | 1044 } |
973 | 1045 |
974 void reportErrorFromToken(Token token, MessageKind errorCode, | 1046 void reportErrorFromToken(Token token, MessageKind errorCode, |
975 [Map arguments = const {}]) { | 1047 [Map arguments = const {}]) { |
976 reportError(reporter.spanFromToken(token), errorCode, arguments); | 1048 reportError(reporter.spanFromToken(token), errorCode, arguments); |
977 } | 1049 } |
978 } | 1050 } |
OLD | NEW |