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

Unified Diff: sdk/lib/_internal/pub_generated/lib/src/validator/dependency.dart

Issue 557563002: Store the async-await compiled pub code directly in the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub_generated/lib/src/validator/dependency.dart
diff --git a/sdk/lib/_internal/pub/lib/src/validator/dependency.dart b/sdk/lib/_internal/pub_generated/lib/src/validator/dependency.dart
similarity index 55%
copy from sdk/lib/_internal/pub/lib/src/validator/dependency.dart
copy to sdk/lib/_internal/pub_generated/lib/src/validator/dependency.dart
index ac66d324fb82643321c3e602fde49dfcde04aaf3..ddafcbe9a58b9193a4fcd7623353db6978b489c6 100644
--- a/sdk/lib/_internal/pub/lib/src/validator/dependency.dart
+++ b/sdk/lib/_internal/pub_generated/lib/src/validator/dependency.dart
@@ -1,28 +1,17 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
library pub.validator.dependency;
-
import 'dart:async';
-
import '../entrypoint.dart';
import '../log.dart' as log;
import '../package.dart';
import '../validator.dart';
import '../version.dart';
-
-/// A validator that validates a package's dependencies.
class DependencyValidator extends Validator {
- DependencyValidator(Entrypoint entrypoint)
- : super(entrypoint);
-
+ DependencyValidator(Entrypoint entrypoint) : super(entrypoint);
Future validate() {
return Future.forEach(entrypoint.root.pubspec.dependencies, (dependency) {
if (dependency.source != "hosted") {
return _warnAboutSource(dependency);
}
-
if (dependency.constraint.isAny) {
_warnAboutNoConstraint(dependency);
} else if (dependency.constraint is Version) {
@@ -34,17 +23,13 @@ class DependencyValidator extends Validator {
_warnAboutNoConstraintUpperBound(dependency);
}
}
-
return new Future.value();
});
}
-
- /// Warn that dependencies should use the hosted source.
Future _warnAboutSource(PackageDep dep) {
- return entrypoint.cache.sources['hosted']
- .getVersions(dep.name, dep.name)
- .catchError((e) => <Version>[])
- .then((versions) {
+ return entrypoint.cache.sources['hosted'].getVersions(
+ dep.name,
+ dep.name).catchError((e) => <Version>[]).then((versions) {
var constraint;
var primary = Version.primary(versions);
if (primary != null) {
@@ -55,55 +40,41 @@ class DependencyValidator extends Validator {
constraint = '"$constraint"';
}
}
-
- // Path sources are errors. Other sources are just warnings.
var messages = warnings;
if (dep.source == "path") {
messages = errors;
}
-
- messages.add('Don\'t depend on "${dep.name}" from the ${dep.source} '
- 'source. Use the hosted source instead. For example:\n'
- '\n'
- 'dependencies:\n'
- ' ${dep.name}: $constraint\n'
- '\n'
- 'Using the hosted source ensures that everyone can download your '
+ messages.add(
+ 'Don\'t depend on "${dep.name}" from the ${dep.source} '
+ 'source. Use the hosted source instead. For example:\n' '\n' 'dependencies:\n'
+ ' ${dep.name}: $constraint\n' '\n'
+ 'Using the hosted source ensures that everyone can download your '
'package\'s dependencies along with your package.');
});
}
-
- /// Warn that dependencies should have version constraints.
void _warnAboutNoConstraint(PackageDep dep) {
- var message = 'Your dependency on "${dep.name}" should have a version '
- 'constraint.';
+ var message =
+ 'Your dependency on "${dep.name}" should have a version ' 'constraint.';
var locked = entrypoint.lockFile.packages[dep.name];
if (locked != null) {
- message = '$message For example:\n'
- '\n'
- 'dependencies:\n'
- ' ${dep.name}: ${_constraintForVersion(locked.version)}\n';
+ message =
+ '$message For example:\n' '\n' 'dependencies:\n'
+ ' ${dep.name}: ${_constraintForVersion(locked.version)}\n';
}
- warnings.add("$message\n"
- 'Without a constraint, you\'re promising to support ${log.bold("all")} '
+ warnings.add(
+ "$message\n"
+ 'Without a constraint, you\'re promising to support ${log.bold("all")} '
'future versions of "${dep.name}".');
}
-
- /// Warn that dependencies should allow more than a single version.
void _warnAboutSingleVersionConstraint(PackageDep dep) {
warnings.add(
'Your dependency on "${dep.name}" should allow more than one version. '
- 'For example:\n'
- '\n'
- 'dependencies:\n'
- ' ${dep.name}: ${_constraintForVersion(dep.constraint)}\n'
- '\n'
- 'Constraints that are too tight will make it difficult for people to '
+ 'For example:\n' '\n' 'dependencies:\n'
+ ' ${dep.name}: ${_constraintForVersion(dep.constraint)}\n' '\n'
+ 'Constraints that are too tight will make it difficult for people to '
'use your package\n'
- 'along with other packages that also depend on "${dep.name}".');
+ 'along with other packages that also depend on "${dep.name}".');
}
-
- /// Warn that dependencies should have lower bounds on their constraints.
void _warnAboutNoConstraintLowerBound(PackageDep dep) {
var message = 'Your dependency on "${dep.name}" should have a lower bound.';
var locked = entrypoint.lockFile.packages[dep.name];
@@ -114,38 +85,24 @@ class DependencyValidator extends Validator {
} else {
constraint = '">=${locked.version} ${dep.constraint}"';
}
-
- message = '$message For example:\n'
- '\n'
- 'dependencies:\n'
- ' ${dep.name}: $constraint\n';
+ message =
+ '$message For example:\n' '\n' 'dependencies:\n' ' ${dep.name}: $constraint\n';
}
- warnings.add("$message\n"
- 'Without a constraint, you\'re promising to support ${log.bold("all")} '
+ warnings.add(
+ "$message\n"
+ 'Without a constraint, you\'re promising to support ${log.bold("all")} '
'previous versions of "${dep.name}".');
}
-
- /// Warn that dependencies should have upper bounds on their constraints.
void _warnAboutNoConstraintUpperBound(PackageDep dep) {
warnings.add(
- 'Your dependency on "${dep.name}" should have an upper bound. For '
- 'example:\n'
- '\n'
- 'dependencies:\n'
- ' ${dep.name}: "${dep.constraint} '
- '${_upperBoundForVersion((dep.constraint as VersionRange).min)}"\n'
- '\n'
- 'Without an upper bound, you\'re promising to support '
+ 'Your dependency on "${dep.name}" should have an upper bound. For ' 'example:\n'
+ '\n' 'dependencies:\n' ' ${dep.name}: "${dep.constraint} '
+ '${_upperBoundForVersion((dep.constraint as VersionRange).min)}"\n' '\n'
+ 'Without an upper bound, you\'re promising to support '
'${log.bold("all")} future versions of ${dep.name}.');
}
-
- /// Returns the suggested version constraint for a dependency that was tested
- /// against [version].
String _constraintForVersion(Version version) =>
'">=$version ${_upperBoundForVersion(version)}"';
-
- /// Returns the suggested upper bound for a dependency that was tested against
- /// [version].
String _upperBoundForVersion(Version version) {
if (version.major != 0) return '<${version.major + 1}.0.0';
return '<${version.major}.${version.minor + 1}.0';

Powered by Google App Engine
This is Rietveld 408576698