| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.command.list; | 5 library pub.command.list; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import '../ascii_tree.dart' as tree; | 10 import '../ascii_tree.dart' as tree; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 /// | 134 /// |
| 135 /// If a package is encountered more than once (i.e. a shared or circular | 135 /// If a package is encountered more than once (i.e. a shared or circular |
| 136 /// dependency), later ones are not traversed. This is done in breadth-first | 136 /// dependency), later ones are not traversed. This is done in breadth-first |
| 137 /// fashion so that a package will always be expanded at the shallowest | 137 /// fashion so that a package will always be expanded at the shallowest |
| 138 /// depth that it appears at. | 138 /// depth that it appears at. |
| 139 void _outputTree() { | 139 void _outputTree() { |
| 140 // The work list for the breadth-first traversal. It contains the package | 140 // The work list for the breadth-first traversal. It contains the package |
| 141 // being added to the tree, and the parent map that will receive that | 141 // being added to the tree, and the parent map that will receive that |
| 142 // package. | 142 // package. |
| 143 var toWalk = new Queue<Pair<Package, Map>>(); | 143 var toWalk = new Queue<Pair<Package, Map>>(); |
| 144 var visited = new Set<String>(); | 144 var visited = new Set<String>.from([entrypoint.root.name]); |
| 145 | 145 |
| 146 // Start with the root dependencies. | 146 // Start with the root dependencies. |
| 147 var packageTree = {}; | 147 var packageTree = {}; |
| 148 for (var dep in entrypoint.root.immediateDependencies) { | 148 for (var dep in entrypoint.root.immediateDependencies) { |
| 149 toWalk.add(new Pair(_graph.packages[dep.name], packageTree)); | 149 toWalk.add(new Pair(_graph.packages[dep.name], packageTree)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Do a breadth-first walk to the dependency graph. | 152 // Do a breadth-first walk to the dependency graph. |
| 153 while (toWalk.isNotEmpty) { | 153 while (toWalk.isNotEmpty) { |
| 154 var pair = toWalk.removeFirst(); | 154 var pair = toWalk.removeFirst(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 181 Set<String> _getTransitiveDependencies() { | 181 Set<String> _getTransitiveDependencies() { |
| 182 var transitive = _graph.packages.keys.toSet(); | 182 var transitive = _graph.packages.keys.toSet(); |
| 183 var root = entrypoint.root; | 183 var root = entrypoint.root; |
| 184 transitive.remove(root.name); | 184 transitive.remove(root.name); |
| 185 transitive.removeAll(root.dependencies.map((dep) => dep.name)); | 185 transitive.removeAll(root.dependencies.map((dep) => dep.name)); |
| 186 transitive.removeAll(root.devDependencies.map((dep) => dep.name)); | 186 transitive.removeAll(root.devDependencies.map((dep) => dep.name)); |
| 187 transitive.removeAll(root.dependencyOverrides.map((dep) => dep.name)); | 187 transitive.removeAll(root.dependencyOverrides.map((dep) => dep.name)); |
| 188 return transitive; | 188 return transitive; |
| 189 } | 189 } |
| 190 } | 190 } |
| OLD | NEW |