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

Side by Side Diff: utils/pub/package.dart

Issue 12255055: Make Comparable generic. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
« no previous file with comments | « utils/css/source.dart ('k') | utils/template/source.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 package; 5 library package;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../../pkg/path/lib/path.dart' as path; 9 import '../../pkg/path/lib/path.dart' as path;
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 String toString() => '$name $version ($dir)'; 78 String toString() => '$name $version ($dir)';
79 } 79 }
80 80
81 /// An unambiguous resolved reference to a package. A package ID contains enough 81 /// An unambiguous resolved reference to a package. A package ID contains enough
82 /// information to correctly install the package. 82 /// information to correctly install the package.
83 /// 83 ///
84 /// Note that it's possible for multiple distinct package IDs to point to 84 /// Note that it's possible for multiple distinct package IDs to point to
85 /// different directories that happen to contain identical packages. For 85 /// different directories that happen to contain identical packages. For
86 /// example, the same package may be available from multiple sources. As far as 86 /// example, the same package may be available from multiple sources. As far as
87 /// Pub is concerned, those packages are different. 87 /// Pub is concerned, those packages are different.
88 class PackageId implements Comparable { 88 class PackageId implements Comparable<PackageId> {
89 /// The name of the package being identified. 89 /// The name of the package being identified.
90 final String name; 90 final String name;
91 91
92 /// The [Source] used to look up this package given its [description]. If 92 /// The [Source] used to look up this package given its [description]. If
93 /// this is a root package ID, this will be `null`. 93 /// this is a root package ID, this will be `null`.
94 final Source source; 94 final Source source;
95 95
96 /// The package's version. 96 /// The package's version.
97 final Version version; 97 final Version version;
98 98
(...skipping 23 matching lines...) Expand all
122 other.source == source && 122 other.source == source &&
123 other.version == version; 123 other.version == version;
124 } 124 }
125 125
126 String toString() { 126 String toString() {
127 if (isRoot) return "$name $version (root)"; 127 if (isRoot) return "$name $version (root)";
128 if (source.isDefault) return "$name $version"; 128 if (source.isDefault) return "$name $version";
129 return "$name $version from $source"; 129 return "$name $version from $source";
130 } 130 }
131 131
132 int compareTo(Comparable other) { 132 int compareTo(PackageId other) {
133 if (other is! PackageId) throw new ArgumentError(other);
134
135 var sourceComp = source.name.compareTo(other.source.name); 133 var sourceComp = source.name.compareTo(other.source.name);
136 if (sourceComp != 0) return sourceComp; 134 if (sourceComp != 0) return sourceComp;
137 135
138 var nameComp = name.compareTo(other.name); 136 var nameComp = name.compareTo(other.name);
139 if (nameComp != 0) return nameComp; 137 if (nameComp != 0) return nameComp;
140 138
141 return version.compareTo(other.version); 139 return version.compareTo(other.version);
142 } 140 }
143 141
144 /// Returns the pubspec for this package. 142 /// Returns the pubspec for this package.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 206
209 class PubspecNameMismatchException implements Exception { 207 class PubspecNameMismatchException implements Exception {
210 final String expectedName; 208 final String expectedName;
211 final String actualName; 209 final String actualName;
212 210
213 PubspecNameMismatchException(this.expectedName, this.actualName); 211 PubspecNameMismatchException(this.expectedName, this.actualName);
214 212
215 String toString() => 'The name you specified for your dependency, ' 213 String toString() => 'The name you specified for your dependency, '
216 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.'; 214 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.';
217 } 215 }
OLDNEW
« no previous file with comments | « utils/css/source.dart ('k') | utils/template/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698