Chromium Code Reviews| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) { | |
|
Paul Berry
2017/03/15 16:14:52
Note: Konstantin introduced an implementation of t
| |
| 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 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1380 | 1391 |
| 1381 @override | 1392 @override |
| 1382 void endTypeVariable(Token token, Token extendsOrSuper) { | 1393 void endTypeVariable(Token token, Token extendsOrSuper) { |
| 1383 // TODO(paulberry): set up scopes properly to resolve parameters and type | 1394 // TODO(paulberry): set up scopes properly to resolve parameters and type |
| 1384 // variables. Note that this is tricky due to the handling of initializers | 1395 // variables. Note that this is tricky due to the handling of initializers |
| 1385 // in constructors, so the logic should be shared with BodyBuilder as much | 1396 // in constructors, so the logic should be shared with BodyBuilder as much |
| 1386 // as possible. | 1397 // as possible. |
| 1387 debugEvent("TypeVariable"); | 1398 debugEvent("TypeVariable"); |
| 1388 TypeAnnotation bound = pop(); | 1399 TypeAnnotation bound = pop(); |
| 1389 SimpleIdentifier name = pop(); | 1400 SimpleIdentifier name = pop(); |
| 1390 List<Annotation> metadata = null; // TODO(paulberry) | 1401 List<Annotation> metadata = pop(); |
| 1391 // TODO(paulberry): capture doc comments. See dartbug.com/28851. | 1402 Comment comment = pop(); |
| 1392 Comment comment = null; | |
| 1393 push(ast.typeParameter( | 1403 push(ast.typeParameter( |
| 1394 comment, metadata, name, toAnalyzerToken(extendsOrSuper), bound)); | 1404 comment, metadata, name, toAnalyzerToken(extendsOrSuper), bound)); |
| 1395 } | 1405 } |
| 1396 | 1406 |
| 1397 @override | 1407 @override |
| 1398 void endTypeVariables(int count, Token beginToken, Token endToken) { | 1408 void endTypeVariables(int count, Token beginToken, Token endToken) { |
| 1399 debugEvent("TypeVariables"); | 1409 debugEvent("TypeVariables"); |
| 1400 List<TypeParameter> typeParameters = popList(count); | 1410 List<TypeParameter> typeParameters = popList(count); |
| 1401 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters, | 1411 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters, |
| 1402 toAnalyzerToken(endToken))); | 1412 toAnalyzerToken(endToken))); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1725 } else if (identical('static', s)) { | 1735 } else if (identical('static', s)) { |
| 1726 staticKeyword = token; | 1736 staticKeyword = token; |
| 1727 } else if (identical('var', s)) { | 1737 } else if (identical('var', s)) { |
| 1728 finalConstOrVarKeyword = token; | 1738 finalConstOrVarKeyword = token; |
| 1729 } else { | 1739 } else { |
| 1730 internalError('Unhandled modifier: $s'); | 1740 internalError('Unhandled modifier: $s'); |
| 1731 } | 1741 } |
| 1732 } | 1742 } |
| 1733 } | 1743 } |
| 1734 } | 1744 } |
| OLD | NEW |