| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:core'; | 7 import 'dart:core'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| 11 import 'package:analyzer/error/listener.dart'; | 11 import 'package:analyzer/error/listener.dart'; |
| 12 import 'package:analyzer/file_system/file_system.dart'; | 12 import 'package:analyzer/file_system/file_system.dart'; |
| 13 import 'package:analyzer/src/dart/scanner/reader.dart'; | 13 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| 14 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 14 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
| 16 import 'package:analyzer/src/generated/parser.dart'; | 16 import 'package:analyzer/src/generated/parser.dart'; |
| 17 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
| 18 import 'package:analyzer/src/generated/utilities_collection.dart'; | 18 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 19 import 'package:analyzer/src/summary/api_signature.dart'; | 19 import 'package:analyzer/src/summary/api_signature.dart'; |
| 20 import 'package:analyzer/src/summary/format.dart'; | 20 import 'package:analyzer/src/summary/format.dart'; |
| 21 import 'package:analyzer/src/summary/idl.dart'; | 21 import 'package:analyzer/src/summary/idl.dart'; |
| 22 import 'package:analyzer/src/summary/link.dart'; | 22 import 'package:analyzer/src/summary/link.dart'; |
| 23 import 'package:analyzer/src/summary/package_bundle_reader.dart' | 23 import 'package:analyzer/src/summary/package_bundle_reader.dart' |
| 24 show ResynthesizerResultProvider, SummaryDataStore; | 24 show ResynthesizerResultProvider, SummaryDataStore; |
| 25 import 'package:analyzer/src/summary/summarize_ast.dart' | 25 import 'package:analyzer/src/summary/summarize_ast.dart' |
| 26 show serializeAstUnlinked; | 26 show serializeAstUnlinked; |
| 27 import 'package:analyzer/src/summary/summarize_elements.dart' | 27 import 'package:analyzer/src/summary/summarize_elements.dart' |
| 28 show PackageBundleAssembler; | 28 show PackageBundleAssembler; |
| 29 import 'package:analyzer/src/util/fast_uri.dart'; | |
| 30 import 'package:convert/convert.dart'; | 29 import 'package:convert/convert.dart'; |
| 31 import 'package:crypto/crypto.dart'; | 30 import 'package:crypto/crypto.dart'; |
| 32 import 'package:meta/meta.dart'; | 31 import 'package:meta/meta.dart'; |
| 33 import 'package:path/path.dart' as pathos; | 32 import 'package:path/path.dart' as pathos; |
| 34 | 33 |
| 35 /** | 34 /** |
| 36 * Unlinked and linked information about a [PubPackage]. | 35 * Unlinked and linked information about a [PubPackage]. |
| 37 */ | 36 */ |
| 38 class LinkedPubPackage { | 37 class LinkedPubPackage { |
| 39 final PubPackage package; | 38 final PubPackage package; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 PackageBundleAssembler assembler = new PackageBundleAssembler(); | 233 PackageBundleAssembler assembler = new PackageBundleAssembler(); |
| 235 | 234 |
| 236 /** | 235 /** |
| 237 * Return the `package` [Uri] for the given [path] in the `lib` folder | 236 * Return the `package` [Uri] for the given [path] in the `lib` folder |
| 238 * of the current package. | 237 * of the current package. |
| 239 */ | 238 */ |
| 240 Uri getUri(String path) { | 239 Uri getUri(String path) { |
| 241 String pathInLib = path.substring(libPath.length); | 240 String pathInLib = path.substring(libPath.length); |
| 242 String uriPath = pathos.posix.joinAll(pathContext.split(pathInLib)); | 241 String uriPath = pathos.posix.joinAll(pathContext.split(pathInLib)); |
| 243 String uriStr = 'package:${package.name}/$uriPath'; | 242 String uriStr = 'package:${package.name}/$uriPath'; |
| 244 return FastUri.parse(uriStr); | 243 return Uri.parse(uriStr); |
| 245 } | 244 } |
| 246 | 245 |
| 247 /** | 246 /** |
| 248 * If the given [file] is a Dart file, add its unlinked unit. | 247 * If the given [file] is a Dart file, add its unlinked unit. |
| 249 */ | 248 */ |
| 250 void addDartFile(File file) { | 249 void addDartFile(File file) { |
| 251 String path = file.path; | 250 String path = file.path; |
| 252 if (AnalysisEngine.isDartFileName(path)) { | 251 if (AnalysisEngine.isDartFileName(path)) { |
| 253 Uri uri = getUri(path); | 252 Uri uri = getUri(path); |
| 254 Source source = file.createSource(uri); | 253 Source source = file.createSource(uri); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 _LinkNode(this.linker, this.package, this.unlinked); | 681 _LinkNode(this.linker, this.package, this.unlinked); |
| 683 | 682 |
| 684 /** | 683 /** |
| 685 * Retrieve the dependencies of this node. | 684 * Retrieve the dependencies of this node. |
| 686 */ | 685 */ |
| 687 List<_LinkNode> get dependencies { | 686 List<_LinkNode> get dependencies { |
| 688 if (_dependencies == null) { | 687 if (_dependencies == null) { |
| 689 Set<_LinkNode> dependencies = new Set<_LinkNode>(); | 688 Set<_LinkNode> dependencies = new Set<_LinkNode>(); |
| 690 | 689 |
| 691 void appendDependency(String uriStr) { | 690 void appendDependency(String uriStr) { |
| 692 Uri uri = FastUri.parse(uriStr); | 691 Uri uri = Uri.parse(uriStr); |
| 693 if (!uri.hasScheme) { | 692 if (!uri.hasScheme) { |
| 694 // A relative path in this package, skip it. | 693 // A relative path in this package, skip it. |
| 695 } else if (uri.scheme == 'dart') { | 694 } else if (uri.scheme == 'dart') { |
| 696 // Dependency on the SDK is implicit and always added. | 695 // Dependency on the SDK is implicit and always added. |
| 697 // The SDK linked bundle is precomputed before linking packages. | 696 // The SDK linked bundle is precomputed before linking packages. |
| 698 } else if (uriStr.startsWith('package:')) { | 697 } else if (uriStr.startsWith('package:')) { |
| 699 String package = PubSummaryManager.getPackageName(uriStr); | 698 String package = PubSummaryManager.getPackageName(uriStr); |
| 700 _LinkNode packageNode = linker.packageToNode[package]; | 699 _LinkNode packageNode = linker.packageToNode[package]; |
| 701 if (packageNode == null && linker.listedPackages.isListed(uriStr)) { | 700 if (packageNode == null && linker.listedPackages.isListed(uriStr)) { |
| 702 failed = true; | 701 failed = true; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 } | 826 } |
| 828 | 827 |
| 829 /** | 828 /** |
| 830 * Check whether the given `package:` [uri] is listed in the package map. | 829 * Check whether the given `package:` [uri] is listed in the package map. |
| 831 */ | 830 */ |
| 832 bool isListed(String uri) { | 831 bool isListed(String uri) { |
| 833 String package = PubSummaryManager.getPackageName(uri); | 832 String package = PubSummaryManager.getPackageName(uri); |
| 834 return names.contains(package); | 833 return names.contains(package); |
| 835 } | 834 } |
| 836 } | 835 } |
| OLD | NEW |