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

Unified Diff: lib/src/lock_file.dart

Issue 1528523003: Clean up the semantics of package descriptions. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 5 years 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
« no previous file with comments | « lib/src/global_packages.dart ('k') | lib/src/package.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/lock_file.dart
diff --git a/lib/src/lock_file.dart b/lib/src/lock_file.dart
index 85316c2a7eec53cbb79b9b7c753fb43b9dcaac79..94c574b2ae1de6bbc2e663d6a702e165b93a3c87 100644
--- a/lib/src/lock_file.dart
+++ b/lib/src/lock_file.dart
@@ -26,21 +26,10 @@ class LockFile {
final Map<String, PackageId> packages;
/// Creates a new lockfile containing [ids].
- ///
- /// Throws an [ArgumentError] if any package has an unresolved ID according to
- /// [Source.isResolved].
factory LockFile(Iterable<PackageId> ids, SourceRegistry sources) {
- var packages = {};
- for (var id in ids) {
- if (id.isRoot) continue;
-
- if (!sources[id.source].isResolved(id)) {
- throw new ArgumentError('ID "$id" is not resolved.');
- }
-
- packages[id.name] = id;
- }
-
+ var packages = new Map.fromIterable(
+ ids.where((id) => !id.isRoot),
+ key: (id) => id.name);
return new LockFile._(packages, sources);
}
@@ -98,16 +87,14 @@ class LockFile {
// Let the source parse the description.
var source = sources[sourceName];
+ var id;
try {
- description = source.parseDescription(filePath, description,
- fromLockFile: true);
+ id = source.parseId(name, version, description);
} on FormatException catch (ex) {
throw new SourceSpanFormatException(ex.message,
- spec.nodes['source'].span);
+ spec.nodes['description'].span);
}
- var id = new PackageId(name, sourceName, version, description);
-
// Validate the name.
_validate(name == id.name,
"Package name $name doesn't match ${id.name}.", spec);
@@ -127,16 +114,11 @@ class LockFile {
/// Returns a copy of this LockFile with [id] added.
///
- /// Throws an [ArgumentError] if [id] isn't resolved according to
- /// [Source.isResolved]. If there's already an ID with the same name as [id]
- /// in the LockFile, it's overwritten.
+ /// If there's already an ID with the same name as [id] in the LockFile, it's
+ /// overwritten.
LockFile setPackage(PackageId id) {
if (id.isRoot) return this;
- if (!_sources[id.source].isResolved(id)) {
- throw new ArgumentError('ID "$id" is not resolved.');
- }
-
var packages = new Map.from(this.packages);
packages[id.name] = id;
return new LockFile._(packages, _sources);
« no previous file with comments | « lib/src/global_packages.dart ('k') | lib/src/package.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698