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.solve_report; | 5 library pub.solver.solve_report; |
6 | 6 |
7 import '../lock_file.dart'; | 7 import '../lock_file.dart'; |
8 import '../log.dart' as log; | 8 import '../log.dart' as log; |
9 import '../package.dart'; | 9 import '../package.dart'; |
10 import '../source_registry.dart'; | 10 import '../source_registry.dart'; |
11 import '../utils.dart'; | 11 import '../utils.dart'; |
12 import 'version_solver.dart'; | 12 import 'version_solver.dart'; |
13 | 13 |
14 /// Generates and displays nicely formatted reports for the results of running | 14 /// Generates and displays nicely formatted reports for the results of running |
15 /// a version resolution. | 15 /// a version resolution. |
16 /// | 16 /// |
17 /// If [showAll] is true, then all of the previous and current dependencies | 17 /// If [showAll] is true, then all of the previous and current dependencies |
18 /// are shown and their changes relative to the previous lock file are | 18 /// are shown and their changes relative to the previous lock file are |
19 /// highlighted. Otherwise, only overrides are shown. | 19 /// highlighted. Otherwise, only overrides are shown. |
20 /// | 20 /// |
21 /// Returns the number of changed dependencies. | 21 /// Returns the number of changed dependencies. |
22 int show(SourceRegistry sources, Package root, LockFile previousLockFile, | 22 int show(SourceRegistry sources, Package root, LockFile previousLockFile, |
23 SolveResult result, {bool showAll: false}) { | 23 SolveResult result, {bool showAll: false}) { |
24 var report = new _SolveReport(sources, root, previousLockFile, result); | 24 var report = new _SolveReport(sources, root, previousLockFile, result); |
25 return report.show(showAll: showAll); | 25 return report.show(showAll: showAll); |
26 } | 26 } |
27 | 27 |
28 /// Unlike [SolveResult], which is the static data describing a resolution, | 28 /// Unlike [SolveResult], which is the static data describing a resolution, |
29 /// this class contains the mutable state used while generating the report | 29 /// this class contains the mutable state used while generating the report |
30 /// itself. It's a report builder. | 30 /// itself. |
| 31 /// |
| 32 /// It's a report builder. |
31 class _SolveReport { | 33 class _SolveReport { |
32 final SourceRegistry _sources; | 34 final SourceRegistry _sources; |
33 final Package _root; | 35 final Package _root; |
34 final LockFile _previousLockFile; | 36 final LockFile _previousLockFile; |
35 final SolveResult _result; | 37 final SolveResult _result; |
36 | 38 |
37 /// The dependencies in [_result], keyed by package name. | 39 /// The dependencies in [_result], keyed by package name. |
38 final _dependencies = new Map<String, PackageId>(); | 40 final _dependencies = new Map<String, PackageId>(); |
39 | 41 |
40 final _output = new StringBuffer(); | 42 final _output = new StringBuffer(); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 void _writeId(PackageId id) { | 224 void _writeId(PackageId id) { |
223 _output.write(id.version); | 225 _output.write(id.version); |
224 | 226 |
225 var source = _sources[id.source]; | 227 var source = _sources[id.source]; |
226 if (source != _sources.defaultSource) { | 228 if (source != _sources.defaultSource) { |
227 var description = source.formatDescription(_root.dir, id.description); | 229 var description = source.formatDescription(_root.dir, id.description); |
228 _output.write(" from ${id.source} $description"); | 230 _output.write(" from ${id.source} $description"); |
229 } | 231 } |
230 } | 232 } |
231 } | 233 } |
OLD | NEW |