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

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

Issue 10874051: Support self-referential package: imports with Pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
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('io.dart'); 7 #import('io.dart');
8 #import('pubspec.dart'); 8 #import('pubspec.dart');
9 #import('source.dart'); 9 #import('source.dart');
10 #import('source_registry.dart'); 10 #import('source_registry.dart');
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 /** 38 /**
39 * The path to the directory containing the package. 39 * The path to the directory containing the package.
40 */ 40 */
41 final String dir; 41 final String dir;
42 42
43 /** 43 /**
44 * The name of the package. 44 * The name of the package.
45 */ 45 */
46 final String name; 46 String get name() {
47 if (pubspec.name != null) return pubspec.name;
48 if (dir != null) return basename(dir);
49 return null;
50 }
47 51
48 /** 52 /**
49 * The package's version. 53 * The package's version.
50 */ 54 */
51 Version get version => pubspec.version; 55 Version get version => pubspec.version;
52 56
53 /** 57 /**
54 * The parsed pubspec associated with this package. 58 * The parsed pubspec associated with this package.
55 */ 59 */
56 final Pubspec pubspec; 60 final Pubspec pubspec;
57 61
58 /** 62 /**
59 * The ids of the packages that this package depends on. This is what is 63 * The ids of the packages that this package depends on. This is what is
60 * specified in the pubspec when this package depends on another. 64 * specified in the pubspec when this package depends on another.
61 */ 65 */
62 Collection<PackageRef> get dependencies => pubspec.dependencies; 66 Collection<PackageRef> get dependencies => pubspec.dependencies;
63 67
64 /** 68 /**
65 * Constructs a package with the given name and pubspec. The package will 69 * Constructs a package with the given pubspec. The package will have no
66 * no directory associated with it. 70 * directory associated with it.
67 */ 71 */
68 Package.inMemory(this.name, this.pubspec) 72 Package.inMemory(this.pubspec)
69 : dir = null; 73 : dir = null;
70 74
71 /** 75 /**
72 * Constructs a package. This should not be called directly. Instead, acquire 76 * Constructs a package. This should not be called directly. Instead, acquire
73 * packages from [load()]. 77 * packages from [load()].
74 */ 78 */
75 Package._(String dir, this.pubspec) 79 Package._(this.dir, this.pubspec);
76 : dir = dir,
77 name = basename(dir);
78 80
79 /** 81 /**
80 * Returns a debug string for the package. 82 * Returns a debug string for the package.
81 */ 83 */
82 String toString() => '$name $version ($dir)'; 84 String toString() => '$name $version ($dir)';
83 } 85 }
84 86
85 /** 87 /**
86 * An unambiguous resolved reference to a package. A package ID contains enough 88 * An unambiguous resolved reference to a package. A package ID contains enough
87 * information to correctly install the package. 89 * information to correctly install the package.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 190
189 String toString() => "$name $constraint from $source ($description)"; 191 String toString() => "$name $constraint from $source ($description)";
190 192
191 /** 193 /**
192 * Returns a [PackageId] generated from this [PackageRef] with the given 194 * Returns a [PackageId] generated from this [PackageRef] with the given
193 * concrete version. 195 * concrete version.
194 */ 196 */
195 PackageId atVersion(Version version) => 197 PackageId atVersion(Version version) =>
196 new PackageId(source, version, description); 198 new PackageId(source, version, description);
197 } 199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698