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 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 TypeParameterList typeParameters = pop(); // TODO(paulberry) | 1492 TypeParameterList typeParameters = pop(); // TODO(paulberry) |
1493 var name = pop(); | 1493 var name = pop(); |
1494 TypeAnnotation returnType = pop(); // TODO(paulberry) | 1494 TypeAnnotation returnType = pop(); // TODO(paulberry) |
1495 _Modifiers modifiers = pop(); | 1495 _Modifiers modifiers = pop(); |
1496 List<Annotation> metadata = pop(); | 1496 List<Annotation> metadata = pop(); |
1497 Comment comment = pop(); | 1497 Comment comment = pop(); |
1498 | 1498 |
1499 var initializers = <ConstructorInitializer>[]; | 1499 var initializers = <ConstructorInitializer>[]; |
1500 for (Object initializerObject in initializerObjects) { | 1500 for (Object initializerObject in initializerObjects) { |
1501 if (initializerObject is FunctionExpressionInvocation) { | 1501 if (initializerObject is FunctionExpressionInvocation) { |
1502 var superExpression = initializerObject.function as SuperExpression; | 1502 Expression function = initializerObject.function; |
1503 initializers.add(ast.superConstructorInvocation( | 1503 if (function is SuperExpression) { |
1504 superExpression.superKeyword, | 1504 initializers.add(ast.superConstructorInvocation(function.superKeyword, |
1505 null, | 1505 null, null, initializerObject.argumentList)); |
1506 null, | 1506 } else { |
1507 initializerObject.argumentList)); | 1507 initializers.add(ast.redirectingConstructorInvocation( |
| 1508 (function as ThisExpression).thisKeyword, |
| 1509 null, |
| 1510 null, |
| 1511 initializerObject.argumentList)); |
| 1512 } |
1508 } else if (initializerObject is MethodInvocation) { | 1513 } else if (initializerObject is MethodInvocation) { |
1509 var superExpression = initializerObject.target as SuperExpression; | 1514 Expression target = initializerObject.target; |
1510 initializers.add(ast.superConstructorInvocation( | 1515 if (target is SuperExpression) { |
1511 superExpression.superKeyword, | 1516 initializers.add(ast.superConstructorInvocation( |
1512 initializerObject.operator, | 1517 target.superKeyword, |
1513 initializerObject.methodName, | 1518 initializerObject.operator, |
1514 initializerObject.argumentList)); | 1519 initializerObject.methodName, |
| 1520 initializerObject.argumentList)); |
| 1521 } else { |
| 1522 initializers.add(ast.redirectingConstructorInvocation( |
| 1523 (target as ThisExpression).thisKeyword, |
| 1524 initializerObject.operator, |
| 1525 initializerObject.methodName, |
| 1526 initializerObject.argumentList)); |
| 1527 } |
1515 } else if (initializerObject is AssignmentExpression) { | 1528 } else if (initializerObject is AssignmentExpression) { |
1516 analyzer.Token thisKeyword; | 1529 analyzer.Token thisKeyword; |
1517 analyzer.Token period; | 1530 analyzer.Token period; |
1518 SimpleIdentifier fieldName; | 1531 SimpleIdentifier fieldName; |
1519 Expression left = initializerObject.leftHandSide; | 1532 Expression left = initializerObject.leftHandSide; |
1520 if (left is PropertyAccess) { | 1533 if (left is PropertyAccess) { |
1521 var thisExpression = left.target as ThisExpression; | 1534 var thisExpression = left.target as ThisExpression; |
1522 thisKeyword = thisExpression.thisKeyword; | 1535 thisKeyword = thisExpression.thisKeyword; |
1523 period = left.operator; | 1536 period = left.operator; |
1524 fieldName = left.propertyName; | 1537 fieldName = left.propertyName; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 } else if (identical('static', s)) { | 1855 } else if (identical('static', s)) { |
1843 staticKeyword = token; | 1856 staticKeyword = token; |
1844 } else if (identical('var', s)) { | 1857 } else if (identical('var', s)) { |
1845 finalConstOrVarKeyword = token; | 1858 finalConstOrVarKeyword = token; |
1846 } else { | 1859 } else { |
1847 internalError('Unhandled modifier: $s'); | 1860 internalError('Unhandled modifier: $s'); |
1848 } | 1861 } |
1849 } | 1862 } |
1850 } | 1863 } |
1851 } | 1864 } |
OLD | NEW |