| OLD | NEW |
| 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.context.cache; | 5 library analyzer.src.context.cache; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/engine.dart' | 9 import 'package:analyzer/src/generated/engine.dart' |
| 10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority; | 10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority; |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 CacheEntry entry = _partition.get(dependentResult.target); | 427 CacheEntry entry = _partition.get(dependentResult.target); |
| 428 entry._invalidate(dependentResult.result, true); | 428 entry._invalidate(dependentResult.result, true); |
| 429 }); | 429 }); |
| 430 // If empty, remove the entry altogether. | 430 // If empty, remove the entry altogether. |
| 431 if (_resultMap.isEmpty) { | 431 if (_resultMap.isEmpty) { |
| 432 _partition._targetMap.remove(target); | 432 _partition._targetMap.remove(target); |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 | 435 |
| 436 /** | 436 /** |
| 437 * Invalidates all the results of this entry, with propagation. |
| 438 */ |
| 439 void _invalidateAll() { |
| 440 List<ResultDescriptor> results = _resultMap.keys.toList(); |
| 441 for (ResultDescriptor result in results) { |
| 442 _invalidate(result, true); |
| 443 } |
| 444 } |
| 445 |
| 446 /** |
| 437 * Set the [dependedOn] on which this result depends. | 447 * Set the [dependedOn] on which this result depends. |
| 438 */ | 448 */ |
| 439 void _setDependedOnResults(ResultData thisData, TargetedResult thisResult, | 449 void _setDependedOnResults(ResultData thisData, TargetedResult thisResult, |
| 440 List<TargetedResult> dependedOn) { | 450 List<TargetedResult> dependedOn) { |
| 441 thisData.dependedOnResults = dependedOn; | 451 thisData.dependedOnResults = dependedOn; |
| 442 thisData.dependedOnResults.forEach((TargetedResult dependentResult) { | 452 thisData.dependedOnResults.forEach((TargetedResult dependentResult) { |
| 443 ResultData data = _partition._getDataFor(dependentResult); | 453 ResultData data = _partition._getDataFor(dependentResult); |
| 444 data.dependentResults.add(thisResult); | 454 data.dependentResults.add(thisResult); |
| 445 }); | 455 }); |
| 446 } | 456 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 _targetMap[target] = entry; | 719 _targetMap[target] = entry; |
| 710 } | 720 } |
| 711 | 721 |
| 712 /** | 722 /** |
| 713 * Remove all information related to the given [target] from this cache. | 723 * Remove all information related to the given [target] from this cache. |
| 714 */ | 724 */ |
| 715 void remove(AnalysisTarget target) { | 725 void remove(AnalysisTarget target) { |
| 716 for (CacheFlushManager flushManager in _flushManagerMap.values) { | 726 for (CacheFlushManager flushManager in _flushManagerMap.values) { |
| 717 flushManager.targetRemoved(target); | 727 flushManager.targetRemoved(target); |
| 718 } | 728 } |
| 719 _targetMap.remove(target); | 729 CacheEntry entry = _targetMap.remove(target); |
| 730 if (entry != null) { |
| 731 entry._invalidateAll(); |
| 732 } |
| 720 } | 733 } |
| 721 | 734 |
| 722 /** | 735 /** |
| 723 * Records that a value of the result described by the given [descriptor] | 736 * Records that a value of the result described by the given [descriptor] |
| 724 * for the given [target] was just read from the cache. | 737 * for the given [target] was just read from the cache. |
| 725 */ | 738 */ |
| 726 void resultAccessed(AnalysisTarget target, ResultDescriptor descriptor) { | 739 void resultAccessed(AnalysisTarget target, ResultDescriptor descriptor) { |
| 727 CacheFlushManager flushManager = _getFlushManager(descriptor); | 740 CacheFlushManager flushManager = _getFlushManager(descriptor); |
| 728 TargetedResult result = new TargetedResult(target, descriptor); | 741 TargetedResult result = new TargetedResult(target, descriptor); |
| 729 flushManager.resultAccessed(result); | 742 flushManager.resultAccessed(result); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 class UniversalCachePartition extends CachePartition { | 904 class UniversalCachePartition extends CachePartition { |
| 892 /** | 905 /** |
| 893 * Initialize a newly created cache partition, belonging to the given | 906 * Initialize a newly created cache partition, belonging to the given |
| 894 * [context]. | 907 * [context]. |
| 895 */ | 908 */ |
| 896 UniversalCachePartition(InternalAnalysisContext context) : super(context); | 909 UniversalCachePartition(InternalAnalysisContext context) : super(context); |
| 897 | 910 |
| 898 @override | 911 @override |
| 899 bool isResponsibleFor(AnalysisTarget target) => true; | 912 bool isResponsibleFor(AnalysisTarget target) => true; |
| 900 } | 913 } |
| OLD | NEW |