| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 b.hides = combinator.hiddenNames; | 431 b.hides = combinator.hiddenNames; |
| 432 } | 432 } |
| 433 return b; | 433 return b; |
| 434 } | 434 } |
| 435 | 435 |
| 436 /** | 436 /** |
| 437 * Serialize the given [expression], creating an [UnlinkedConstBuilder]. | 437 * Serialize the given [expression], creating an [UnlinkedConstBuilder]. |
| 438 */ | 438 */ |
| 439 UnlinkedConstBuilder serializeConstExpr(Expression expression) { | 439 UnlinkedConstBuilder serializeConstExpr(Expression expression) { |
| 440 _ConstExprSerializer serializer = new _ConstExprSerializer(this); | 440 _ConstExprSerializer serializer = new _ConstExprSerializer(this); |
| 441 serializer.serialize(expression); | 441 return serializer.serialize(expression); |
| 442 return serializer.toBuilder(); | |
| 443 } | 442 } |
| 444 | 443 |
| 445 /** | 444 /** |
| 446 * Serialize documentation from the given [element], creating an | 445 * Serialize documentation from the given [element], creating an |
| 447 * [UnlinkedDocumentationComment]. | 446 * [UnlinkedDocumentationComment]. |
| 448 * | 447 * |
| 449 * If [element] has no documentation, `null` is returned. | 448 * If [element] has no documentation, `null` is returned. |
| 450 */ | 449 */ |
| 451 UnlinkedDocumentationCommentBuilder serializeDocumentation(Element element) { | 450 UnlinkedDocumentationCommentBuilder serializeDocumentation(Element element) { |
| 452 if (element.documentationComment == null) { | 451 if (element.documentationComment == null) { |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 } | 937 } |
| 939 } | 938 } |
| 940 | 939 |
| 941 EntityRefBuilder serializeIdentifier(Identifier identifier) { | 940 EntityRefBuilder serializeIdentifier(Identifier identifier) { |
| 942 Element element = identifier.staticElement; | 941 Element element = identifier.staticElement; |
| 943 assert(element != null); | 942 assert(element != null); |
| 944 // The only supported instance property accessor - `length`. | 943 // The only supported instance property accessor - `length`. |
| 945 if (identifier is PrefixedIdentifier && | 944 if (identifier is PrefixedIdentifier && |
| 946 element is PropertyAccessorElement && | 945 element is PropertyAccessorElement && |
| 947 !element.isStatic) { | 946 !element.isStatic) { |
| 948 assert(element.name == 'length'); | 947 if (element.name != 'length') { |
| 948 throw new StateError('Only "length" property is allowed in constants.'); |
| 949 } |
| 949 Element prefixElement = identifier.prefix.staticElement; | 950 Element prefixElement = identifier.prefix.staticElement; |
| 950 int prefixRef = serializer._getElementReferenceId(prefixElement); | 951 int prefixRef = serializer._getElementReferenceId(prefixElement); |
| 951 int lengthRef = serializer._getLengthPropertyReference(prefixRef); | 952 int lengthRef = serializer._getLengthPropertyReference(prefixRef); |
| 952 return new EntityRefBuilder(reference: lengthRef); | 953 return new EntityRefBuilder(reference: lengthRef); |
| 953 } | 954 } |
| 954 return new EntityRefBuilder( | 955 return new EntityRefBuilder( |
| 955 reference: serializer._getElementReferenceId(element)); | 956 reference: serializer._getElementReferenceId(element)); |
| 956 } | 957 } |
| 957 | 958 |
| 958 @override | 959 @override |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 exportNames.add(new LinkedExportNameBuilder( | 1165 exportNames.add(new LinkedExportNameBuilder( |
| 1165 name: name, | 1166 name: name, |
| 1166 dependency: serializeDependency(dependentLibrary), | 1167 dependency: serializeDependency(dependentLibrary), |
| 1167 unit: unit, | 1168 unit: unit, |
| 1168 kind: kind)); | 1169 kind: kind)); |
| 1169 } | 1170 } |
| 1170 pb.exportNames = exportNames; | 1171 pb.exportNames = exportNames; |
| 1171 return pb; | 1172 return pb; |
| 1172 } | 1173 } |
| 1173 } | 1174 } |
| OLD | NEW |