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 pub.package; | 5 library pub.package; |
6 | 6 |
7 import 'package:path/path.dart' as path; | 7 import 'package:path/path.dart' as path; |
8 | 8 |
9 import 'io.dart'; | 9 import 'io.dart'; |
10 import 'pubspec.dart'; | 10 import 'pubspec.dart'; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 return "$name from $source"; | 104 return "$name from $source"; |
105 } | 105 } |
106 | 106 |
107 /// Returns a [PackageRef] with this one's [name], [source], and | 107 /// Returns a [PackageRef] with this one's [name], [source], and |
108 /// [description]. | 108 /// [description]. |
109 PackageRef toRef() => new PackageRef(name, source, description); | 109 PackageRef toRef() => new PackageRef(name, source, description); |
110 | 110 |
111 /// Returns a [PackageId] for this package with the given concrete version. | 111 /// Returns a [PackageId] for this package with the given concrete version. |
112 PackageId atVersion(Version version) => | 112 PackageId atVersion(Version version) => |
113 new PackageId(name, source, version, description); | 113 new PackageId(name, source, version, description); |
| 114 |
| 115 /// Returns a [PackageDep] for this package with the given version constraint. |
| 116 PackageDep withConstraint(VersionConstraint constraint) => |
| 117 new PackageDep(name, source, constraint, description); |
114 } | 118 } |
115 | 119 |
116 /// A reference to a [Package], but not any particular version(s) of it. | 120 /// A reference to a [Package], but not any particular version(s) of it. |
117 class PackageRef extends _PackageName { | 121 class PackageRef extends _PackageName { |
118 PackageRef(String name, String source, description) | 122 PackageRef(String name, String source, description) |
119 : super(name, source, description); | 123 : super(name, source, description); |
120 | 124 |
121 int get hashCode => name.hashCode ^ source.hashCode; | 125 int get hashCode => name.hashCode ^ source.hashCode; |
122 | 126 |
123 bool operator ==(other) { | 127 bool operator ==(other) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 186 |
183 bool operator ==(other) { | 187 bool operator ==(other) { |
184 // TODO(rnystrom): We're assuming here that we don't need to delve into the | 188 // TODO(rnystrom): We're assuming here that we don't need to delve into the |
185 // description. | 189 // description. |
186 return other is PackageDep && | 190 return other is PackageDep && |
187 other.name == name && | 191 other.name == name && |
188 other.source == source && | 192 other.source == source && |
189 other.constraint == constraint; | 193 other.constraint == constraint; |
190 } | 194 } |
191 } | 195 } |
OLD | NEW |