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

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

Issue 2681573002: Rename _FileBasedSummaryResynthesizer to StoreBasedSummaryResynthesizer. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/file_system/file_system.dart'; 4 import 'package:analyzer/file_system/file_system.dart';
5 import 'package:analyzer/src/context/cache.dart'; 5 import 'package:analyzer/src/context/cache.dart';
6 import 'package:analyzer/src/context/context.dart'; 6 import 'package:analyzer/src/context/context.dart';
7 import 'package:analyzer/src/dart/element/element.dart'; 7 import 'package:analyzer/src/dart/element/element.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; 9 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 } 113 }
114 114
115 /** 115 /**
116 * The [ResultProvider] that provides results using summary resynthesizer. 116 * The [ResultProvider] that provides results using summary resynthesizer.
117 */ 117 */
118 abstract class ResynthesizerResultProvider extends ResultProvider { 118 abstract class ResynthesizerResultProvider extends ResultProvider {
119 final InternalAnalysisContext context; 119 final InternalAnalysisContext context;
120 final SummaryDataStore _dataStore; 120 final SummaryDataStore _dataStore;
121 121
122 _FileBasedSummaryResynthesizer _resynthesizer; 122 StoreBasedSummaryResynthesizer _resynthesizer;
123 123
124 ResynthesizerResultProvider(this.context, this._dataStore); 124 ResynthesizerResultProvider(this.context, this._dataStore);
125 125
126 SummaryResynthesizer get resynthesizer => _resynthesizer; 126 SummaryResynthesizer get resynthesizer => _resynthesizer;
127 127
128 /** 128 /**
129 * Add a new [bundle] to the resynthesizer. 129 * Add a new [bundle] to the resynthesizer.
130 */ 130 */
131 void addBundle(String path, PackageBundle bundle) { 131 void addBundle(String path, PackageBundle bundle) {
132 _dataStore.addBundle(path, bundle); 132 _dataStore.addBundle(path, bundle);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Unknown target. 259 // Unknown target.
260 return false; 260 return false;
261 } 261 }
262 262
263 /** 263 /**
264 * Create the [resynthesizer] instance. 264 * Create the [resynthesizer] instance.
265 * 265 *
266 * Subclasses must call this method in their constructors. 266 * Subclasses must call this method in their constructors.
267 */ 267 */
268 void createResynthesizer() { 268 void createResynthesizer() {
269 _resynthesizer = new _FileBasedSummaryResynthesizer(context, 269 _resynthesizer = new StoreBasedSummaryResynthesizer(context,
270 context.sourceFactory, context.analysisOptions.strongMode, _dataStore); 270 context.sourceFactory, context.analysisOptions.strongMode, _dataStore);
271 } 271 }
272 272
273 /** 273 /**
274 * Return `true` if this result provider can provide a result for the 274 * Return `true` if this result provider can provide a result for the
275 * given [source]. The provider must ensure that [addBundle] is invoked for 275 * given [source]. The provider must ensure that [addBundle] is invoked for
276 * every bundle that would be required to provide results for the [source]. 276 * every bundle that would be required to provide results for the [source].
277 */ 277 */
278 bool hasResultsForSource(Source source); 278 bool hasResultsForSource(Source source);
279 } 279 }
280 280
281 /** 281 /**
282 * A concrete resynthesizer that serves summaries from [SummaryDataStore].
283 */
284 class StoreBasedSummaryResynthesizer extends SummaryResynthesizer {
285 final SummaryDataStore _dataStore;
286
287 StoreBasedSummaryResynthesizer(AnalysisContext context,
288 SourceFactory sourceFactory, bool strongMode, this._dataStore)
289 : super(context, sourceFactory, strongMode);
290
291 @override
292 LinkedLibrary getLinkedSummary(String uri) {
293 return _dataStore.linkedMap[uri];
294 }
295
296 @override
297 UnlinkedUnit getUnlinkedSummary(String uri) {
298 return _dataStore.unlinkedMap[uri];
299 }
300
301 @override
302 bool hasLibrarySummary(String uri) {
303 LinkedLibrary linkedLibrary = _dataStore.linkedMap[uri];
304 return linkedLibrary != null;
305 }
306 }
307
308 /**
282 * A [SummaryDataStore] is a container for the data extracted from a set of 309 * A [SummaryDataStore] is a container for the data extracted from a set of
283 * summary package bundles. It contains maps which can be used to find linked 310 * summary package bundles. It contains maps which can be used to find linked
284 * and unlinked summaries by URI. 311 * and unlinked summaries by URI.
285 */ 312 */
286 class SummaryDataStore { 313 class SummaryDataStore {
287 /** 314 /**
288 * List of all [PackageBundle]s. 315 * List of all [PackageBundle]s.
289 */ 316 */
290 final List<PackageBundle> bundles = <PackageBundle>[]; 317 final List<PackageBundle> bundles = <PackageBundle>[];
291 318
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 return libraryUriStrings.isNotEmpty ? libraryUriStrings : null; 432 return libraryUriStrings.isNotEmpty ? libraryUriStrings : null;
406 } 433 }
407 434
408 void _fillMaps(String path) { 435 void _fillMaps(String path) {
409 io.File file = new io.File(path); 436 io.File file = new io.File(path);
410 List<int> buffer = file.readAsBytesSync(); 437 List<int> buffer = file.readAsBytesSync();
411 PackageBundle bundle = new PackageBundle.fromBuffer(buffer); 438 PackageBundle bundle = new PackageBundle.fromBuffer(buffer);
412 addBundle(path, bundle); 439 addBundle(path, bundle);
413 } 440 }
414 } 441 }
415
416 /**
417 * A concrete resynthesizer that serves summaries from given file paths.
418 */
419 class _FileBasedSummaryResynthesizer extends SummaryResynthesizer {
420 final SummaryDataStore _dataStore;
421
422 _FileBasedSummaryResynthesizer(AnalysisContext context,
423 SourceFactory sourceFactory, bool strongMode, this._dataStore)
424 : super(context, sourceFactory, strongMode);
425
426 @override
427 LinkedLibrary getLinkedSummary(String uri) {
428 return _dataStore.linkedMap[uri];
429 }
430
431 @override
432 UnlinkedUnit getUnlinkedSummary(String uri) {
433 return _dataStore.unlinkedMap[uri];
434 }
435
436 @override
437 bool hasLibrarySummary(String uri) {
438 LinkedLibrary linkedLibrary = _dataStore.linkedMap[uri];
439 return linkedLibrary != null;
440 }
441 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698