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

Side by Side Diff: pkg/analyzer/lib/src/task/dart_work_manager.dart

Issue 2188523004: DartWorkManager.getLibrariesContainingPart() should ask the ResultProvider for CONTAINING_LIBRARIES. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 // 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 library analyzer.src.task.dart_work_manager; 5 library analyzer.src.task.dart_work_manager;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/context/cache.dart'; 9 import 'package:analyzer/src/context/cache.dart';
10 import 'package:analyzer/src/generated/engine.dart' 10 import 'package:analyzer/src/generated/engine.dart'
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 * Maybe empty, but not null. 195 * Maybe empty, but not null.
196 */ 196 */
197 List<Source> getLibrariesContainingPart(Source part) { 197 List<Source> getLibrariesContainingPart(Source part) {
198 if (part.isInSystemLibrary) { 198 if (part.isInSystemLibrary) {
199 DartWorkManager sdkDartWorkManager = _getSdkDartWorkManager(); 199 DartWorkManager sdkDartWorkManager = _getSdkDartWorkManager();
200 if (sdkDartWorkManager != this) { 200 if (sdkDartWorkManager != this) {
201 return sdkDartWorkManager.getLibrariesContainingPart(part); 201 return sdkDartWorkManager.getLibrariesContainingPart(part);
202 } 202 }
203 } 203 }
204 List<Source> libraries = partLibrariesMap[part]; 204 List<Source> libraries = partLibrariesMap[part];
205 libraries ??= _getLibrariesContainingPartFromResultProvider(part);
205 return libraries?.toList() ?? Source.EMPTY_LIST; 206 return libraries?.toList() ?? Source.EMPTY_LIST;
206 } 207 }
207 208
208 @override 209 @override
209 TargetedResult getNextResult() { 210 TargetedResult getNextResult() {
210 // Try to find a priority result to compute. 211 // Try to find a priority result to compute.
211 while (priorityResultQueue.isNotEmpty) { 212 while (priorityResultQueue.isNotEmpty) {
212 TargetedResult result = priorityResultQueue.first; 213 TargetedResult result = priorityResultQueue.first;
213 if (!_needsComputing(result.target, result.result)) { 214 if (!_needsComputing(result.target, result.result)) {
214 priorityResultQueue.remove(result); 215 priorityResultQueue.remove(result);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 context.getNotice(source).setErrors(info.errors, info.lineInfo); 349 context.getNotice(source).setErrors(info.errors, info.lineInfo);
349 } 350 }
350 } 351 }
351 } 352 }
352 353
353 void unitIncrementallyResolved(Source librarySource, Source unitSource) { 354 void unitIncrementallyResolved(Source librarySource, Source unitSource) {
354 librarySourceQueue.add(librarySource); 355 librarySourceQueue.add(librarySource);
355 } 356 }
356 357
357 /** 358 /**
359 * Ask the [context]'s result provider for [CONTAINING_LIBRARIES].
360 * Return the list of containing libraries, or `null` if unknown.
361 */
362 List<Source> _getLibrariesContainingPartFromResultProvider(Source part) {
363 CacheEntry cacheEntry = context.getCacheEntry(part);
364 bool knows = context.aboutToComputeResult(cacheEntry, CONTAINING_LIBRARIES);
365 if (knows) {
366 return cacheEntry.getValue(CONTAINING_LIBRARIES);
367 }
368 return null;
369 }
370
371 /**
358 * Return the SDK [DartWorkManager] or this one. 372 * Return the SDK [DartWorkManager] or this one.
359 */ 373 */
360 DartWorkManager _getSdkDartWorkManager() { 374 DartWorkManager _getSdkDartWorkManager() {
361 SourceFactory sourceFactory = context.sourceFactory; 375 SourceFactory sourceFactory = context.sourceFactory;
362 InternalAnalysisContext sdkContext = sourceFactory.dartSdk.context; 376 InternalAnalysisContext sdkContext = sourceFactory.dartSdk.context;
363 if (sdkContext != context) { 377 if (sdkContext != context) {
364 for (WorkManager workManager in sdkContext.workManagers) { 378 for (WorkManager workManager in sdkContext.workManagers) {
365 if (workManager is DartWorkManager) { 379 if (workManager is DartWorkManager) {
366 return workManager; 380 return workManager;
367 } 381 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 487 }
474 } 488 }
475 489
476 bool _shouldErrorsBeComputed(Source source) => 490 bool _shouldErrorsBeComputed(Source source) =>
477 context.shouldErrorsBeAnalyzed(source); 491 context.shouldErrorsBeAnalyzed(source);
478 492
479 static bool _isDartSource(AnalysisTarget target) { 493 static bool _isDartSource(AnalysisTarget target) {
480 return target is Source && AnalysisEngine.isDartFileName(target.fullName); 494 return target is Source && AnalysisEngine.isDartFileName(target.fullName);
481 } 495 }
482 } 496 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/package_bundle_reader.dart ('k') | pkg/analyzer/test/src/task/dart_work_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698