| 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 serialization.elements; | 5 library serialization.elements; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 for (MethodElement method in cls.methods) { | 610 for (MethodElement method in cls.methods) { |
| 611 if (method.isStatic && method.isPublic) { | 611 if (method.isStatic && method.isPublic) { |
| 612 // TODO(paulberry): should numTypeParameters include class params? | 612 // TODO(paulberry): should numTypeParameters include class params? |
| 613 bs.add(new UnlinkedPublicNameBuilder( | 613 bs.add(new UnlinkedPublicNameBuilder( |
| 614 name: method.name, | 614 name: method.name, |
| 615 kind: ReferenceKind.method, | 615 kind: ReferenceKind.method, |
| 616 numTypeParameters: method.typeParameters.length)); | 616 numTypeParameters: method.typeParameters.length)); |
| 617 } | 617 } |
| 618 } | 618 } |
| 619 for (PropertyAccessorElement accessor in cls.accessors) { | 619 for (PropertyAccessorElement accessor in cls.accessors) { |
| 620 if (accessor.isStatic && | 620 if (accessor.isStatic && accessor.isGetter && accessor.isPublic) { |
| 621 accessor.isGetter && | |
| 622 accessor.isPublic) { | |
| 623 // TODO(paulberry): should numTypeParameters include class params? | 621 // TODO(paulberry): should numTypeParameters include class params? |
| 624 bs.add(new UnlinkedPublicNameBuilder( | 622 bs.add(new UnlinkedPublicNameBuilder( |
| 625 name: accessor.name, kind: ReferenceKind.propertyAccessor)); | 623 name: accessor.name, kind: ReferenceKind.propertyAccessor)); |
| 626 } | 624 } |
| 627 } | 625 } |
| 628 for (ConstructorElement constructor in cls.constructors) { | 626 for (ConstructorElement constructor in cls.constructors) { |
| 629 if (constructor.isPublic && constructor.name.isNotEmpty) { | 627 if (constructor.isPublic && constructor.name.isNotEmpty) { |
| 630 // TODO(paulberry): should numTypeParameters include class params? | 628 // TODO(paulberry): should numTypeParameters include class params? |
| 631 bs.add(new UnlinkedPublicNameBuilder( | 629 bs.add(new UnlinkedPublicNameBuilder( |
| 632 name: constructor.name, | 630 name: constructor.name, |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 } else { | 1065 } else { |
| 1068 throw new StateError( | 1066 throw new StateError( |
| 1069 'Unexpected element enclosing parameter: ${parent.runtimeType}')
; | 1067 'Unexpected element enclosing parameter: ${parent.runtimeType}')
; |
| 1070 } | 1068 } |
| 1071 } | 1069 } |
| 1072 } else { | 1070 } else { |
| 1073 b.reference = serializeReferenceForType(type); | 1071 b.reference = serializeReferenceForType(type); |
| 1074 } | 1072 } |
| 1075 List<DartType> typeArguments = getTypeArguments(type); | 1073 List<DartType> typeArguments = getTypeArguments(type); |
| 1076 if (typeArguments != null) { | 1074 if (typeArguments != null) { |
| 1077 // Trailing type arguments of type 'dynamic' should be omitted. | 1075 b.typeArguments = typeArguments |
| 1078 int numArgsToSerialize = typeArguments.length; | 1076 .map((typeArgument) => serializeTypeRef(typeArgument, context)) |
| 1079 while (numArgsToSerialize > 0 && | 1077 .toList(); |
| 1080 typeArguments[numArgsToSerialize - 1].isDynamic) { | |
| 1081 --numArgsToSerialize; | |
| 1082 } | |
| 1083 if (numArgsToSerialize > 0) { | |
| 1084 List<EntityRefBuilder> serializedArguments = <EntityRefBuilder>[]; | |
| 1085 for (int i = 0; i < numArgsToSerialize; i++) { | |
| 1086 serializedArguments | |
| 1087 .add(serializeTypeRef(typeArguments[i], context)); | |
| 1088 } | |
| 1089 b.typeArguments = serializedArguments; | |
| 1090 } | |
| 1091 } | 1078 } |
| 1092 } | 1079 } |
| 1093 return b; | 1080 return b; |
| 1094 } | 1081 } |
| 1095 | 1082 |
| 1096 /** | 1083 /** |
| 1097 * Create a new entry in the references table ([UnlinkedUnit.references] | 1084 * Create a new entry in the references table ([UnlinkedUnit.references] |
| 1098 * and [LinkedUnit.references]) representing an entity having the given | 1085 * and [LinkedUnit.references]) representing an entity having the given |
| 1099 * [name] and [kind]. If [unit] is given, it is the index of the compilation | 1086 * [name] and [kind]. If [unit] is given, it is the index of the compilation |
| 1100 * unit containing the entity being referred to. If [prefixReference] is | 1087 * unit containing the entity being referred to. If [prefixReference] is |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 exportNames.add(new LinkedExportNameBuilder( | 1655 exportNames.add(new LinkedExportNameBuilder( |
| 1669 name: name, | 1656 name: name, |
| 1670 dependency: serializeDependency(dependentLibrary), | 1657 dependency: serializeDependency(dependentLibrary), |
| 1671 unit: unit, | 1658 unit: unit, |
| 1672 kind: kind)); | 1659 kind: kind)); |
| 1673 } | 1660 } |
| 1674 pb.exportNames = exportNames; | 1661 pb.exportNames = exportNames; |
| 1675 return pb; | 1662 return pb; |
| 1676 } | 1663 } |
| 1677 } | 1664 } |
| OLD | NEW |