OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:front_end/src/fasta/fasta_codes.dart'; | 5 import 'package:front_end/src/fasta/fasta_codes.dart'; |
6 import 'package:front_end/src/fasta/parser/identifier_context.dart' | 6 import 'package:front_end/src/fasta/parser/identifier_context.dart' |
7 show IdentifierContext; | 7 show IdentifierContext; |
8 import 'package:front_end/src/fasta/parser.dart' as fasta; | 8 import 'package:front_end/src/fasta/parser.dart' as fasta; |
9 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; | 9 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; |
10 import 'package:front_end/src/fasta/util/link.dart'; | 10 import 'package:front_end/src/fasta/util/link.dart'; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 void expectEmpty() { | 44 void expectEmpty() { |
45 expect(_stack, isEmpty); | 45 expect(_stack, isEmpty); |
46 } | 46 } |
47 | 47 |
48 void expectIn(String event) { | 48 void expectIn(String event) { |
49 if (_stack.isEmpty || _stack.last != event) { | 49 if (_stack.isEmpty || _stack.last != event) { |
50 fail('Expected $event, but found $_stack'); | 50 fail('Expected $event, but found $_stack'); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
| 54 void expectInOneOf(List<String> events) { |
| 55 if (_stack.isEmpty || !events.contains(_stack.last)) { |
| 56 fail('Expected one of $events, but found $_stack'); |
| 57 } |
| 58 } |
| 59 |
54 void end(String event) { | 60 void end(String event) { |
55 expectIn(event); | 61 expectIn(event); |
56 _stack.removeLast(); | 62 _stack.removeLast(); |
57 } | 63 } |
58 | 64 |
59 ForwardingTestListener(this.listener); | 65 ForwardingTestListener(this.listener); |
60 | 66 |
61 @override | 67 @override |
62 Uri get uri => listener.uri; | 68 Uri get uri => listener.uri; |
63 | 69 |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } | 617 } |
612 | 618 |
613 @override | 619 @override |
614 void endClassBody(int memberCount, Token beginToken, Token endToken) { | 620 void endClassBody(int memberCount, Token beginToken, Token endToken) { |
615 end('ClassBody'); | 621 end('ClassBody'); |
616 listener.endClassBody(memberCount, beginToken, endToken); | 622 listener.endClassBody(memberCount, beginToken, endToken); |
617 } | 623 } |
618 | 624 |
619 @override | 625 @override |
620 void handleNativeClause(Token nativeToken, bool hasName) { | 626 void handleNativeClause(Token nativeToken, bool hasName) { |
621 expectIn('ClassDeclaration'); | 627 expectInOneOf(['ClassDeclaration', 'Method']); |
622 listener.handleNativeClause(nativeToken, hasName); | 628 listener.handleNativeClause(nativeToken, hasName); |
623 } | 629 } |
624 | 630 |
625 @override | 631 @override |
626 void endClassDeclaration( | 632 void endClassDeclaration( |
627 int interfacesCount, | 633 int interfacesCount, |
628 Token beginToken, | 634 Token beginToken, |
629 Token classKeyword, | 635 Token classKeyword, |
630 Token extendsKeyword, | 636 Token extendsKeyword, |
631 Token implementsKeyword, | 637 Token implementsKeyword, |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 listener.endMetadata(beginToken, periodBeforeName, endToken); | 920 listener.endMetadata(beginToken, periodBeforeName, endToken); |
915 } | 921 } |
916 | 922 |
917 @override | 923 @override |
918 void endMetadataStar(int count, bool forParameter) { | 924 void endMetadataStar(int count, bool forParameter) { |
919 end('MetadataStar'); | 925 end('MetadataStar'); |
920 listener.endMetadataStar(count, forParameter); | 926 listener.endMetadataStar(count, forParameter); |
921 } | 927 } |
922 | 928 |
923 @override | 929 @override |
924 void endMethod(Token getOrSet, Token beginToken, Token endToken) { | 930 void endMethod( |
| 931 Token getOrSet, Token beginToken, Token nativeToken, Token endToken) { |
925 end('Method'); | 932 end('Method'); |
926 listener.endMethod(getOrSet, beginToken, endToken); | 933 listener.endMethod(getOrSet, beginToken, nativeToken, endToken); |
927 } | 934 } |
928 | 935 |
929 @override | 936 @override |
930 void endMixinApplication(Token withKeyword) { | 937 void endMixinApplication(Token withKeyword) { |
931 end('MixinApplication'); | 938 end('MixinApplication'); |
932 listener.endMixinApplication(withKeyword); | 939 listener.endMixinApplication(withKeyword); |
933 } | 940 } |
934 | 941 |
935 @override | 942 @override |
936 void endNamedFunctionExpression(Token endToken) { | 943 void endNamedFunctionExpression(Token endToken) { |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 tokenToStartReplacing, tokenWithComment); | 1553 tokenToStartReplacing, tokenWithComment); |
1547 // TODO(danrubel): implement replaceTokenWithGenericCommentTypeAssign | 1554 // TODO(danrubel): implement replaceTokenWithGenericCommentTypeAssign |
1548 } | 1555 } |
1549 | 1556 |
1550 @override | 1557 @override |
1551 set suppressParseErrors(bool value) { | 1558 set suppressParseErrors(bool value) { |
1552 listener.suppressParseErrors = value; | 1559 listener.suppressParseErrors = value; |
1553 // TODO(danrubel): implement suppressParseErrors | 1560 // TODO(danrubel): implement suppressParseErrors |
1554 } | 1561 } |
1555 } | 1562 } |
OLD | NEW |