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

Unified Diff: lib/src/source/unknown.dart

Issue 2044253003: Refactor Source and SourceRegistry. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Rename LiveSource to BoundSource. Created 4 years, 6 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 | « lib/src/source/path.dart ('k') | lib/src/source_registry.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/source/unknown.dart
diff --git a/lib/src/source/unknown.dart b/lib/src/source/unknown.dart
index 7f015af00f8847417150238b48e2b3f7d894bf00..3ed09e0f2aaf13bcccb20890c2c4b2e4d8d69edf 100644
--- a/lib/src/source/unknown.dart
+++ b/lib/src/source/unknown.dart
@@ -9,6 +9,7 @@ import 'package:pub_semver/pub_semver.dart';
import '../package.dart';
import '../pubspec.dart';
import '../source.dart';
+import '../system_cache.dart';
/// A [Null Object] that represents a source not recognized by pub.
///
@@ -21,6 +22,9 @@ class UnknownSource extends Source {
UnknownSource(this.name);
+ BoundSource bind(SystemCache systemCache) =>
+ new _BoundUnknownSource(this, systemCache);
+
/// Two unknown sources are the same if their names are the same.
bool operator==(other) =>
other is UnknownSource &&
@@ -28,26 +32,34 @@ class UnknownSource extends Source {
int get hashCode => name.hashCode;
+ bool descriptionsEqual(description1, description2) =>
+ description1 == description2;
+
+ PackageRef parseRef(String name, description, {String containingPath}) =>
+ new PackageRef(name, this.name, description);
+
+ PackageId parseId(String name, Version version, description) =>
+ new PackageId(name, this.name, version, description);
+}
+
+class _BoundUnknownSource extends BoundSource {
+ final UnknownSource source;
+
+ final SystemCache systemCache;
+
+ _BoundUnknownSource(this.source, this.systemCache);
+
Future<List<PackageId>> doGetVersions(PackageRef ref) =>
throw new UnsupportedError(
- "Cannot get package versions from unknown source '$name'.");
+ "Cannot get package versions from unknown source '${source.name}'.");
Future<Pubspec> doDescribe(PackageId id) => throw new UnsupportedError(
- "Cannot describe a package from unknown source '$name'.");
+ "Cannot describe a package from unknown source '${source.name}'.");
Future get(PackageId id, String symlink) => throw new UnsupportedError(
- "Cannot get an unknown source '$name'.");
+ "Cannot get an unknown source '${source.name}'.");
/// Returns the directory where this package can be found locally.
String getDirectory(PackageId id) => throw new UnsupportedError(
- "Cannot find a package from an unknown source '$name'.");
-
- bool descriptionsEqual(description1, description2) =>
- description1 == description2;
-
- PackageRef parseRef(String name, description, {String containingPath}) =>
- new PackageRef(name, this.name, description);
-
- PackageId parseId(String name, Version version, description) =>
- new PackageId(name, this.name, version, description);
+ "Cannot find a package from an unknown source '${source.name}'.");
}
« no previous file with comments | « lib/src/source/path.dart ('k') | lib/src/source_registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698