Chromium Code Reviews| 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..a99caae368d7ad076ae8f250f67d68ca4c1772d8 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, {Object delta}) { |
|
Brian Wilkerson
2015/06/25 18:04:10
Will this ever *not* be a Delta?
scheglov
2015/06/25 18:11:26
No.
Fixed.
|
| 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, Object delta) { |
|
Brian Wilkerson
2015/06/25 18:04:10
Will this ever *not* be a Delta?
scheglov
2015/06/25 18:11:26
No.
Fixed.
|
| + if (delta is Delta && |
| + !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 { |