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

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

Issue 1405643002: Issue 24566. Main AnalysisContext.getLibrariesContaining() should work also for SDK sources. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 | « no previous file | pkg/analyzer/test/src/context/context_test.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) 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 } 187 }
188 return errors; 188 return errors;
189 } 189 }
190 190
191 /** 191 /**
192 * Returns libraries containing the given [part]. 192 * Returns libraries containing the given [part].
193 * Maybe empty, but not null. 193 * Maybe empty, but not null.
194 */ 194 */
195 List<Source> getLibrariesContainingPart(Source part) { 195 List<Source> getLibrariesContainingPart(Source part) {
196 if (part.isInSystemLibrary) {
197 DartWorkManager sdkDartWorkManager = _getSdkDartWorkManager();
198 if (sdkDartWorkManager != this) {
199 return sdkDartWorkManager.getLibrariesContainingPart(part);
200 }
201 }
196 List<Source> libraries = partLibrariesMap[part]; 202 List<Source> libraries = partLibrariesMap[part];
197 return libraries != null ? libraries : Source.EMPTY_LIST; 203 return libraries != null ? libraries : Source.EMPTY_LIST;
198 } 204 }
199 205
200 @override 206 @override
201 TargetedResult getNextResult() { 207 TargetedResult getNextResult() {
202 // Try to find a priority result to compute. 208 // Try to find a priority result to compute.
203 while (priorityResultQueue.isNotEmpty) { 209 while (priorityResultQueue.isNotEmpty) {
204 TargetedResult result = priorityResultQueue.first; 210 TargetedResult result = priorityResultQueue.first;
205 if (!_needsComputing(result.target, result.result)) { 211 if (!_needsComputing(result.target, result.result)) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 void onSourceFactoryChanged() { 266 void onSourceFactoryChanged() {
261 _invalidateAllLocalResolutionInformation(true); 267 _invalidateAllLocalResolutionInformation(true);
262 } 268 }
263 269
264 @override 270 @override
265 void resultsComputed( 271 void resultsComputed(
266 AnalysisTarget target, Map<ResultDescriptor, dynamic> outputs) { 272 AnalysisTarget target, Map<ResultDescriptor, dynamic> outputs) {
267 bool isDartSource = _isDartSource(target); 273 bool isDartSource = _isDartSource(target);
268 // Route SDK outputs to the SDK WorkManager. 274 // Route SDK outputs to the SDK WorkManager.
269 if (isDartSource && target.source.isInSystemLibrary) { 275 if (isDartSource && target.source.isInSystemLibrary) {
270 SourceFactory sourceFactory = context.sourceFactory; 276 DartWorkManager sdkWorkManager = _getSdkDartWorkManager();
271 InternalAnalysisContext sdkContext = sourceFactory.dartSdk.context; 277 if (sdkWorkManager != this) {
272 if (sdkContext != context) { 278 sdkWorkManager.resultsComputed(target, outputs);
273 for (WorkManager sdkWorkManager in sdkContext.workManagers) { 279 return;
274 if (sdkWorkManager is DartWorkManager) {
275 sdkWorkManager.resultsComputed(target, outputs);
276 return;
277 }
278 }
279 } 280 }
280 } 281 }
281 // Organize sources. 282 // Organize sources.
282 bool isDartLibrarySource = false; 283 bool isDartLibrarySource = false;
283 if (isDartSource) { 284 if (isDartSource) {
284 Source source = target; 285 Source source = target;
285 SourceKind kind = outputs[SOURCE_KIND]; 286 SourceKind kind = outputs[SOURCE_KIND];
286 if (kind != null) { 287 if (kind != null) {
287 unknownSourceQueue.remove(source); 288 unknownSourceQueue.remove(source);
288 if (kind == SourceKind.LIBRARY) { 289 if (kind == SourceKind.LIBRARY) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 context.getNotice(source).setErrors(info.errors, info.lineInfo); 346 context.getNotice(source).setErrors(info.errors, info.lineInfo);
346 } 347 }
347 } 348 }
348 } 349 }
349 350
350 void unitIncrementallyResolved(Source librarySource, Source unitSource) { 351 void unitIncrementallyResolved(Source librarySource, Source unitSource) {
351 librarySourceQueue.add(librarySource); 352 librarySourceQueue.add(librarySource);
352 } 353 }
353 354
354 /** 355 /**
356 * Return the SDK [DartWorkManager] or this one.
357 */
358 DartWorkManager _getSdkDartWorkManager() {
359 SourceFactory sourceFactory = context.sourceFactory;
360 InternalAnalysisContext sdkContext = sourceFactory.dartSdk.context;
361 if (sdkContext != context) {
362 for (WorkManager workManager in sdkContext.workManagers) {
363 if (workManager is DartWorkManager) {
364 return workManager;
365 }
366 }
367 }
368 return this;
369 }
370
371 /**
355 * Invalidate all of the resolution results computed by this context. The flag 372 * Invalidate all of the resolution results computed by this context. The flag
356 * [invalidateUris] should be `true` if the cached results of converting URIs 373 * [invalidateUris] should be `true` if the cached results of converting URIs
357 * to source files should also be invalidated. 374 * to source files should also be invalidated.
358 */ 375 */
359 void _invalidateAllLocalResolutionInformation(bool invalidateUris) { 376 void _invalidateAllLocalResolutionInformation(bool invalidateUris) {
360 CachePartition partition = privateAnalysisCachePartition; 377 CachePartition partition = privateAnalysisCachePartition;
361 // Prepare targets and values to invalidate. 378 // Prepare targets and values to invalidate.
362 List<Source> dartSources = <Source>[]; 379 List<Source> dartSources = <Source>[];
363 List<LibrarySpecificUnit> unitTargets = <LibrarySpecificUnit>[]; 380 List<LibrarySpecificUnit> unitTargets = <LibrarySpecificUnit>[];
364 MapIterator<AnalysisTarget, CacheEntry> iterator = partition.iterator(); 381 MapIterator<AnalysisTarget, CacheEntry> iterator = partition.iterator();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 466 }
450 } 467 }
451 468
452 bool _shouldErrorsBeComputed(Source source) => 469 bool _shouldErrorsBeComputed(Source source) =>
453 context.shouldErrorsBeAnalyzed(source, null); 470 context.shouldErrorsBeAnalyzed(source, null);
454 471
455 static bool _isDartSource(AnalysisTarget target) { 472 static bool _isDartSource(AnalysisTarget target) {
456 return target is Source && AnalysisEngine.isDartFileName(target.fullName); 473 return target is Source && AnalysisEngine.isDartFileName(target.fullName);
457 } 474 }
458 } 475 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698