| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 if (e is ConstructorElement) { | 323 if (e is ConstructorElement) { |
| 324 return e; | 324 return e; |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 throw new StateError( | 327 throw new StateError( |
| 328 'Unable to find the enclosing constructor of $context'); | 328 'Unable to find the enclosing constructor of $context'); |
| 329 } | 329 } |
| 330 | 330 |
| 331 Expression build() { | 331 Expression build() { |
| 332 if (!uc.isValidConst) { | 332 if (!uc.isValidConst) { |
| 333 return AstTestFactory.identifier3(r'$$invalidConstExpr$$'); | 333 return null; |
| 334 } | 334 } |
| 335 for (UnlinkedExprOperation operation in uc.operations) { | 335 for (UnlinkedExprOperation operation in uc.operations) { |
| 336 switch (operation) { | 336 switch (operation) { |
| 337 case UnlinkedExprOperation.pushNull: | 337 case UnlinkedExprOperation.pushNull: |
| 338 _push(AstTestFactory.nullLiteral()); | 338 _push(AstTestFactory.nullLiteral()); |
| 339 break; | 339 break; |
| 340 // bool | 340 // bool |
| 341 case UnlinkedExprOperation.pushFalse: | 341 case UnlinkedExprOperation.pushFalse: |
| 342 _push(AstTestFactory.booleanLiteral(false)); | 342 _push(AstTestFactory.booleanLiteral(false)); |
| 343 break; | 343 break; |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 libraryResynthesizer.summaryResynthesizer; | 1565 libraryResynthesizer.summaryResynthesizer; |
| 1566 | 1566 |
| 1567 TypeProvider get typeProvider => summaryResynthesizer.typeProvider; | 1567 TypeProvider get typeProvider => summaryResynthesizer.typeProvider; |
| 1568 | 1568 |
| 1569 /** | 1569 /** |
| 1570 * Build [ElementAnnotationImpl] for the given [UnlinkedExpr]. | 1570 * Build [ElementAnnotationImpl] for the given [UnlinkedExpr]. |
| 1571 */ | 1571 */ |
| 1572 ElementAnnotationImpl buildAnnotation(ElementImpl context, UnlinkedExpr uc) { | 1572 ElementAnnotationImpl buildAnnotation(ElementImpl context, UnlinkedExpr uc) { |
| 1573 ElementAnnotationImpl elementAnnotation = new ElementAnnotationImpl(unit); | 1573 ElementAnnotationImpl elementAnnotation = new ElementAnnotationImpl(unit); |
| 1574 Expression constExpr = _buildConstExpression(context, uc); | 1574 Expression constExpr = _buildConstExpression(context, uc); |
| 1575 if (constExpr is Identifier) { | 1575 if (constExpr == null) { |
| 1576 // Invalid constant expression. |
| 1577 } else if (constExpr is Identifier) { |
| 1576 ArgumentList arguments = | 1578 ArgumentList arguments = |
| 1577 constExpr.getProperty(_ConstExprBuilder.ARGUMENT_LIST); | 1579 constExpr.getProperty(_ConstExprBuilder.ARGUMENT_LIST); |
| 1578 elementAnnotation.element = constExpr.staticElement; | 1580 elementAnnotation.element = constExpr.staticElement; |
| 1579 elementAnnotation.annotationAst = | 1581 elementAnnotation.annotationAst = |
| 1580 AstTestFactory.annotation2(constExpr, null, arguments); | 1582 AstTestFactory.annotation2(constExpr, null, arguments); |
| 1581 } else if (constExpr is InstanceCreationExpression) { | 1583 } else if (constExpr is InstanceCreationExpression) { |
| 1582 elementAnnotation.element = constExpr.staticElement; | 1584 elementAnnotation.element = constExpr.staticElement; |
| 1583 Identifier typeName = constExpr.constructorName.type.name; | 1585 Identifier typeName = constExpr.constructorName.type.name; |
| 1584 SimpleIdentifier constructorName = constExpr.constructorName.name; | 1586 SimpleIdentifier constructorName = constExpr.constructorName.name; |
| 1585 if (typeName is SimpleIdentifier && constructorName != null) { | 1587 if (typeName is SimpleIdentifier && constructorName != null) { |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 static String _getElementIdentifier(String name, ReferenceKind kind) { | 1991 static String _getElementIdentifier(String name, ReferenceKind kind) { |
| 1990 if (kind == ReferenceKind.topLevelPropertyAccessor || | 1992 if (kind == ReferenceKind.topLevelPropertyAccessor || |
| 1991 kind == ReferenceKind.propertyAccessor) { | 1993 kind == ReferenceKind.propertyAccessor) { |
| 1992 if (!name.endsWith('=')) { | 1994 if (!name.endsWith('=')) { |
| 1993 return name + '?'; | 1995 return name + '?'; |
| 1994 } | 1996 } |
| 1995 } | 1997 } |
| 1996 return name; | 1998 return name; |
| 1997 } | 1999 } |
| 1998 } | 2000 } |
| OLD | NEW |