| 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 source; | 5 library source; | 
| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 162   /// | 162   /// | 
| 163   /// This doesn't need to be implemented if [shouldCache] is false. | 163   /// This doesn't need to be implemented if [shouldCache] is false. | 
| 164   Future<String> systemCacheDirectory(PackageId id) { | 164   Future<String> systemCacheDirectory(PackageId id) { | 
| 165     return new Future.immediateError( | 165     return new Future.immediateError( | 
| 166         "systemCacheDirectory() must be implemented if shouldCache is true."); | 166         "systemCacheDirectory() must be implemented if shouldCache is true."); | 
| 167   } | 167   } | 
| 168 | 168 | 
| 169   /// When a [Pubspec] or [LockFile] is parsed, it reads in the description for | 169   /// When a [Pubspec] or [LockFile] is parsed, it reads in the description for | 
| 170   /// each dependency. It is up to the dependency's [Source] to determine how | 170   /// each dependency. It is up to the dependency's [Source] to determine how | 
| 171   /// that should be interpreted. This will be called during parsing to validate | 171   /// that should be interpreted. This will be called during parsing to validate | 
| 172   /// that the given [description] is well-formed according to this source. It | 172   /// that the given [description] is well-formed according to this source, and | 
| 173   /// should return if the description is valid, or throw a [FormatException] if | 173   /// to give the source a chance to canonicalize the description. | 
| 174   /// not. | 174   /// | 
|  | 175   /// [containingPath] is the path to the local file (pubspec or lockfile) | 
|  | 176   /// where this description appears. It may be `null` if the description is | 
|  | 177   /// coming from some in-memory source (such as pulling down a pubspec from | 
|  | 178   /// pub.dartlang.org). | 
|  | 179   /// | 
|  | 180   /// It should return if a (possibly modified) valid description, or throw a | 
|  | 181   /// [FormatException] if not valid. | 
| 175   /// | 182   /// | 
| 176   /// [fromLockFile] is true when the description comes from a [LockFile], to | 183   /// [fromLockFile] is true when the description comes from a [LockFile], to | 
| 177   /// allow the source to use lockfile-specific descriptions via [resolveId]. | 184   /// allow the source to use lockfile-specific descriptions via [resolveId]. | 
| 178   void validateDescription(description, {bool fromLockFile: false}) {} | 185   dynamic parseDescription(String containingPath, description, | 
|  | 186                            {bool fromLockFile: false}) { | 
|  | 187     return description; | 
|  | 188   } | 
| 179 | 189 | 
| 180   /// Returns whether or not [description1] describes the same package as | 190   /// Returns whether or not [description1] describes the same package as | 
| 181   /// [description2] for this source. This method should be light-weight. It | 191   /// [description2] for this source. This method should be light-weight. It | 
| 182   /// doesn't need to validate that either package exists. | 192   /// doesn't need to validate that either package exists. | 
| 183   /// | 193   /// | 
| 184   /// By default, just uses regular equality. | 194   /// By default, just uses regular equality. | 
| 185   bool descriptionsEqual(description1, description2) => | 195   bool descriptionsEqual(description1, description2) => | 
| 186     description1 == description2; | 196     description1 == description2; | 
| 187 | 197 | 
| 188   /// For some sources, [PackageId]s can point to different chunks of code at | 198   /// For some sources, [PackageId]s can point to different chunks of code at | 
| 189   /// different times. This takes such an [id] and returns a future that | 199   /// different times. This takes such an [id] and returns a future that | 
| 190   /// completes to a [PackageId] that will uniquely specify a single chunk of | 200   /// completes to a [PackageId] that will uniquely specify a single chunk of | 
| 191   /// code forever. | 201   /// code forever. | 
| 192   /// | 202   /// | 
| 193   /// For example, [GitSource] might take an [id] with description | 203   /// For example, [GitSource] might take an [id] with description | 
| 194   /// `http://github.com/dart-lang/some-lib.git` and return an id with a | 204   /// `http://github.com/dart-lang/some-lib.git` and return an id with a | 
| 195   /// description that includes the current commit of the Git repository. | 205   /// description that includes the current commit of the Git repository. | 
| 196   /// | 206   /// | 
| 197   /// This will be called after the package identified by [id] is installed, so | 207   /// This will be called after the package identified by [id] is installed, so | 
| 198   /// the source can use the installed package to determine information about | 208   /// the source can use the installed package to determine information about | 
| 199   /// the resolved id. | 209   /// the resolved id. | 
| 200   /// | 210   /// | 
| 201   /// The returned [PackageId] may have a description field that's invalid | 211   /// The returned [PackageId] may have a description field that's invalid | 
| 202   /// according to [validateDescription], although it must still be serializable | 212   /// according to [parseDescription], although it must still be serializable | 
| 203   /// to JSON and YAML. It must also be equal to [id] according to | 213   /// to JSON and YAML. It must also be equal to [id] according to | 
| 204   /// [descriptionsEqual]. | 214   /// [descriptionsEqual]. | 
| 205   /// | 215   /// | 
| 206   /// By default, this just returns [id]. | 216   /// By default, this just returns [id]. | 
| 207   Future<PackageId> resolveId(PackageId id) => new Future.immediate(id); | 217   Future<PackageId> resolveId(PackageId id) => new Future.immediate(id); | 
| 208 | 218 | 
| 209   /// Returns the source's name. | 219   /// Returns the source's name. | 
| 210   String toString() => name; | 220   String toString() => name; | 
| 211 } | 221 } | 
| OLD | NEW | 
|---|