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

Unified Diff: sdk/lib/_internal/pub/lib/src/package.dart

Issue 1140083005: Rewrite pub's version solver. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Nuke implicit deps. 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
Index: sdk/lib/_internal/pub/lib/src/package.dart
diff --git a/sdk/lib/_internal/pub/lib/src/package.dart b/sdk/lib/_internal/pub/lib/src/package.dart
index d59a0945fff1622cb040359f6dd40c7b423f27c1..c5b1a04d397eabbbb3f20a95c9e74849cb9e6a31 100644
--- a/sdk/lib/_internal/pub/lib/src/package.dart
+++ b/sdk/lib/_internal/pub/lib/src/package.dart
@@ -271,7 +271,13 @@ class Package {
/// so that from outside of this library, there is no type relationship between
/// those three types.
class _PackageName {
- _PackageName(this.name, this.source, this.description);
+ _PackageName(this.name, this.source, this.description)
+ : isMagic = false;
+
+ _PackageName.magic(this.name)
+ : source = null,
+ description = null,
+ isMagic = true;
/// The name of the package being identified.
final String name;
@@ -289,17 +295,25 @@ class _PackageName {
/// by the URL "git://github.com/dart/uilib.git".
final description;
+ /// Whether this is a name for a magic package.
+ ///
+ /// Magic packages are unversioned pub constructs that have special semantics.
Bob Nystrom 2015/05/14 18:09:37 Given the name "magic", this really needs a more d
nweiz 2015/05/14 22:08:00 Done.
+ final bool isMagic;
+
/// Whether this package is the root package.
- bool get isRoot => source == null;
+ bool get isRoot => source == null && !isMagic;
String toString() {
if (isRoot) return "$name (root)";
+ if (isMagic) return name;
return "$name from $source";
}
/// Returns a [PackageRef] with this one's [name], [source], and
/// [description].
- PackageRef toRef() => new PackageRef(name, source, description);
+ PackageRef toRef() => isMagic
+ ? new PackageRef.magic(name)
+ : new PackageRef(name, source, description);
/// Returns a [PackageId] for this package with the given concrete version.
PackageId atVersion(Version version) =>
@@ -315,6 +329,10 @@ class PackageRef extends _PackageName {
PackageRef(String name, String source, description)
: super(name, source, description);
+ /// Creates a reference to a magic package (see [isMagic]).
Bob Nystrom 2015/05/14 18:09:38 see [_PackageName.isMagic].
nweiz 2015/05/14 22:08:00 I'm pretty sure linking to superclass methods is v
Bob Nystrom 2015/05/14 22:13:02 Oh, right. Forgot this was a subclass. :)
+ PackageRef.magic(String name)
+ : super.magic(name);
+
int get hashCode => name.hashCode ^ source.hashCode;
bool operator ==(other) {
@@ -341,6 +359,11 @@ class PackageId extends _PackageName {
PackageId(String name, String source, this.version, description)
: super(name, source, description);
+ /// Creates an ID for a magic package (see [isMagic]).
Bob Nystrom 2015/05/14 18:09:38 Ditto.
+ PackageId.magic(String name)
+ : super.magic(name),
+ version = Version.none;
+
/// Creates an ID for the given root package.
PackageId.root(Package package)
: version = package.version,
@@ -359,6 +382,7 @@ class PackageId extends _PackageName {
String toString() {
if (isRoot) return "$name $version (root)";
+ if (isMagic) return name;
return "$name $version from $source";
}
}

Powered by Google App Engine
This is Rietveld 408576698