| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 pub.solver.dependency_queue; | 5 library pub.solver.dependency_queue; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection' show Queue; | 8 import 'dart:collection' show Queue; |
| 9 | 9 |
| 10 import '../log.dart' as log; | 10 import '../log.dart' as log; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 _isSorted = true; | 118 _isSorted = true; |
| 119 }); | 119 }); |
| 120 | 120 |
| 121 return _sortFuture; | 121 return _sortFuture; |
| 122 } | 122 } |
| 123 | 123 |
| 124 /// Given a dependency, returns a future that completes to the number of | 124 /// Given a dependency, returns a future that completes to the number of |
| 125 /// versions available for it. | 125 /// versions available for it. |
| 126 Future<int> _getNumVersions(PackageDep dep) { | 126 Future<int> _getNumVersions(PackageDep dep) { |
| 127 // There is only ever one version of the root package. | 127 // There is only ever one version of the root package. |
| 128 if (dep.isRoot) { | 128 if (dep.isRoot) return new Future.value(1); |
| 129 return new Future.value(1); | |
| 130 } | |
| 131 | 129 |
| 132 return _solver.cache.getVersions(dep.toRef()).then((versions) { | 130 return _solver.cache.getVersions(dep.toRef()) |
| 133 return versions.length; | 131 .then((versions) => versions.length); |
| 134 }).catchError((error, trace) { | |
| 135 // If it fails for any reason, just treat that as no versions. This | |
| 136 // will sort this reference higher so that we can traverse into it | |
| 137 // and report the error more properly. | |
| 138 log.solver("Could not get versions for $dep:\n$error\n\n$trace"); | |
| 139 return 0; | |
| 140 }); | |
| 141 } | 132 } |
| 142 } | 133 } |
| OLD | NEW |