OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |