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 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1541 body = ast.emptyFunctionBody(toAnalyzerToken(semicolon)); | 1541 body = ast.emptyFunctionBody(toAnalyzerToken(semicolon)); |
| 1542 } else { | 1542 } else { |
| 1543 internalError('Unexpected body object: ${bodyObject.runtimeType}'); | 1543 internalError('Unexpected body object: ${bodyObject.runtimeType}'); |
| 1544 } | 1544 } |
| 1545 | 1545 |
| 1546 FormalParameterList parameters = pop(); | 1546 FormalParameterList parameters = pop(); |
| 1547 ConstructorName constructorName = pop(); | 1547 ConstructorName constructorName = pop(); |
| 1548 _Modifiers modifiers = pop(); | 1548 _Modifiers modifiers = pop(); |
| 1549 List<Annotation> metadata = pop(); | 1549 List<Annotation> metadata = pop(); |
| 1550 Comment comment = pop(); | 1550 Comment comment = pop(); |
| 1551 | |
| 1552 // Decompose the preliminary ConstructorName into the type name and | |
| 1553 // the actual constructor name. | |
| 1554 SimpleIdentifier returnType; | |
| 1555 analyzer.Token period; | |
| 1556 SimpleIdentifier name; | |
| 1557 Identifier typeName = constructorName.type.name; | |
| 1558 if (typeName is SimpleIdentifier) { | |
| 1559 returnType = typeName; | |
| 1560 } else if (typeName is PrefixedIdentifier) { | |
| 1561 returnType = typeName.prefix; | |
| 1562 period = typeName.period; | |
| 1563 name = | |
| 1564 ast.simpleIdentifier(typeName.identifier.token, isDeclaration: true); | |
| 1565 } | |
| 1566 | |
| 1551 push(ast.constructorDeclaration( | 1567 push(ast.constructorDeclaration( |
| 1552 comment, | 1568 comment, |
| 1553 metadata, | 1569 metadata, |
| 1554 toAnalyzerToken(modifiers?.externalKeyword), | 1570 toAnalyzerToken(modifiers?.externalKeyword), |
| 1555 toAnalyzerToken(modifiers?.finalConstOrVarKeyword), | 1571 toAnalyzerToken(modifiers?.finalConstOrVarKeyword), |
| 1556 toAnalyzerToken(factoryKeyword), | 1572 factoryKeyword, |
|
Paul Berry
2017/04/06 20:36:51
Analyzer and Fasta token types have been partially
scheglov
2017/04/06 21:11:38
Done.
| |
| 1557 constructorName.type.name, | 1573 ast.simpleIdentifier(returnType.token), |
| 1558 constructorName.period, | 1574 period, |
| 1559 constructorName.name, | 1575 name, |
| 1560 parameters, | 1576 parameters, |
| 1561 toAnalyzerToken(separator), | 1577 toAnalyzerToken(separator), |
| 1562 null, | 1578 null, |
| 1563 redirectedConstructor, | 1579 redirectedConstructor, |
| 1564 body)); | 1580 body)); |
| 1565 } | 1581 } |
| 1566 | 1582 |
| 1567 void endFieldInitializer(Token assignment) { | 1583 void endFieldInitializer(Token assignment) { |
| 1568 debugEvent("FieldInitializer"); | 1584 debugEvent("FieldInitializer"); |
| 1569 Expression initializer = pop(); | 1585 Expression initializer = pop(); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1965 } else if (identical('static', s)) { | 1981 } else if (identical('static', s)) { |
| 1966 staticKeyword = token; | 1982 staticKeyword = token; |
| 1967 } else if (identical('var', s)) { | 1983 } else if (identical('var', s)) { |
| 1968 finalConstOrVarKeyword = token; | 1984 finalConstOrVarKeyword = token; |
| 1969 } else { | 1985 } else { |
| 1970 internalError('Unhandled modifier: $s'); | 1986 internalError('Unhandled modifier: $s'); |
| 1971 } | 1987 } |
| 1972 } | 1988 } |
| 1973 } | 1989 } |
| 1974 } | 1990 } |
| OLD | NEW |