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

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

Issue 2738013002: Add support for metadata on type variables to Fasta parser. (Closed)
Patch Set: Bug fixes Created 3 years, 9 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:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory;
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard;
10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 void endArguments(int count, Token beginToken, Token endToken) { 157 void endArguments(int count, Token beginToken, Token endToken) {
158 debugEvent("Arguments"); 158 debugEvent("Arguments");
159 List expressions = popList(count); 159 List expressions = popList(count);
160 ArgumentList arguments = ast.argumentList( 160 ArgumentList arguments = ast.argumentList(
161 toAnalyzerToken(beginToken), expressions, toAnalyzerToken(endToken)); 161 toAnalyzerToken(beginToken), expressions, toAnalyzerToken(endToken));
162 push(ast.methodInvocation(null, null, null, null, arguments)); 162 push(ast.methodInvocation(null, null, null, null, arguments));
163 } 163 }
164 164
165 void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) {
166 debugEvent("Metadata");
167 ArgumentList arguments = pop();
168 SimpleIdentifier constructorName = popIfNotNull(periodBeforeName);
169 var typeArguments = pop();
170 assert(typeArguments == null); // TODO(paulberry)
171 Identifier name = pop();
172 push(ast.annotation(toAnalyzerToken(beginToken), name,
173 toAnalyzerToken(periodBeforeName), constructorName, arguments));
174 }
175
165 void handleIdentifier(Token token, IdentifierContext context) { 176 void handleIdentifier(Token token, IdentifierContext context) {
166 debugEvent("handleIdentifier"); 177 debugEvent("handleIdentifier");
167 analyzer.Token analyzerToken = toAnalyzerToken(token); 178 analyzer.Token analyzerToken = toAnalyzerToken(token);
168 179
169 if (context.inSymbol) { 180 if (context.inSymbol) {
170 push(analyzerToken); 181 push(analyzerToken);
171 return; 182 return;
172 } 183 }
173 184
174 SimpleIdentifier identifier = ast.simpleIdentifier(analyzerToken); 185 SimpleIdentifier identifier = ast.simpleIdentifier(analyzerToken);
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 1208
1198 @override 1209 @override
1199 void endTypeVariable(Token token, Token extendsOrSuper) { 1210 void endTypeVariable(Token token, Token extendsOrSuper) {
1200 // TODO(paulberry): set up scopes properly to resolve parameters and type 1211 // TODO(paulberry): set up scopes properly to resolve parameters and type
1201 // variables. Note that this is tricky due to the handling of initializers 1212 // variables. Note that this is tricky due to the handling of initializers
1202 // in constructors, so the logic should be shared with BodyBuilder as much 1213 // in constructors, so the logic should be shared with BodyBuilder as much
1203 // as possible. 1214 // as possible.
1204 debugEvent("TypeVariable"); 1215 debugEvent("TypeVariable");
1205 TypeAnnotation bound = pop(); 1216 TypeAnnotation bound = pop();
1206 SimpleIdentifier name = pop(); 1217 SimpleIdentifier name = pop();
1207 List<Annotation> metadata = null; // TODO(paulberry) 1218 List<Annotation> metadata = pop();
1208 // TODO(paulberry): capture doc comments. See dartbug.com/28851. 1219 Comment comment = pop();
1209 Comment comment = null;
1210 push(ast.typeParameter( 1220 push(ast.typeParameter(
1211 comment, metadata, name, toAnalyzerToken(extendsOrSuper), bound)); 1221 comment, metadata, name, toAnalyzerToken(extendsOrSuper), bound));
1212 } 1222 }
1213 1223
1214 @override 1224 @override
1215 void endTypeVariables(int count, Token beginToken, Token endToken) { 1225 void endTypeVariables(int count, Token beginToken, Token endToken) {
1216 debugEvent("TypeVariables"); 1226 debugEvent("TypeVariables");
1217 List<TypeParameter> typeParameters = popList(count); 1227 List<TypeParameter> typeParameters = popList(count);
1218 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters, 1228 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters,
1219 toAnalyzerToken(endToken))); 1229 toAnalyzerToken(endToken)));
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 } else if (identical('static', s)) { 1524 } else if (identical('static', s)) {
1515 staticKeyword = token; 1525 staticKeyword = token;
1516 } else if (identical('var', s)) { 1526 } else if (identical('var', s)) {
1517 finalConstOrVarKeyword = token; 1527 finalConstOrVarKeyword = token;
1518 } else { 1528 } else {
1519 internalError('Unhandled modifier: $s'); 1529 internalError('Unhandled modifier: $s');
1520 } 1530 }
1521 } 1531 }
1522 } 1532 }
1523 } 1533 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698