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

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

Issue 1113363004: Cache pubspecs when HostedSource.getVersions is called. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source/hosted.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/validator/dependency.dart
diff --git a/sdk/lib/_internal/pub/lib/src/validator/dependency.dart b/sdk/lib/_internal/pub/lib/src/validator/dependency.dart
index fe30ac5948aeb2b2606853ab83fc0788fc1888b4..2721d32aaa8e8fc0161290f3b488d88ff5d757a4 100644
--- a/sdk/lib/_internal/pub/lib/src/validator/dependency.dart
+++ b/sdk/lib/_internal/pub/lib/src/validator/dependency.dart
@@ -64,37 +64,41 @@ class DependencyValidator extends Validator {
}
/// 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) {
- var constraint;
- var primary = Version.primary(versions);
- if (primary != null) {
- constraint = _constraintForVersion(primary);
- } else {
- constraint = dep.constraint.toString();
- if (!dep.constraint.isAny && dep.constraint is! Version) {
- constraint = '"$constraint"';
- }
- }
+ Future _warnAboutSource(PackageDep dep) async {
+ var versions;
+ try {
+ var pubspecs = await entrypoint.cache.sources['hosted']
+ .getVersions(dep.name, dep.name);
+ versions = pubspecs.map((pubspec) => pubspec.version);
+ } catch (error) {
+ versions = [];
+ }
- // Path sources are errors. Other sources are just warnings.
- var messages = warnings;
- if (dep.source == "path") {
- messages = errors;
+ var constraint;
+ var primary = Version.primary(versions);
+ if (primary != null) {
+ constraint = _constraintForVersion(primary);
+ } else {
+ constraint = dep.constraint.toString();
+ if (!dep.constraint.isAny && dep.constraint is! Version) {
+ constraint = '"$constraint"';
}
+ }
- 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.');
- });
+ // 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 '
+ 'package\'s dependencies along with your package.');
}
/// Warn that dependencies should have version constraints.
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source/hosted.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698