Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: sdk/lib/_internal/pub/lib/src/solver/version_solver.dart

Issue 14685002: Backjump on a source or description mismatch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 version_solver; 5 library version_solver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:json' as json; 8 import 'dart:json' as json;
9 9
10 import '../lock_file.dart'; 10 import '../lock_file.dart';
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 /// Base class for all failures that can occur while trying to resolve versions. 155 /// Base class for all failures that can occur while trying to resolve versions.
156 class SolveFailure implements Exception { 156 class SolveFailure implements Exception {
157 /// The name of the package whose version could not be solved. Will be `null` 157 /// The name of the package whose version could not be solved. Will be `null`
158 /// if the failure is not specific to one package. 158 /// if the failure is not specific to one package.
159 final String package; 159 final String package;
160 160
161 /// The known dependencies on [package] at the time of the failure. Will be 161 /// The known dependencies on [package] at the time of the failure. Will be
162 /// an empty collection if the failure is not specific to one package. 162 /// an empty collection if the failure is not specific to one package.
163 final Iterable<Dependency> dependencies; 163 final Iterable<Dependency> dependencies;
164 164
165 /// If this is `true`, then it may be possible to avoid this failure by
166 /// adjusting one of the transitive dependencies of a package in
167 /// [dependencies]. Otherwise, [dependencies] themselves are in conflict and
168 /// only changing one of those may resolve the failure.
169 bool get mayHaveTransitiveCause => true;
170
165 SolveFailure(this.package, Iterable<Dependency> dependencies) 171 SolveFailure(this.package, Iterable<Dependency> dependencies)
166 : dependencies = dependencies != null ? dependencies : <Dependency>[]; 172 : dependencies = dependencies != null ? dependencies : <Dependency>[];
167 173
168 /// Writes [dependencies] to [buffer] as a bullet list. If [describe] is 174 /// Writes [dependencies] to [buffer] as a bullet list. If [describe] is
169 /// passed, it will be called for each dependency and the result will be 175 /// passed, it will be called for each dependency and the result will be
170 /// written next to the dependency. 176 /// written next to the dependency.
171 void writeDependencies(StringBuffer buffer, 177 void writeDependencies(StringBuffer buffer,
172 [String describe(PackageDep dep)]) { 178 [String describe(PackageDep dep)]) {
173 var map = {}; 179 var map = {};
174 for (var dep in dependencies) { 180 for (var dep in dependencies) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 String get _message => "Incompatible version constraints on '$package'"; 274 String get _message => "Incompatible version constraints on '$package'";
269 } 275 }
270 276
271 /// Exception thrown when two packages with the same name but different sources 277 /// Exception thrown when two packages with the same name but different sources
272 /// are depended upon. 278 /// are depended upon.
273 class SourceMismatchException extends SolveFailure { 279 class SourceMismatchException extends SolveFailure {
274 280
275 SourceMismatchException(String package, Iterable<Dependency> dependencies) 281 SourceMismatchException(String package, Iterable<Dependency> dependencies)
276 : super(package, dependencies); 282 : super(package, dependencies);
277 283
284 bool get mayHaveTransitiveCause => false;
285
278 String get _message => "Incompatible dependencies on '$package'"; 286 String get _message => "Incompatible dependencies on '$package'";
279 287
280 String _describeDependency(PackageDep dep) => 288 String _describeDependency(PackageDep dep) =>
281 "depends on it from source ${dep.source}"; 289 "depends on it from source ${dep.source}";
282 } 290 }
283 291
284 /// Exception thrown when two packages with the same name and source but 292 /// Exception thrown when two packages with the same name and source but
285 /// different descriptions are depended upon. 293 /// different descriptions are depended upon.
286 class DescriptionMismatchException extends SolveFailure { 294 class DescriptionMismatchException extends SolveFailure {
287 DescriptionMismatchException(String package, 295 DescriptionMismatchException(String package,
288 Iterable<Dependency> dependencies) 296 Iterable<Dependency> dependencies)
289 : super(package, dependencies); 297 : super(package, dependencies);
290 298
299 bool get mayHaveTransitiveCause => false;
300
291 String get _message => "Incompatible dependencies on '$package'"; 301 String get _message => "Incompatible dependencies on '$package'";
292 302
293 String _describeDependency(PackageDep dep) { 303 String _describeDependency(PackageDep dep) {
294 // TODO(nweiz): Dump descriptions to YAML when that's supported. 304 // TODO(nweiz): Dump descriptions to YAML when that's supported.
295 return "depends on it with description ${json.stringify(dep.description)}"; 305 return "depends on it with description ${json.stringify(dep.description)}";
296 } 306 }
297 } 307 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698