Index: pkg/analyzer/lib/src/context/cache.dart |
diff --git a/pkg/analyzer/lib/src/context/cache.dart b/pkg/analyzer/lib/src/context/cache.dart |
index 532764f3b662736857a6520f0a40792278c15a66..74bd8aa1973837aba504e8be5fe1c003bf2600f5 100644 |
--- a/pkg/analyzer/lib/src/context/cache.dart |
+++ b/pkg/analyzer/lib/src/context/cache.dart |
@@ -940,7 +940,7 @@ class CacheFlushManager<T> { |
: policy = policy, |
maxActiveSize = policy.maxActiveSize, |
maxIdleSize = policy.maxIdleSize, |
- maxSize = policy.maxIdleSize; |
+ maxSize = policy.maxActiveSize; |
/** |
* If [currentSize] is already less than [maxSize], returns an empty list. |
@@ -1081,6 +1081,20 @@ abstract class CachePartition { |
CachePartition(this.context); |
/** |
+ * Specify whether a context that uses this partition is being analyzed. |
+ */ |
+ set isActive(bool active) { |
+ for (CacheFlushManager manager in _flushManagerMap.values) { |
+ if (active) { |
+ manager.madeActive(); |
+ } else { |
+ List<TargetedResult> resultsToFlush = manager.madeIdle(); |
+ _flushResults(resultsToFlush); |
+ } |
+ } |
+ } |
+ |
+ /** |
* Notifies the partition that the client is going to stop using it. |
*/ |
void dispose() { |
@@ -1176,15 +1190,7 @@ abstract class CachePartition { |
CacheFlushManager flushManager = _getFlushManager(result.result); |
List<TargetedResult> resultsToFlush = |
flushManager.resultStored(result, value); |
- for (TargetedResult result in resultsToFlush) { |
- CacheEntry entry = get(result.target); |
- if (entry != null) { |
- ResultData data = entry._resultMap[result.result]; |
- if (data != null) { |
- data.flush(); |
- } |
- } |
- } |
+ _flushResults(resultsToFlush); |
} |
/** |
@@ -1204,6 +1210,21 @@ abstract class CachePartition { |
} |
/** |
+ * Flush the given [resultsToFlush]. |
+ */ |
+ void _flushResults(List<TargetedResult> resultsToFlush) { |
+ for (TargetedResult result in resultsToFlush) { |
+ CacheEntry entry = get(result.target); |
+ if (entry != null) { |
+ ResultData data = entry._resultMap[result.result]; |
+ if (data != null) { |
+ data.flush(); |
+ } |
+ } |
+ } |
+ } |
+ |
+ /** |
* Return the [CacheFlushManager] for the given [descriptor], not `null`. |
*/ |
CacheFlushManager _getFlushManager(ResultDescriptor descriptor) { |