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

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

Issue 1441013003: Issue 24812. Fix for detached CompilationUnitElement(s) after package version switch. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/abstract_context.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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 final HashMap<Source, List<Source>> partLibrariesMap = 81 final HashMap<Source, List<Source>> partLibrariesMap =
82 new HashMap<Source, List<Source>>(); 82 new HashMap<Source, List<Source>>();
83 83
84 /** 84 /**
85 * Initialize a newly created manager. 85 * Initialize a newly created manager.
86 */ 86 */
87 DartWorkManager(this.context) { 87 DartWorkManager(this.context) {
88 analysisCache.onResultInvalidated.listen((InvalidatedResult event) { 88 analysisCache.onResultInvalidated.listen((InvalidatedResult event) {
89 if (event.descriptor == LIBRARY_ERRORS_READY) { 89 if (event.descriptor == LIBRARY_ERRORS_READY) {
90 CacheEntry entry = event.entry; 90 CacheEntry entry = event.entry;
91 if (entry.getValue(SOURCE_KIND) == SourceKind.LIBRARY) { 91 if (entry.explicitlyAdded &&
92 entry.getValue(SOURCE_KIND) == SourceKind.LIBRARY) {
92 librarySourceQueue.add(entry.target); 93 librarySourceQueue.add(entry.target);
93 } 94 }
94 } 95 }
95 }); 96 });
96 } 97 }
97 98
98 /** 99 /**
99 * Returns the correctly typed result of `context.analysisCache`. 100 * Returns the correctly typed result of `context.analysisCache`.
100 */ 101 */
101 AnalysisCache get analysisCache => context.analysisCache; 102 AnalysisCache get analysisCache => context.analysisCache;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // Optionally gather Dart sources to invalidate URIs resolution. 386 // Optionally gather Dart sources to invalidate URIs resolution.
386 if (invalidateUris && _isDartSource(target)) { 387 if (invalidateUris && _isDartSource(target)) {
387 dartSources.add(target); 388 dartSources.add(target);
388 } 389 }
389 // LibrarySpecificUnit(s) are roots of Dart resolution. 390 // LibrarySpecificUnit(s) are roots of Dart resolution.
390 // When one is invalidated, invalidation is propagated to all resolution. 391 // When one is invalidated, invalidation is propagated to all resolution.
391 if (target is LibrarySpecificUnit) { 392 if (target is LibrarySpecificUnit) {
392 unitTargets.add(target); 393 unitTargets.add(target);
393 Source library = target.library; 394 Source library = target.library;
394 if (context.exists(library)) { 395 if (context.exists(library)) {
395 librarySourceQueue.add(library); 396 CacheEntry entry = iterator.value;
397 if (entry.explicitlyAdded) {
398 librarySourceQueue.add(library);
399 }
396 } 400 }
397 } 401 }
398 } 402 }
399 // Invalidate targets and values. 403 // Invalidate targets and values.
400 unitTargets.forEach(partition.remove); 404 unitTargets.forEach(partition.remove);
401 for (Source dartSource in dartSources) { 405 for (Source dartSource in dartSources) {
402 CacheEntry entry = partition.get(dartSource); 406 CacheEntry entry = partition.get(dartSource);
403 if (entry != null) { 407 if (entry != null) {
404 // TODO(scheglov) we invalidate too much. 408 // TODO(scheglov) we invalidate too much.
405 // Would be nice to invalidate just URLs resolution. 409 // Would be nice to invalidate just URLs resolution.
406 entry.setState(PARSED_UNIT, CacheState.INVALID); 410 entry.setState(PARSED_UNIT, CacheState.INVALID);
407 entry.setState(IMPORTED_LIBRARIES, CacheState.INVALID); 411 entry.setState(IMPORTED_LIBRARIES, CacheState.INVALID);
408 entry.setState(EXPLICITLY_IMPORTED_LIBRARIES, CacheState.INVALID); 412 entry.setState(EXPLICITLY_IMPORTED_LIBRARIES, CacheState.INVALID);
409 entry.setState(EXPORTED_LIBRARIES, CacheState.INVALID); 413 entry.setState(EXPORTED_LIBRARIES, CacheState.INVALID);
410 entry.setState(INCLUDED_PARTS, CacheState.INVALID); 414 entry.setState(INCLUDED_PARTS, CacheState.INVALID);
415 entry.setState(LIBRARY_SPECIFIC_UNITS, CacheState.INVALID);
416 entry.setState(UNITS, CacheState.INVALID);
411 } 417 }
412 } 418 }
413 } 419 }
414 420
415 /** 421 /**
416 * Invalidate [CONTAINING_LIBRARIES] for the given [source]. 422 * Invalidate [CONTAINING_LIBRARIES] for the given [source].
417 * [CONTAINING_LIBRARIES] does not have dependencies, so we manage it here. 423 * [CONTAINING_LIBRARIES] does not have dependencies, so we manage it here.
418 * The [source] may be a part, or a library whose contents is updated so 424 * The [source] may be a part, or a library whose contents is updated so
419 * will be a part. 425 * will be a part.
420 */ 426 */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 473 }
468 } 474 }
469 475
470 bool _shouldErrorsBeComputed(Source source) => 476 bool _shouldErrorsBeComputed(Source source) =>
471 context.shouldErrorsBeAnalyzed(source, null); 477 context.shouldErrorsBeAnalyzed(source, null);
472 478
473 static bool _isDartSource(AnalysisTarget target) { 479 static bool _isDartSource(AnalysisTarget target) {
474 return target is Source && AnalysisEngine.isDartFileName(target.fullName); 480 return target is Source && AnalysisEngine.isDartFileName(target.fullName);
475 } 481 }
476 } 482 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/abstract_context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698