| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.analyzer.ast_builder; | 5 library fasta.analyzer.ast_builder; |
| 6 | 6 |
| 7 import 'package:front_end/src/fasta/scanner/token.dart' | 7 import 'package:front_end/src/fasta/scanner/token.dart' |
| 8 show BeginGroupToken, Token; | 8 show BeginGroupToken, Token; |
| 9 | 9 |
| 10 import 'package:analyzer/analyzer.dart'; | 10 import 'package:analyzer/analyzer.dart'; |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 | 798 |
| 799 @override | 799 @override |
| 800 void endClassBody(int memberCount, Token beginToken, Token endToken) { | 800 void endClassBody(int memberCount, Token beginToken, Token endToken) { |
| 801 debugEvent("ClassBody"); | 801 debugEvent("ClassBody"); |
| 802 push(new _ClassBody( | 802 push(new _ClassBody( |
| 803 beginToken, popList(memberCount) ?? <ClassMember>[], endToken)); | 803 beginToken, popList(memberCount) ?? <ClassMember>[], endToken)); |
| 804 } | 804 } |
| 805 | 805 |
| 806 @override | 806 @override |
| 807 void endClassDeclaration(int interfacesCount, Token beginToken, | 807 void endClassDeclaration(int interfacesCount, Token beginToken, |
| 808 Token extendsKeyword, Token implementsKeyword, Token endToken) { | 808 Token classKeyword, Token extendsKeyword, Token implementsKeyword, |
| 809 Token endToken) { |
| 809 debugEvent("ClassDeclaration"); | 810 debugEvent("ClassDeclaration"); |
| 810 _ClassBody body = pop(); | 811 _ClassBody body = pop(); |
| 811 ImplementsClause implementsClause; | 812 ImplementsClause implementsClause; |
| 812 if (implementsKeyword != null) { | 813 if (implementsKeyword != null) { |
| 813 List<TypeName> interfaces = popList(interfacesCount); | 814 List<TypeName> interfaces = popList(interfacesCount); |
| 814 implementsClause = | 815 implementsClause = |
| 815 ast.implementsClause(toAnalyzerToken(implementsKeyword), interfaces); | 816 ast.implementsClause(toAnalyzerToken(implementsKeyword), interfaces); |
| 816 } | 817 } |
| 817 ExtendsClause extendsClause; | 818 ExtendsClause extendsClause; |
| 818 WithClause withClause; | 819 WithClause withClause; |
| 819 var supertype = pop(); | 820 var supertype = pop(); |
| 820 if (supertype == null) { | 821 if (supertype == null) { |
| 821 // No extends clause | 822 // No extends clause |
| 822 } else if (supertype is TypeName) { | 823 } else if (supertype is TypeName) { |
| 823 extendsClause = | 824 extendsClause = |
| 824 ast.extendsClause(toAnalyzerToken(extendsKeyword), supertype); | 825 ast.extendsClause(toAnalyzerToken(extendsKeyword), supertype); |
| 825 } else if (supertype is _MixinApplication) { | 826 } else if (supertype is _MixinApplication) { |
| 826 extendsClause = ast.extendsClause( | 827 extendsClause = ast.extendsClause( |
| 827 toAnalyzerToken(extendsKeyword), supertype.supertype); | 828 toAnalyzerToken(extendsKeyword), supertype.supertype); |
| 828 withClause = ast.withClause( | 829 withClause = ast.withClause( |
| 829 toAnalyzerToken(supertype.withKeyword), supertype.mixinTypes); | 830 toAnalyzerToken(supertype.withKeyword), supertype.mixinTypes); |
| 830 } else { | 831 } else { |
| 831 internalError('Unexpected kind of supertype ${supertype.runtimeType}'); | 832 internalError('Unexpected kind of supertype ${supertype.runtimeType}'); |
| 832 } | 833 } |
| 833 TypeParameterList typeParameters = pop(); | 834 TypeParameterList typeParameters = pop(); |
| 834 SimpleIdentifier name = pop(); | 835 SimpleIdentifier name = pop(); |
| 835 Token classKeyword; | |
| 836 // TODO(paulberry,ahe): This is a hack. The parser should give us the class | |
| 837 // keyword. | |
| 838 if (optional('abstract', beginToken)) { | |
| 839 classKeyword = beginToken.next; | |
| 840 } else { | |
| 841 classKeyword = beginToken; | |
| 842 } | |
| 843 var modifiers = pop(); | 836 var modifiers = pop(); |
| 844 assert(modifiers == null); // TODO(paulberry) | 837 assert(modifiers == null); // TODO(paulberry) |
| 845 analyzer.Token abstractKeyword; | 838 analyzer.Token abstractKeyword; |
| 846 List<Annotation> metadata = pop(); | 839 List<Annotation> metadata = pop(); |
| 847 // TODO(paulberry): capture doc comments. See dartbug.com/28851. | 840 // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
| 848 Comment comment = null; | 841 Comment comment = null; |
| 849 push(ast.classDeclaration( | 842 push(ast.classDeclaration( |
| 850 comment, | 843 comment, |
| 851 metadata, | 844 metadata, |
| 852 abstractKeyword, | 845 abstractKeyword, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 867 List<TypeName> mixinTypes = pop(); | 860 List<TypeName> mixinTypes = pop(); |
| 868 // TODO(paulberry,ahe): the parser doesn't give us enough information to | 861 // TODO(paulberry,ahe): the parser doesn't give us enough information to |
| 869 // locate the "with" keyword. | 862 // locate the "with" keyword. |
| 870 Token withKeyword; | 863 Token withKeyword; |
| 871 TypeName supertype = pop(); | 864 TypeName supertype = pop(); |
| 872 push(new _MixinApplication(supertype, withKeyword, mixinTypes)); | 865 push(new _MixinApplication(supertype, withKeyword, mixinTypes)); |
| 873 } | 866 } |
| 874 | 867 |
| 875 @override | 868 @override |
| 876 void endNamedMixinApplication( | 869 void endNamedMixinApplication( |
| 877 Token beginToken, Token equalsToken, Token implementsKeyword, Token endTok
en) { | 870 Token beginToken, Token classKeyword, Token equalsToken, |
| 871 Token implementsKeyword, Token endToken) { |
| 878 debugEvent("NamedMixinApplication"); | 872 debugEvent("NamedMixinApplication"); |
| 879 ImplementsClause implementsClause; | 873 ImplementsClause implementsClause; |
| 880 if (implementsKeyword != null) { | 874 if (implementsKeyword != null) { |
| 881 List<TypeName> interfaces = pop(); | 875 List<TypeName> interfaces = pop(); |
| 882 implementsClause = | 876 implementsClause = |
| 883 ast.implementsClause(toAnalyzerToken(implementsKeyword), interfaces); | 877 ast.implementsClause(toAnalyzerToken(implementsKeyword), interfaces); |
| 884 } | 878 } |
| 885 _MixinApplication mixinApplication = pop(); | 879 _MixinApplication mixinApplication = pop(); |
| 886 var superclass = mixinApplication.supertype; | 880 var superclass = mixinApplication.supertype; |
| 887 var withClause = ast.withClause( | 881 var withClause = ast.withClause( |
| 888 toAnalyzerToken(mixinApplication.withKeyword), | 882 toAnalyzerToken(mixinApplication.withKeyword), |
| 889 mixinApplication.mixinTypes); | 883 mixinApplication.mixinTypes); |
| 890 analyzer.Token equals = toAnalyzerToken(equalsToken); | 884 analyzer.Token equals = toAnalyzerToken(equalsToken); |
| 891 TypeParameterList typeParameters = pop(); | 885 TypeParameterList typeParameters = pop(); |
| 892 SimpleIdentifier name = pop(); | 886 SimpleIdentifier name = pop(); |
| 893 Token classKeyword; | |
| 894 // TODO(paulberry,ahe): This is a hack. The parser should give us the class | |
| 895 // keyword. | |
| 896 if (identical(beginToken.value, 'abstract')) { | |
| 897 classKeyword = beginToken.next; | |
| 898 } else { | |
| 899 classKeyword = beginToken; | |
| 900 } | |
| 901 var modifiers = pop(); | 887 var modifiers = pop(); |
| 902 assert(modifiers == null); // TODO(paulberry) | 888 assert(modifiers == null); // TODO(paulberry) |
| 903 analyzer.Token abstractKeyword; | 889 analyzer.Token abstractKeyword; |
| 904 List<Annotation> metadata = pop(); | 890 List<Annotation> metadata = pop(); |
| 905 // TODO(paulberry): capture doc comments. See dartbug.com/28851. | 891 // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
| 906 Comment comment = null; | 892 Comment comment = null; |
| 907 push(ast.classTypeAlias( | 893 push(ast.classTypeAlias( |
| 908 comment, | 894 comment, |
| 909 metadata, | 895 metadata, |
| 910 toAnalyzerToken(classKeyword), | 896 toAnalyzerToken(classKeyword), |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 /// [ClassDeclaration] or [ClassTypeAlias] object. | 1145 /// [ClassDeclaration] or [ClassTypeAlias] object. |
| 1160 class _MixinApplication { | 1146 class _MixinApplication { |
| 1161 final TypeName supertype; | 1147 final TypeName supertype; |
| 1162 | 1148 |
| 1163 final Token withKeyword; | 1149 final Token withKeyword; |
| 1164 | 1150 |
| 1165 final List<TypeName> mixinTypes; | 1151 final List<TypeName> mixinTypes; |
| 1166 | 1152 |
| 1167 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes); | 1153 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes); |
| 1168 } | 1154 } |
| OLD | NEW |