| 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'; |
| 11 import 'package:analyzer/dart/element/type.dart'; | 11 import 'package:analyzer/dart/element/type.dart'; |
| 12 import 'package:analyzer/src/dart/element/element.dart'; | 12 import 'package:analyzer/src/dart/element/element.dart'; |
| 13 import 'package:analyzer/src/dart/element/member.dart'; | 13 import 'package:analyzer/src/dart/element/member.dart'; |
| 14 import 'package:analyzer/src/dart/element/type.dart'; | 14 import 'package:analyzer/src/dart/element/type.dart'; |
| 15 import 'package:analyzer/src/generated/resolver.dart'; | 15 import 'package:analyzer/src/generated/resolver.dart'; |
| 16 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
| 17 import 'package:analyzer/src/generated/utilities_dart.dart'; | 17 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 18 import 'package:analyzer/src/summary/format.dart'; | 18 import 'package:analyzer/src/summary/format.dart'; |
| 19 import 'package:analyzer/src/summary/idl.dart'; | 19 import 'package:analyzer/src/summary/idl.dart'; |
| 20 import 'package:analyzer/src/summary/name_filter.dart'; | 20 import 'package:analyzer/src/summary/name_filter.dart'; |
| 21 import 'package:analyzer/src/summary/summarize_const_expr.dart'; | 21 import 'package:analyzer/src/summary/summarize_const_expr.dart'; |
| 22 import 'package:convert/convert.dart'; |
| 22 import 'package:crypto/crypto.dart'; | 23 import 'package:crypto/crypto.dart'; |
| 23 import 'package:path/path.dart' as path; | 24 import 'package:path/path.dart' as path; |
| 24 | 25 |
| 25 /** | 26 /** |
| 26 * Serialize all the elements in [lib] to a summary using [ctx] as the context | 27 * Serialize all the elements in [lib] to a summary using [ctx] as the context |
| 27 * for building the summary, and using [typeProvider] to find built-in types. | 28 * for building the summary, and using [typeProvider] to find built-in types. |
| 28 */ | 29 */ |
| 29 LibrarySerializationResult serializeLibrary( | 30 LibrarySerializationResult serializeLibrary( |
| 30 LibraryElement lib, TypeProvider typeProvider, bool strongMode) { | 31 LibraryElement lib, TypeProvider typeProvider, bool strongMode) { |
| 31 _LibrarySerializer serializer = | 32 _LibrarySerializer serializer = |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 _unlinkedUnits.addAll(libraryResult.unlinkedUnits); | 206 _unlinkedUnits.addAll(libraryResult.unlinkedUnits); |
| 206 for (Source source in libraryResult.unitSources) { | 207 for (Source source in libraryResult.unitSources) { |
| 207 _unlinkedUnitHashes.add(_hash(source.contents.data)); | 208 _unlinkedUnitHashes.add(_hash(source.contents.data)); |
| 208 } | 209 } |
| 209 } | 210 } |
| 210 | 211 |
| 211 /** | 212 /** |
| 212 * Compute a hash of the given file contents. | 213 * Compute a hash of the given file contents. |
| 213 */ | 214 */ |
| 214 String _hash(String contents) { | 215 String _hash(String contents) { |
| 215 MD5 md5 = new MD5(); | 216 return hex.encode(md5.convert(UTF8.encode(contents)).bytes); |
| 216 md5.add(UTF8.encode(contents)); | |
| 217 return CryptoUtils.bytesToHex(md5.close()); | |
| 218 } | 217 } |
| 219 } | 218 } |
| 220 | 219 |
| 221 /** | 220 /** |
| 222 * Instances of this class keep track of intermediate state during | 221 * Instances of this class keep track of intermediate state during |
| 223 * serialization of a single compilation unit. | 222 * serialization of a single compilation unit. |
| 224 */ | 223 */ |
| 225 class _CompilationUnitSerializer { | 224 class _CompilationUnitSerializer { |
| 226 /** | 225 /** |
| 227 * The [_LibrarySerializer] which is serializing the library of which | 226 * The [_LibrarySerializer] which is serializing the library of which |
| (...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 exportNames.add(new LinkedExportNameBuilder( | 1648 exportNames.add(new LinkedExportNameBuilder( |
| 1650 name: name, | 1649 name: name, |
| 1651 dependency: serializeDependency(dependentLibrary), | 1650 dependency: serializeDependency(dependentLibrary), |
| 1652 unit: unit, | 1651 unit: unit, |
| 1653 kind: kind)); | 1652 kind: kind)); |
| 1654 } | 1653 } |
| 1655 pb.exportNames = exportNames; | 1654 pb.exportNames = exportNames; |
| 1656 return pb; | 1655 return pb; |
| 1657 } | 1656 } |
| 1658 } | 1657 } |
| OLD | NEW |