| 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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 } else { | 1065 } else { |
| 1066 throw new StateError( | 1066 throw new StateError( |
| 1067 'Unexpected element enclosing parameter: ${parent.runtimeType}')
; | 1067 'Unexpected element enclosing parameter: ${parent.runtimeType}')
; |
| 1068 } | 1068 } |
| 1069 } | 1069 } |
| 1070 } else { | 1070 } else { |
| 1071 b.reference = serializeReferenceForType(type); | 1071 b.reference = serializeReferenceForType(type); |
| 1072 } | 1072 } |
| 1073 List<DartType> typeArguments = getTypeArguments(type); | 1073 List<DartType> typeArguments = getTypeArguments(type); |
| 1074 if (typeArguments != null) { | 1074 if (typeArguments != null) { |
| 1075 // Trailing type arguments of type 'dynamic' should be omitted. | 1075 b.typeArguments = typeArguments |
| 1076 int numArgsToSerialize = typeArguments.length; | 1076 .map((typeArgument) => serializeTypeRef(typeArgument, context)) |
| 1077 while (numArgsToSerialize > 0 && | 1077 .toList(); |
| 1078 typeArguments[numArgsToSerialize - 1].isDynamic) { | |
| 1079 --numArgsToSerialize; | |
| 1080 } | |
| 1081 if (numArgsToSerialize > 0) { | |
| 1082 List<EntityRefBuilder> serializedArguments = <EntityRefBuilder>[]; | |
| 1083 for (int i = 0; i < numArgsToSerialize; i++) { | |
| 1084 serializedArguments | |
| 1085 .add(serializeTypeRef(typeArguments[i], context)); | |
| 1086 } | |
| 1087 b.typeArguments = serializedArguments; | |
| 1088 } | |
| 1089 } | 1078 } |
| 1090 } | 1079 } |
| 1091 return b; | 1080 return b; |
| 1092 } | 1081 } |
| 1093 | 1082 |
| 1094 /** | 1083 /** |
| 1095 * Create a new entry in the references table ([UnlinkedUnit.references] | 1084 * Create a new entry in the references table ([UnlinkedUnit.references] |
| 1096 * and [LinkedUnit.references]) representing an entity having the given | 1085 * and [LinkedUnit.references]) representing an entity having the given |
| 1097 * [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 |
| 1098 * 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... |
| 1666 exportNames.add(new LinkedExportNameBuilder( | 1655 exportNames.add(new LinkedExportNameBuilder( |
| 1667 name: name, | 1656 name: name, |
| 1668 dependency: serializeDependency(dependentLibrary), | 1657 dependency: serializeDependency(dependentLibrary), |
| 1669 unit: unit, | 1658 unit: unit, |
| 1670 kind: kind)); | 1659 kind: kind)); |
| 1671 } | 1660 } |
| 1672 pb.exportNames = exportNames; | 1661 pb.exportNames = exportNames; |
| 1673 return pb; | 1662 return pb; |
| 1674 } | 1663 } |
| 1675 } | 1664 } |
| OLD | NEW |