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 0b93d03743b899c6b99864b1119d9b8443f2ab73..662e350532e63cc365deef3ba738922113b38fff 100644 |
--- a/pkg/analyzer/lib/src/context/cache.dart |
+++ b/pkg/analyzer/lib/src/context/cache.dart |
@@ -412,7 +412,7 @@ class CacheEntry { |
* Set the state of the result represented by the given [descriptor] to the |
* given [state]. |
*/ |
- void setState(ResultDescriptor descriptor, CacheState state) { |
+ void setState(ResultDescriptor descriptor, CacheState state, {Delta delta}) { |
if (state == CacheState.ERROR) { |
throw new ArgumentError('use setErrorState() to set the state to ERROR'); |
} |
@@ -423,7 +423,7 @@ class CacheEntry { |
if (state == CacheState.INVALID) { |
ResultData data = _resultMap[descriptor]; |
if (data != null) { |
- _invalidate(descriptor); |
+ _invalidate(descriptor, delta); |
} |
} else { |
ResultData data = getResultData(descriptor); |
@@ -471,7 +471,7 @@ class CacheEntry { |
void setValueIncremental(ResultDescriptor descriptor, dynamic value) { |
ResultData data = getResultData(descriptor); |
List<TargetedResult> dependedOn = data.dependedOnResults; |
- _invalidate(descriptor); |
+ _invalidate(descriptor, null); |
setValue(descriptor, value, dependedOn); |
} |
@@ -491,7 +491,12 @@ class CacheEntry { |
* Invalidate the result represented by the given [descriptor] and propagate |
* invalidation to other results that depend on it. |
*/ |
- void _invalidate(ResultDescriptor descriptor) { |
+ void _invalidate(ResultDescriptor descriptor, Delta delta) { |
+ if (delta != null && |
+ !delta.affects(_partition.context, target, descriptor)) { |
+// print('not-invalidate $descriptor for $target'); |
+ return; |
+ } |
// print('invalidate $descriptor for $target'); |
ResultData thisData = _resultMap.remove(descriptor); |
if (thisData == null) { |
@@ -511,7 +516,7 @@ class CacheEntry { |
dependentResults.forEach((TargetedResult dependentResult) { |
CacheEntry entry = _partition.get(dependentResult.target); |
if (entry != null) { |
- entry._invalidate(dependentResult.result); |
+ entry._invalidate(dependentResult.result, delta); |
} |
}); |
// If empty, remove the entry altogether. |
@@ -530,7 +535,7 @@ class CacheEntry { |
void _invalidateAll() { |
List<ResultDescriptor> results = _resultMap.keys.toList(); |
for (ResultDescriptor result in results) { |
- _invalidate(result); |
+ _invalidate(result, null); |
} |
} |
@@ -960,6 +965,24 @@ abstract class CachePartition { |
} |
/** |
+ * The description for a change. |
+ */ |
+class Delta { |
+ final Source source; |
+ |
+ Delta(this.source); |
+ |
+ /** |
+ * Check whether this delta affects the result described by the given |
+ * [descriptor] and [target]. |
+ */ |
+ bool affects(InternalAnalysisContext context, AnalysisTarget target, |
+ ResultDescriptor descriptor) { |
+ return true; |
+ } |
+} |
+ |
+/** |
* [InvalidatedResult] describes an invalidated result. |
*/ |
class InvalidatedResult { |