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

Side by Side Diff: pkg/analyzer/lib/src/summary/package_bundle_reader.dart

Issue 1974323003: Add '--dart-sdk-summary' option to analyzer-cli and use SummaryBasedDartSdk. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 import 'dart:io' as io; 1 import 'dart:io' as io;
2 2
3 import 'package:analyzer/dart/element/element.dart'; 3 import 'package:analyzer/dart/element/element.dart';
4 import 'package:analyzer/src/context/cache.dart'; 4 import 'package:analyzer/src/context/cache.dart';
5 import 'package:analyzer/src/context/context.dart'; 5 import 'package:analyzer/src/context/context.dart';
6 import 'package:analyzer/src/dart/element/element.dart'; 6 import 'package:analyzer/src/dart/element/element.dart';
7 import 'package:analyzer/src/generated/engine.dart'; 7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/java_io.dart'; 8 import 'package:analyzer/src/generated/java_io.dart';
9 import 'package:analyzer/src/generated/resolver.dart'; 9 import 'package:analyzer/src/generated/resolver.dart';
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return true; 127 return true;
128 } 128 }
129 } 129 }
130 return false; 130 return false;
131 } 131 }
132 } 132 }
133 133
134 /** 134 /**
135 * The [UriResolver] that knows about sources that are served from their 135 * The [UriResolver] that knows about sources that are served from their
136 * summaries. 136 * summaries.
137 *
138 * TODO(scheglov) rename to `InSummaryUriResolver` - it's not `package:` specifi c.
137 */ 139 */
138 class InSummaryPackageUriResolver extends UriResolver { 140 class InSummaryPackageUriResolver extends UriResolver {
139 final SummaryDataStore _dataStore; 141 final SummaryDataStore _dataStore;
140 142
141 InSummaryPackageUriResolver(this._dataStore); 143 InSummaryPackageUriResolver(this._dataStore);
142 144
143 @override 145 @override
144 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 146 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
145 actualUri ??= uri; 147 actualUri ??= uri;
146 String uriString = uri.toString(); 148 String uriString = uri.toString();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 @override 181 @override
180 String get encoding => uri.toString(); 182 String get encoding => uri.toString();
181 183
182 @override 184 @override
183 String get fullName => encoding; 185 String get fullName => encoding;
184 186
185 @override 187 @override
186 int get hashCode => uri.hashCode; 188 int get hashCode => uri.hashCode;
187 189
188 @override 190 @override
189 bool get isInSystemLibrary => false; 191 bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME;
190 192
191 @override 193 @override
192 int get modificationStamp => 0; 194 int get modificationStamp => 0;
193 195
194 @override 196 @override
195 String get shortName => pathos.basename(fullName); 197 String get shortName => pathos.basename(fullName);
196 198
197 @override 199 @override
198 UriKind get uriKind => UriKind.PACKAGE_URI; 200 UriKind get uriKind => UriKind.PACKAGE_URI;
199 201
200 @override 202 @override
201 bool operator ==(Object object) => 203 bool operator ==(Object object) =>
202 object is InSummarySource && object.uri == uri; 204 object is InSummarySource && object.uri == uri;
203 205
204 @override 206 @override
205 bool exists() => true; 207 bool exists() => true;
206 208
207 @override 209 @override
208 String toString() => uri.toString(); 210 String toString() => uri.toString();
209 } 211 }
210 212
211 /** 213 /**
212 * A [SummaryDataStore] is a container for the data extracted from a set of 214 * A [SummaryDataStore] is a container for the data extracted from a set of
213 * summary package bundles. It contains maps which can be used to find linked 215 * summary package bundles. It contains maps which can be used to find linked
214 * and unlinked summaries by URI. 216 * and unlinked summaries by URI.
215 */ 217 */
216 class SummaryDataStore { 218 class SummaryDataStore {
217 /** 219 /**
220 * List of all [PackageBundle]s.
221 */
222 final List<PackageBundle> bundles = <PackageBundle>[];
223
224 /**
218 * Map from the URI of a compilation unit to the unlinked summary of that 225 * Map from the URI of a compilation unit to the unlinked summary of that
219 * compilation unit. 226 * compilation unit.
220 */ 227 */
221 final Map<String, UnlinkedUnit> unlinkedMap = <String, UnlinkedUnit>{}; 228 final Map<String, UnlinkedUnit> unlinkedMap = <String, UnlinkedUnit>{};
222 229
223 /** 230 /**
224 * Map from the URI of a library to the linked summary of that library. 231 * Map from the URI of a library to the linked summary of that library.
225 */ 232 */
226 final Map<String, LinkedLibrary> linkedMap = <String, LinkedLibrary>{}; 233 final Map<String, LinkedLibrary> linkedMap = <String, LinkedLibrary>{};
227 234
228 /** 235 /**
229 * Map from the URI of a library to the summary path that contained it. 236 * Map from the URI of a library to the summary path that contained it.
230 */ 237 */
231 final Map<String, String> uriToSummaryPath = <String, String>{}; 238 final Map<String, String> uriToSummaryPath = <String, String>{};
232 239
233 SummaryDataStore(Iterable<String> summaryPaths) { 240 SummaryDataStore(Iterable<String> summaryPaths) {
234 summaryPaths.forEach(_fillMaps); 241 summaryPaths.forEach(_fillMaps);
235 } 242 }
236 243
237 /** 244 /**
238 * Add the given [bundle] loaded from the file with the given [path]. 245 * Add the given [bundle] loaded from the file with the given [path].
239 */ 246 */
240 void addBundle(String path, PackageBundle bundle) { 247 void addBundle(String path, PackageBundle bundle) {
248 bundles.add(bundle);
241 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) { 249 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
242 String uri = bundle.unlinkedUnitUris[i]; 250 String uri = bundle.unlinkedUnitUris[i];
243 uriToSummaryPath[uri] = path; 251 uriToSummaryPath[uri] = path;
244 unlinkedMap[uri] = bundle.unlinkedUnits[i]; 252 unlinkedMap[uri] = bundle.unlinkedUnits[i];
245 } 253 }
246 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) { 254 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) {
247 String uri = bundle.linkedLibraryUris[i]; 255 String uri = bundle.linkedLibraryUris[i];
248 linkedMap[uri] = bundle.linkedLibraries[i]; 256 linkedMap[uri] = bundle.linkedLibraries[i];
249 } 257 }
250 } 258 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 * also provides [summaryPath]. 303 * also provides [summaryPath].
296 */ 304 */
297 class _InSummaryFallbackSource extends FileBasedSource 305 class _InSummaryFallbackSource extends FileBasedSource
298 implements InSummarySource { 306 implements InSummarySource {
299 @override 307 @override
300 final String summaryPath; 308 final String summaryPath;
301 309
302 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath) 310 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath)
303 : super(file, uri); 311 : super(file, uri);
304 } 312 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summary_sdk.dart » ('j') | pkg/analyzer/lib/src/summary/summary_sdk.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698