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

Side by Side Diff: lib/src/package_graph.dart

Issue 2044253003: Refactor Source and SourceRegistry. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Rename LiveSource to BoundSource. Created 4 years, 6 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
« no previous file with comments | « lib/src/lock_file.dart ('k') | lib/src/solver/backtracking_solver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'barback/transformer_cache.dart'; 5 import 'barback/transformer_cache.dart';
6 import 'entrypoint.dart'; 6 import 'entrypoint.dart';
7 import 'lock_file.dart'; 7 import 'lock_file.dart';
8 import 'package.dart'; 8 import 'package.dart';
9 import 'solver/version_solver.dart'; 9 import 'solver/version_solver.dart';
10 import 'source/cached.dart'; 10 import 'source/cached.dart';
(...skipping 30 matching lines...) Expand all
41 /// This is generally faster than loading a package graph from scratch, since 41 /// This is generally faster than loading a package graph from scratch, since
42 /// the packages' pubspecs are already fully-parsed. 42 /// the packages' pubspecs are already fully-parsed.
43 factory PackageGraph.fromSolveResult(Entrypoint entrypoint, 43 factory PackageGraph.fromSolveResult(Entrypoint entrypoint,
44 SolveResult result) { 44 SolveResult result) {
45 var packages = new Map.fromIterable(result.packages, 45 var packages = new Map.fromIterable(result.packages,
46 key: (id) => id.name, 46 key: (id) => id.name,
47 value: (id) { 47 value: (id) {
48 if (id.name == entrypoint.root.name) return entrypoint.root; 48 if (id.name == entrypoint.root.name) return entrypoint.root;
49 49
50 return new Package(result.pubspecs[id.name], 50 return new Package(result.pubspecs[id.name],
51 entrypoint.cache.sources[id.source].getDirectory(id)); 51 entrypoint.cache.source(id.source).getDirectory(id));
52 }); 52 });
53 53
54 return new PackageGraph(entrypoint, result.lockFile, packages); 54 return new PackageGraph(entrypoint, result.lockFile, packages);
55 } 55 }
56 56
57 /// Loads the transformer cache for this graph. 57 /// Loads the transformer cache for this graph.
58 /// 58 ///
59 /// This may only be called if [entrypoint] represents a physical package. 59 /// This may only be called if [entrypoint] represents a physical package.
60 /// This may modify the cache. 60 /// This may modify the cache.
61 TransformerCache loadTransformerCache() { 61 TransformerCache loadTransformerCache() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 /// Returns whether [package] is mutable. 118 /// Returns whether [package] is mutable.
119 /// 119 ///
120 /// A package is considered to be mutable if it or any of its dependencies 120 /// A package is considered to be mutable if it or any of its dependencies
121 /// don't come from a cached source, since the user can change its contents 121 /// don't come from a cached source, since the user can change its contents
122 /// without modifying the pub cache. Information generated from mutable 122 /// without modifying the pub cache. Information generated from mutable
123 /// packages is generally not safe to cache, since it may change frequently. 123 /// packages is generally not safe to cache, since it may change frequently.
124 bool isPackageMutable(String package) { 124 bool isPackageMutable(String package) {
125 var id = lockFile.packages[package]; 125 var id = lockFile.packages[package];
126 if (id == null) return true; 126 if (id == null) return true;
127 127
128 var source = entrypoint.cache.sources[id.source]; 128 if (entrypoint.cache.source(id.source) is! CachedSource) return true;
129 if (source is! CachedSource) return true;
130 129
131 return transitiveDependencies(package).any((dep) { 130 return transitiveDependencies(package).any((dep) {
132 var depId = lockFile.packages[dep.name]; 131 var depId = lockFile.packages[dep.name];
133 132
134 // The entrypoint package doesn't have a lockfile entry. It's always 133 // The entrypoint package doesn't have a lockfile entry. It's always
135 // mutable. 134 // mutable.
136 if (depId == null) return true; 135 if (depId == null) return true;
137 136
138 return entrypoint.cache.sources[depId.source] is! CachedSource; 137 return entrypoint.cache.source(depId.source) is! CachedSource;
139 }); 138 });
140 } 139 }
141 140
142 /// Returns whether [package] is static. 141 /// Returns whether [package] is static.
143 /// 142 ///
144 /// A package is considered to be static if it's not transformed and it came 143 /// A package is considered to be static if it's not transformed and it came
145 /// from a cached source. Static packages don't need to be fully processed by 144 /// from a cached source. Static packages don't need to be fully processed by
146 /// barback. 145 /// barback.
147 /// 146 ///
148 /// Note that a static package isn't the same as an immutable package (see 147 /// Note that a static package isn't the same as an immutable package (see
149 /// [isPackageMutable]). 148 /// [isPackageMutable]).
150 bool isPackageStatic(String package) { 149 bool isPackageStatic(String package) {
151 var id = lockFile.packages[package]; 150 var id = lockFile.packages[package];
152 if (id == null) return false; 151 if (id == null) return false;
153 152 if (entrypoint.cache.source(id.source) is! CachedSource) return false;
154 var source = entrypoint.cache.sources[id.source];
155 if (source is! CachedSource) return false;
156
157 return packages[package].pubspec.transformers.isEmpty; 153 return packages[package].pubspec.transformers.isEmpty;
158 } 154 }
159 } 155 }
OLDNEW
« no previous file with comments | « lib/src/lock_file.dart ('k') | lib/src/solver/backtracking_solver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698