Chromium Code Reviews| Index: pkg/analyzer/lib/src/summary/resynthesize.dart |
| diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart |
| index 9f63a59a3b9a10038a067cdcf871ee40afcccbc3..d60d4dce1b08e3e82c4aa971e37780ee6258d59c 100644 |
| --- a/pkg/analyzer/lib/src/summary/resynthesize.dart |
| +++ b/pkg/analyzer/lib/src/summary/resynthesize.dart |
| @@ -413,12 +413,14 @@ class _ConstExprBuilder { |
| case UnlinkedConstOperation.pushReference: |
| EntityRef ref = uc.references[refPtr++]; |
| _ReferenceInfo info = resynthesizer.referenceInfos[ref.reference]; |
| - if (info.type != null) { |
| - Identifier node = _buildTypeIdentifierAst(info.type); |
| + if (info.element != null) { |
| + Identifier node = _buildElementAst(info.name, info.element); |
| + _push(node); |
| + } else if (info.type != null) { |
| + Identifier node = _buildElementAst(info.name, info.type.element); |
|
Paul Berry
2016/02/01 19:27:16
I bet this case (info.element == null but info.typ
scheglov
2016/02/01 19:42:18
I will try to simplify this in the next CL.
|
| _push(node); |
| } else { |
| - throw new StateError( |
| - 'Unsupported reference ${info.element?.runtimeType}'); |
| + throw new StateError('Unsupported reference ${ref.toMap()}'); |
| } |
| break; |
| case UnlinkedConstOperation.invokeConstructor: |
| @@ -430,6 +432,12 @@ class _ConstExprBuilder { |
| return stack.single; |
| } |
| + Identifier _buildElementAst(String name, Element element) { |
| + SimpleIdentifier node = AstFactory.identifier3(name); |
| + node.staticElement = element; |
| + return node; |
| + } |
| + |
| TypeName _buildTypeAst(DartType type) { |
| if (type is DynamicTypeImpl) { |
| TypeName node = AstFactory.typeName4('dynamic'); |
| @@ -447,13 +455,6 @@ class _ConstExprBuilder { |
| throw new StateError('Unsupported type $type'); |
| } |
| - Identifier _buildTypeIdentifierAst(DartType type) { |
| - String name = type.name; |
| - SimpleIdentifier node = AstFactory.identifier3(name); |
| - node.staticElement = type.element; |
| - return node; |
| - } |
| - |
| InterpolationElement _newInterpolationElement(Expression expr) { |
| if (expr is SimpleStringLiteral) { |
| return new InterpolationString(expr.literal, expr.value); |
| @@ -1479,15 +1480,17 @@ class _LibraryResynthesizer { |
| List<String> locationComponents; |
| if (containingReference != 0 && |
| referenceInfos[containingReference].element is ClassElement) { |
| + String identifier = _getElementIdentifier(name, linkedReference.kind); |
| locationComponents = referenceInfos[containingReference] |
| .element |
| .location |
| .components |
| .toList(); |
| - locationComponents.add(name); |
| + locationComponents.add(identifier); |
| } else { |
| + String identifier = _getElementIdentifier(name, linkedReference.kind); |
| locationComponents = getReferencedLocationComponents( |
| - linkedReference.dependency, linkedReference.unit, name); |
| + linkedReference.dependency, linkedReference.unit, identifier); |
| } |
| ElementLocation location = |
| new ElementLocationImpl.con3(locationComponents); |
| @@ -1499,6 +1502,10 @@ class _LibraryResynthesizer { |
| element = new FunctionTypeAliasElementHandle( |
| summaryResynthesizer, location); |
| break; |
| + case ReferenceKind.topLevelPropertyAccessor: |
| + element = new PropertyAccessorElementHandle( |
| + summaryResynthesizer, location); |
| + break; |
| case ReferenceKind.propertyAccessor: |
| assert(location.components.length == 4); |
| element = new PropertyAccessorElementHandle( |
| @@ -1574,11 +1581,26 @@ class _LibraryResynthesizer { |
| linkedTypeMap = null; |
| referenceInfos = null; |
| } |
| + |
| + /** |
| + * If the given [kind] is a top-level or class member property accessor, and |
| + * the given [name] does not end with `=`, i.e. does not denote a setter, |
| + * return the getter identifier by appending `?`. |
| + */ |
| + static String _getElementIdentifier(String name, ReferenceKind kind) { |
| + if (kind == ReferenceKind.topLevelPropertyAccessor || |
| + kind == ReferenceKind.propertyAccessor) { |
| + if (!name.endsWith('=')) { |
| + return name + '?'; |
| + } |
| + } |
| + return name; |
| + } |
| } |
| /** |
| * Data structure used during resynthesis to record all the information that is |
| - * known about how to reserialize a single entry in [LinkedUnit.references] |
| + * known about how to resynthesize a single entry in [LinkedUnit.references] |
| * (and its associated entry in [UnlinkedUnit.references], if it exists). |
| */ |
| class _ReferenceInfo { |