| 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 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/dart/element/type.dart'; | 8 import 'package:analyzer/dart/element/type.dart'; |
| 9 import 'package:analyzer/src/dart/element/element.dart'; | 9 import 'package:analyzer/src/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/element/type.dart'; | 10 import 'package:analyzer/src/dart/element/type.dart'; |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 element is PropertyAccessorElement && | 1023 element is PropertyAccessorElement && |
| 1024 !element.isStatic) { | 1024 !element.isStatic) { |
| 1025 if (element.name != 'length') { | 1025 if (element.name != 'length') { |
| 1026 throw new StateError('Only "length" property is allowed in constants.'); | 1026 throw new StateError('Only "length" property is allowed in constants.'); |
| 1027 } | 1027 } |
| 1028 Element prefixElement = identifier.prefix.staticElement; | 1028 Element prefixElement = identifier.prefix.staticElement; |
| 1029 int prefixRef = serializer._getElementReferenceId(prefixElement); | 1029 int prefixRef = serializer._getElementReferenceId(prefixElement); |
| 1030 int lengthRef = serializer._getLengthPropertyReference(prefixRef); | 1030 int lengthRef = serializer._getLengthPropertyReference(prefixRef); |
| 1031 return new EntityRefBuilder(reference: lengthRef); | 1031 return new EntityRefBuilder(reference: lengthRef); |
| 1032 } | 1032 } |
| 1033 if (element is TypeParameterElement) { |
| 1034 throw new StateError('Constants may not refer to type parameters.'); |
| 1035 } |
| 1033 return new EntityRefBuilder( | 1036 return new EntityRefBuilder( |
| 1034 reference: serializer._getElementReferenceId(element)); | 1037 reference: serializer._getElementReferenceId(element)); |
| 1035 } | 1038 } |
| 1036 | 1039 |
| 1037 @override | 1040 @override |
| 1038 EntityRefBuilder serializePropertyAccess(PropertyAccess access) { | 1041 EntityRefBuilder serializePropertyAccess(PropertyAccess access) { |
| 1039 Element element = access.propertyName.staticElement; | 1042 Element element = access.propertyName.staticElement; |
| 1040 assert(element != null); | 1043 assert(element != null); |
| 1041 // The only supported instance property accessor - `length`. | 1044 // The only supported instance property accessor - `length`. |
| 1042 Expression target = access.target; | 1045 Expression target = access.target; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 exportNames.add(new LinkedExportNameBuilder( | 1246 exportNames.add(new LinkedExportNameBuilder( |
| 1244 name: name, | 1247 name: name, |
| 1245 dependency: serializeDependency(dependentLibrary), | 1248 dependency: serializeDependency(dependentLibrary), |
| 1246 unit: unit, | 1249 unit: unit, |
| 1247 kind: kind)); | 1250 kind: kind)); |
| 1248 } | 1251 } |
| 1249 pb.exportNames = exportNames; | 1252 pb.exportNames = exportNames; |
| 1250 return pb; | 1253 return pb; |
| 1251 } | 1254 } |
| 1252 } | 1255 } |
| OLD | NEW |