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: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 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1304 | 1304 |
1305 @override | 1305 @override |
1306 void endTypeArguments(int count, Token beginToken, Token endToken) { | 1306 void endTypeArguments(int count, Token beginToken, Token endToken) { |
1307 debugEvent("TypeArguments"); | 1307 debugEvent("TypeArguments"); |
1308 List<TypeAnnotation> arguments = popList(count); | 1308 List<TypeAnnotation> arguments = popList(count); |
1309 push(ast.typeArgumentList( | 1309 push(ast.typeArgumentList( |
1310 toAnalyzerToken(beginToken), arguments, toAnalyzerToken(endToken))); | 1310 toAnalyzerToken(beginToken), arguments, toAnalyzerToken(endToken))); |
1311 } | 1311 } |
1312 | 1312 |
1313 @override | 1313 @override |
1314 void endFields( | |
1315 int count, Token covariantKeyword, Token beginToken, Token endToken) { | |
1316 debugEvent("Fields"); | |
1317 List<VariableDeclaration> variables = popList(count); | |
1318 TypeAnnotation type = pop(); | |
1319 List<Token> modifiers = pop(); | |
1320 Token staticKeyword; | |
1321 Token keyword; | |
1322 for (Token modifier in modifiers) { | |
ahe
2017/03/01 15:20:31
Would it make sense to have something more like pk
Paul Berry
2017/03/01 21:08:22
Unfortunately that wouldn't be quite enough; the a
| |
1323 String value = modifier.stringValue; | |
1324 if (identical('static', value)) { | |
1325 // TODO(paulberry): Check the order and uniqueness. | |
ahe
2017/03/01 15:20:31
I think we should have the parser do that (while s
Paul Berry
2017/03/01 21:08:22
Agreed. There are several TODOs that say this, so
| |
1326 staticKeyword = modifier; | |
1327 } else if (identical('var', value)) { | |
1328 // TODO(paulberry): Check the order and uniqueness. | |
1329 keyword = modifier; | |
1330 } else { | |
1331 // TODO(paulberry): Report error. | |
1332 internalError("Invalid modifier ($value). Report an error."); | |
1333 } | |
1334 } | |
1335 var variableList = ast.variableDeclarationList( | |
1336 null, null, toAnalyzerToken(keyword), type, variables); | |
1337 List<Annotation> metadata = pop(); | |
1338 // TODO(paulberry): capture doc comments. See dartbug.com/28851. | |
1339 Comment comment = null; | |
1340 push(ast.fieldDeclaration2( | |
1341 comment: comment, | |
1342 metadata: metadata, | |
1343 covariantKeyword: toAnalyzerToken(covariantKeyword), | |
1344 staticKeyword: toAnalyzerToken(staticKeyword), | |
1345 fieldList: variableList, | |
1346 semicolon: toAnalyzerToken(endToken))); | |
1347 } | |
1348 | |
1349 @override | |
1314 void handleOperatorName(Token operatorKeyword, Token token) { | 1350 void handleOperatorName(Token operatorKeyword, Token token) { |
1315 debugEvent("OperatorName"); | 1351 debugEvent("OperatorName"); |
1316 push(new _OperatorName(operatorKeyword, | 1352 push(new _OperatorName(operatorKeyword, |
1317 ast.simpleIdentifier(toAnalyzerToken(token), isDeclaration: true))); | 1353 ast.simpleIdentifier(toAnalyzerToken(token), isDeclaration: true))); |
1318 } | 1354 } |
1319 | 1355 |
1320 /** | 1356 /** |
1321 * Pop the modifiers list, if the list is empty return `null`, if the list | 1357 * Pop the modifiers list, if the list is empty return `null`, if the list |
1322 * has one item return it; otherwise return `null`. | 1358 * has one item return it; otherwise return `null`. |
1323 */ | 1359 */ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1397 } | 1433 } |
1398 | 1434 |
1399 /// Data structure placed on the stack to represent the keyword "operator" | 1435 /// Data structure placed on the stack to represent the keyword "operator" |
1400 /// followed by a token. | 1436 /// followed by a token. |
1401 class _OperatorName { | 1437 class _OperatorName { |
1402 final Token operatorKeyword; | 1438 final Token operatorKeyword; |
1403 final SimpleIdentifier name; | 1439 final SimpleIdentifier name; |
1404 | 1440 |
1405 _OperatorName(this.operatorKeyword, this.name); | 1441 _OperatorName(this.operatorKeyword, this.name); |
1406 } | 1442 } |
OLD | NEW |