| 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'; | |
| 11 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| 12 import 'package:analyzer/dart/element/element.dart'; | 11 import 'package:analyzer/dart/element/element.dart'; |
| 13 import 'package:analyzer/dart/element/type.dart'; | 12 import 'package:analyzer/dart/element/type.dart'; |
| 14 import 'package:analyzer/src/dart/element/element.dart'; | 13 import 'package:analyzer/src/dart/element/element.dart'; |
| 15 import 'package:analyzer/src/dart/element/handle.dart'; | 14 import 'package:analyzer/src/dart/element/handle.dart'; |
| 16 import 'package:analyzer/src/dart/element/member.dart'; | 15 import 'package:analyzer/src/dart/element/member.dart'; |
| 17 import 'package:analyzer/src/dart/element/type.dart'; | 16 import 'package:analyzer/src/dart/element/type.dart'; |
| 18 import 'package:analyzer/src/generated/engine.dart'; | 17 import 'package:analyzer/src/generated/engine.dart'; |
| 19 import 'package:analyzer/src/generated/resolver.dart'; | 18 import 'package:analyzer/src/generated/resolver.dart'; |
| 20 import 'package:analyzer/src/generated/source_io.dart'; | 19 import 'package:analyzer/src/generated/source_io.dart'; |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 node.type = type; | 581 node.type = type; |
| 583 (node.name as SimpleIdentifier).staticElement = type.element; | 582 (node.name as SimpleIdentifier).staticElement = type.element; |
| 584 return node; | 583 return node; |
| 585 } | 584 } |
| 586 | 585 |
| 587 PropertyAccessorElement _getStringLengthElement() => | 586 PropertyAccessorElement _getStringLengthElement() => |
| 588 resynthesizer.typeProvider.stringType.getGetter('length'); | 587 resynthesizer.typeProvider.stringType.getGetter('length'); |
| 589 | 588 |
| 590 InterpolationElement _newInterpolationElement(Expression expr) { | 589 InterpolationElement _newInterpolationElement(Expression expr) { |
| 591 if (expr is SimpleStringLiteral) { | 590 if (expr is SimpleStringLiteral) { |
| 592 return astFactory.interpolationString(expr.literal, expr.value); | 591 return new InterpolationString(expr.literal, expr.value); |
| 593 } else { | 592 } else { |
| 594 return astFactory.interpolationExpression( | 593 return new InterpolationExpression( |
| 595 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION), | 594 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION), |
| 596 expr, | 595 expr, |
| 597 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); | 596 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); |
| 598 } | 597 } |
| 599 } | 598 } |
| 600 | 599 |
| 601 /** | 600 /** |
| 602 * Convert the next reference to the [DartType] and return the AST | 601 * Convert the next reference to the [DartType] and return the AST |
| 603 * corresponding to this type. | 602 * corresponding to this type. |
| 604 */ | 603 */ |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 TypeArgumentList typeArguments; | 707 TypeArgumentList typeArguments; |
| 709 int numTypeArguments = uc.ints[intPtr++]; | 708 int numTypeArguments = uc.ints[intPtr++]; |
| 710 if (numTypeArguments > 0) { | 709 if (numTypeArguments > 0) { |
| 711 List<TypeName> typeNames = new List<TypeName>(numTypeArguments); | 710 List<TypeName> typeNames = new List<TypeName>(numTypeArguments); |
| 712 for (int i = 0; i < numTypeArguments; i++) { | 711 for (int i = 0; i < numTypeArguments; i++) { |
| 713 typeNames[i] = _newTypeName(); | 712 typeNames[i] = _newTypeName(); |
| 714 } | 713 } |
| 715 typeArguments = AstTestFactory.typeArgumentList(typeNames); | 714 typeArguments = AstTestFactory.typeArgumentList(typeNames); |
| 716 } | 715 } |
| 717 if (node is SimpleIdentifier) { | 716 if (node is SimpleIdentifier) { |
| 718 _push(astFactory.methodInvocation( | 717 _push(new MethodInvocation( |
| 719 null, | 718 null, |
| 720 TokenFactory.tokenFromType(TokenType.PERIOD), | 719 TokenFactory.tokenFromType(TokenType.PERIOD), |
| 721 node, | 720 node, |
| 722 typeArguments, | 721 typeArguments, |
| 723 AstTestFactory.argumentList(arguments))); | 722 AstTestFactory.argumentList(arguments))); |
| 724 } else { | 723 } else { |
| 725 throw new UnimplementedError('For ${node?.runtimeType}: $node'); | 724 throw new UnimplementedError('For ${node?.runtimeType}: $node'); |
| 726 } | 725 } |
| 727 } | 726 } |
| 728 | 727 |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 static String _getElementIdentifier(String name, ReferenceKind kind) { | 1887 static String _getElementIdentifier(String name, ReferenceKind kind) { |
| 1889 if (kind == ReferenceKind.topLevelPropertyAccessor || | 1888 if (kind == ReferenceKind.topLevelPropertyAccessor || |
| 1890 kind == ReferenceKind.propertyAccessor) { | 1889 kind == ReferenceKind.propertyAccessor) { |
| 1891 if (!name.endsWith('=')) { | 1890 if (!name.endsWith('=')) { |
| 1892 return name + '?'; | 1891 return name + '?'; |
| 1893 } | 1892 } |
| 1894 } | 1893 } |
| 1895 return name; | 1894 return name; |
| 1896 } | 1895 } |
| 1897 } | 1896 } |
| OLD | NEW |