Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart

Issue 2707163002: Add preliminary support for methods to AstBuilder. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 comment, metadata, name, toAnalyzerToken(extendsOrSuper), bound)); 1011 comment, metadata, name, toAnalyzerToken(extendsOrSuper), bound));
1012 } 1012 }
1013 1013
1014 @override 1014 @override
1015 void endTypeVariables(int count, Token beginToken, Token endToken) { 1015 void endTypeVariables(int count, Token beginToken, Token endToken) {
1016 debugEvent("TypeVariables"); 1016 debugEvent("TypeVariables");
1017 List<TypeParameter> typeParameters = popList(count); 1017 List<TypeParameter> typeParameters = popList(count);
1018 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters, 1018 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters,
1019 toAnalyzerToken(endToken))); 1019 toAnalyzerToken(endToken)));
1020 } 1020 }
1021
1022 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
scheglov 2017/02/21 20:17:27 @override
Paul Berry 2017/02/21 20:24:03 Done.
1023 debugEvent("Method");
1024 FunctionBody body = _endFunctionBody();
1025 ConstructorName redirectedConstructor = null; // TODO(paulberry)
1026 List<ConstructorInitializer> initializers = null; // TODO(paulberry)
1027 Token separator = null; // TODO(paulberry)
1028 FormalParameterList parameters = pop();
1029 TypeParameterList typeParameters = pop();
1030 var name = pop();
1031 analyzer.Token propertyKeyword = toAnalyzerToken(getOrSet);
1032 TypeAnnotation returnType = pop();
1033 // TODO(paulberry): handle modifiers.
1034 var modifiers = pop();
1035 assert(modifiers == null);
1036 Token externalKeyword = null; // TODO(paulberry)
1037 Token constKeyword = null; // TODO(paulberry)
1038 Token factoryKeyword = null; // TODO(paulberry)
1039 List<Annotation> metadata = pop();
1040 // TODO(paulberry): capture doc comments.
1041 Comment comment = null;
1042 SimpleIdentifier returnType2;
1043 Token period;
1044 SimpleIdentifier name2;
1045 if (name is SimpleIdentifier) {
1046 SimpleIdentifier returnType2 = name;
ahe 2017/02/22 11:30:38 There's a few hints introduced with this change. C
Paul Berry 2017/02/22 16:37:12 Fair enough. I will follow up with a fix.
1047 }
1048 push(ast.constructorDeclaration(
1049 comment,
1050 metadata,
1051 toAnalyzerToken(externalKeyword),
1052 toAnalyzerToken(constKeyword),
1053 toAnalyzerToken(factoryKeyword),
1054 returnType2,
1055 toAnalyzerToken(period),
1056 name2,
1057 parameters,
1058 toAnalyzerToken(separator),
1059 initializers,
1060 redirectedConstructor,
1061 body));
1062 }
1063
1064 void endMember() {
scheglov 2017/02/21 20:17:27 @override
Paul Berry 2017/02/21 20:24:03 Done.
1065 debugEvent("Member");
1066 }
1021 } 1067 }
1022 1068
1023 /// Data structure placed on the stack to represent a class body. 1069 /// Data structure placed on the stack to represent a class body.
1024 /// 1070 ///
1025 /// This is needed because analyzer has no separate AST representation of a 1071 /// This is needed because analyzer has no separate AST representation of a
1026 /// class body; it simply stores all of the relevant data in the 1072 /// class body; it simply stores all of the relevant data in the
1027 /// [ClassDeclaration] object. 1073 /// [ClassDeclaration] object.
1028 class _ClassBody { 1074 class _ClassBody {
1029 final Token beginToken; 1075 final Token beginToken;
1030 1076
(...skipping 12 matching lines...) Expand all
1043 /// [ClassDeclaration] or [ClassTypeAlias] object. 1089 /// [ClassDeclaration] or [ClassTypeAlias] object.
1044 class _MixinApplication { 1090 class _MixinApplication {
1045 final TypeName supertype; 1091 final TypeName supertype;
1046 1092
1047 final Token withKeyword; 1093 final Token withKeyword;
1048 1094
1049 final List<TypeName> mixinTypes; 1095 final List<TypeName> mixinTypes;
1050 1096
1051 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes); 1097 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes);
1052 } 1098 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_fasta_test.dart ('k') | pkg/front_end/lib/src/fasta/parser/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698