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

Side by Side Diff: packages/package_config/lib/discovery_analysis.dart

Issue 3014633002: Roll to pickup pool changes (Closed)
Patch Set: Created 3 years, 2 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 | « packages/package_config/lib/discovery.dart ('k') | packages/package_config/pubspec.yaml » ('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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Analyse a directory structure and find packages resolvers for each 5 /// Analyse a directory structure and find packages resolvers for each
6 /// sub-directory. 6 /// sub-directory.
7 /// 7 ///
8 /// The resolvers are generally the same that would be found by using 8 /// The resolvers are generally the same that would be found by using
9 /// the `discovery.dart` library on each sub-directory in turn, 9 /// the `discovery.dart` library on each sub-directory in turn,
10 /// but more efficiently and with some heuristics for directories that 10 /// but more efficiently and with some heuristics for directories that
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (packages == null || !entry.path.endsWith("/packages")) { 84 if (packages == null || !entry.path.endsWith("/packages")) {
85 findRoots(entry); 85 findRoots(entry);
86 } 86 }
87 } 87 }
88 } 88 }
89 if (packages != null) { 89 if (packages != null) {
90 oldContexts.add(new _PackageContext(directory, packages, contexts)); 90 oldContexts.add(new _PackageContext(directory, packages, contexts));
91 contexts = oldContexts; 91 contexts = oldContexts;
92 } 92 }
93 } 93 }
94
94 findRoots(directory); 95 findRoots(directory);
95 // If the root is not itself context root, add a the wrapper context. 96 // If the root is not itself context root, add a the wrapper context.
96 if (contexts.length == 1 && contexts[0].directory == directory) { 97 if (contexts.length == 1 && contexts[0].directory == directory) {
97 return contexts[0]; 98 return contexts[0];
98 } 99 }
99 return new _PackageContext(directory, root, contexts); 100 return new _PackageContext(directory, root, contexts);
100 } 101 }
101 } 102 }
102 103
103 class _PackageContext implements PackageContext { 104 class _PackageContext implements PackageContext {
104 final Directory directory; 105 final Directory directory;
105 final Packages packages; 106 final Packages packages;
106 final List<PackageContext> children; 107 final List<PackageContext> children;
107 _PackageContext(this.directory, this.packages, List<PackageContext> children) 108 _PackageContext(this.directory, this.packages, List<PackageContext> children)
108 : children = new List<PackageContext>.unmodifiable(children); 109 : children = new List<PackageContext>.unmodifiable(children);
109 110
110 Map<Directory, Packages> asMap() { 111 Map<Directory, Packages> asMap() {
111 var result = new HashMap<Directory, Packages>(); 112 var result = new HashMap<Directory, Packages>();
112 recurse(_PackageContext current) { 113 recurse(_PackageContext current) {
113 result[current.directory] = current.packages; 114 result[current.directory] = current.packages;
114 for (var child in current.children) { 115 for (var child in current.children) {
115 recurse(child); 116 recurse(child);
116 } 117 }
117 } 118 }
119
118 recurse(this); 120 recurse(this);
119 return result; 121 return result;
120 } 122 }
121 123
122 PackageContext operator [](Directory directory) { 124 PackageContext operator [](Directory directory) {
123 String path = directory.path; 125 String path = directory.path;
124 if (!path.startsWith(this.directory.path)) { 126 if (!path.startsWith(this.directory.path)) {
125 throw new ArgumentError("Not inside $path: $directory"); 127 throw new ArgumentError("Not inside $path: $directory");
126 } 128 }
127 _PackageContext current = this; 129 _PackageContext current = this;
(...skipping 28 matching lines...) Expand all
156 return true; 158 return true;
157 } 159 }
158 } 160 }
159 161
160 Packages _loadPackagesFile(File file) { 162 Packages _loadPackagesFile(File file) {
161 var uri = new Uri.file(file.path); 163 var uri = new Uri.file(file.path);
162 var bytes = file.readAsBytesSync(); 164 var bytes = file.readAsBytesSync();
163 var map = pkgfile.parse(bytes, uri); 165 var map = pkgfile.parse(bytes, uri);
164 return new MapPackages(map); 166 return new MapPackages(map);
165 } 167 }
OLDNEW
« no previous file with comments | « packages/package_config/lib/discovery.dart ('k') | packages/package_config/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698