| 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' hide Resource; | 7 import 'dart:core' hide Resource; |
| 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'; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 */ | 288 */ |
| 289 Map<PubPackage, PackageBundle> getUnlinkedBundles(AnalysisContext context) { | 289 Map<PubPackage, PackageBundle> getUnlinkedBundles(AnalysisContext context) { |
| 290 bool strong = context.analysisOptions.strongMode; | 290 bool strong = context.analysisOptions.strongMode; |
| 291 Map<PubPackage, PackageBundle> unlinkedBundles = | 291 Map<PubPackage, PackageBundle> unlinkedBundles = |
| 292 new HashMap<PubPackage, PackageBundle>(); | 292 new HashMap<PubPackage, PackageBundle>(); |
| 293 Map<String, List<Folder>> packageMap = context.sourceFactory.packageMap; | 293 Map<String, List<Folder>> packageMap = context.sourceFactory.packageMap; |
| 294 if (packageMap != null) { | 294 if (packageMap != null) { |
| 295 packageMap.forEach((String packageName, List<Folder> libFolders) { | 295 packageMap.forEach((String packageName, List<Folder> libFolders) { |
| 296 if (libFolders.length == 1) { | 296 if (libFolders.length == 1) { |
| 297 Folder libFolder = libFolders.first; | 297 Folder libFolder = libFolders.first; |
| 298 // TODO(scheglov) handle Flutter packages, outside of the pub cache. | 298 PubPackage package = new PubPackage(packageName, libFolder); |
| 299 if (isPathInPubCache(pathContext, libFolder.path)) { | 299 PackageBundle unlinkedBundle = |
| 300 PubPackage package = new PubPackage(packageName, libFolder); | 300 _getUnlinkedOrSchedule(package, strong); |
| 301 PackageBundle unlinkedBundle = | 301 if (unlinkedBundle != null) { |
| 302 _getUnlinkedOrSchedule(package, strong); | 302 unlinkedBundles[package] = unlinkedBundle; |
| 303 if (unlinkedBundle != null) { | |
| 304 unlinkedBundles[package] = unlinkedBundle; | |
| 305 } | |
| 306 } | 303 } |
| 307 } | 304 } |
| 308 }); | 305 }); |
| 309 } | 306 } |
| 310 return unlinkedBundles; | 307 return unlinkedBundles; |
| 311 } | 308 } |
| 312 | 309 |
| 313 /** | 310 /** |
| 314 * Compute unlinked bundle for a package from [packagesToComputeUnlinked], | 311 * Compute unlinked bundle for a package from [packagesToComputeUnlinked], |
| 315 * and schedule delayed computation for the next package, if any. | 312 * and schedule delayed computation for the next package, if any. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 if (unlinkedFile.exists) { | 416 if (unlinkedFile.exists) { |
| 420 try { | 417 try { |
| 421 List<int> bytes = unlinkedFile.readAsBytesSync(); | 418 List<int> bytes = unlinkedFile.readAsBytesSync(); |
| 422 bundle = new PackageBundle.fromBuffer(bytes); | 419 bundle = new PackageBundle.fromBuffer(bytes); |
| 423 unlinkedBundleMap[package] = bundle; | 420 unlinkedBundleMap[package] = bundle; |
| 424 return bundle; | 421 return bundle; |
| 425 } on FileSystemException { | 422 } on FileSystemException { |
| 426 // Ignore file system exceptions. | 423 // Ignore file system exceptions. |
| 427 } | 424 } |
| 428 } | 425 } |
| 429 // Schedule computation in the background. | 426 // Schedule computation in the background, if in the pub cache. |
| 430 if (package != null && seenPackages.add(package)) { | 427 if (isPathInPubCache(pathContext, package.folder.path)) { |
| 431 if (packagesToComputeUnlinked.isEmpty) { | 428 if (seenPackages.add(package)) { |
| 432 _scheduleNextUnlinked(); | 429 if (packagesToComputeUnlinked.isEmpty) { |
| 430 _scheduleNextUnlinked(); |
| 431 } |
| 432 packagesToComputeUnlinked.add(package); |
| 433 } | 433 } |
| 434 packagesToComputeUnlinked.add(package); | |
| 435 } | 434 } |
| 436 // The bundle is for available. | 435 // The bundle is for available. |
| 437 return null; | 436 return null; |
| 438 } | 437 } |
| 439 | 438 |
| 440 /** | 439 /** |
| 441 * Parse the given [source] into AST. | 440 * Parse the given [source] into AST. |
| 442 */ | 441 */ |
| 443 CompilationUnit _parse(Source source, bool strong) { | 442 CompilationUnit _parse(Source source, bool strong) { |
| 444 String code = source.contents.data; | 443 String code = source.contents.data; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 } | 606 } |
| 608 }); | 607 }); |
| 609 node.linkedBuilder = assembler.assemble(); | 608 node.linkedBuilder = assembler.assemble(); |
| 610 store.addBundle(null, node.linkedBuilder); | 609 store.addBundle(null, node.linkedBuilder); |
| 611 } | 610 } |
| 612 } else { | 611 } else { |
| 613 scc.forEach((node) => node.failed = true); | 612 scc.forEach((node) => node.failed = true); |
| 614 } | 613 } |
| 615 } | 614 } |
| 616 } | 615 } |
| OLD | NEW |