| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 summary_resynthesizer; | 5 library summary_resynthesizer; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 10 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
| (...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 SimpleIdentifier constructorName = constExpr.constructorName.name; | 1514 SimpleIdentifier constructorName = constExpr.constructorName.name; |
| 1515 if (typeName is SimpleIdentifier && constructorName != null) { | 1515 if (typeName is SimpleIdentifier && constructorName != null) { |
| 1516 // E.g. `@cls.ctor()`. Since `cls.ctor` would have been parsed as | 1516 // E.g. `@cls.ctor()`. Since `cls.ctor` would have been parsed as |
| 1517 // a PrefixedIdentifier, we need to resynthesize it as one. | 1517 // a PrefixedIdentifier, we need to resynthesize it as one. |
| 1518 typeName = AstTestFactory.identifier(typeName, constructorName); | 1518 typeName = AstTestFactory.identifier(typeName, constructorName); |
| 1519 constructorName = null; | 1519 constructorName = null; |
| 1520 } | 1520 } |
| 1521 elementAnnotation.annotationAst = AstTestFactory.annotation2( | 1521 elementAnnotation.annotationAst = AstTestFactory.annotation2( |
| 1522 typeName, constructorName, constExpr.argumentList) | 1522 typeName, constructorName, constExpr.argumentList) |
| 1523 ..element = constExpr.staticElement; | 1523 ..element = constExpr.staticElement; |
| 1524 } else if (constExpr is PropertyAccess) { |
| 1525 var target = constExpr.target as Identifier; |
| 1526 var propertyName = constExpr.propertyName; |
| 1527 ArgumentList arguments = |
| 1528 constExpr.getProperty(_ConstExprBuilder.ARGUMENT_LIST); |
| 1529 elementAnnotation.element = propertyName.staticElement; |
| 1530 elementAnnotation.annotationAst = AstTestFactory.annotation2( |
| 1531 target, propertyName, arguments) |
| 1532 ..element = propertyName.staticElement; |
| 1524 } else { | 1533 } else { |
| 1525 throw new StateError( | 1534 throw new StateError( |
| 1526 'Unexpected annotation type: ${constExpr.runtimeType}'); | 1535 'Unexpected annotation type: ${constExpr.runtimeType}'); |
| 1527 } | 1536 } |
| 1528 return elementAnnotation; | 1537 return elementAnnotation; |
| 1529 } | 1538 } |
| 1530 | 1539 |
| 1531 /** | 1540 /** |
| 1532 * Build an implicit getter for the given [property] and bind it to the | 1541 * Build an implicit getter for the given [property] and bind it to the |
| 1533 * [property] and to its enclosing element. | 1542 * [property] and to its enclosing element. |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 static String _getElementIdentifier(String name, ReferenceKind kind) { | 1879 static String _getElementIdentifier(String name, ReferenceKind kind) { |
| 1871 if (kind == ReferenceKind.topLevelPropertyAccessor || | 1880 if (kind == ReferenceKind.topLevelPropertyAccessor || |
| 1872 kind == ReferenceKind.propertyAccessor) { | 1881 kind == ReferenceKind.propertyAccessor) { |
| 1873 if (!name.endsWith('=')) { | 1882 if (!name.endsWith('=')) { |
| 1874 return name + '?'; | 1883 return name + '?'; |
| 1875 } | 1884 } |
| 1876 } | 1885 } |
| 1877 return name; | 1886 return name; |
| 1878 } | 1887 } |
| 1879 } | 1888 } |
| OLD | NEW |