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 4ef2814a792dabf89efce162db140f8391556782..5d8354f6b41b58f4dccbc97580e48eeb6003697a 100644 |
| --- a/pkg/analyzer/lib/src/context/cache.dart |
| +++ b/pkg/analyzer/lib/src/context/cache.dart |
| @@ -331,6 +331,17 @@ class CacheEntry { |
| } |
| /** |
| + * Return the memento of the result represented by the given [descriptor]. |
| + */ |
| + dynamic getMemento(ResultDescriptor descriptor) { |
| + ResultData data = _resultMap[descriptor]; |
| + if (data == null) { |
| + return null; |
| + } |
| + return data.memento; |
| + } |
| + |
| + /** |
| * Return the state of the result represented by the given [descriptor]. |
| */ |
| CacheState getState(ResultDescriptor descriptor) { |
| @@ -441,10 +452,11 @@ class CacheEntry { |
| /** |
| * Set the value of the result represented by the given [descriptor] to the |
| - * given [value]. |
| + * given [value]. The optional [memento] may help to recompute [value] more |
| + * efficiently after invalidation. |
| */ |
| /*<V>*/ void setValue(ResultDescriptor /*<V>*/ descriptor, dynamic /*V*/ |
| - value, List<TargetedResult> dependedOn) { |
| + value, List<TargetedResult> dependedOn, [dynamic memento]) { |
| _validateStateChange(descriptor, CacheState.VALID); |
| ResultData data = _getResultData(descriptor); |
| { |
| @@ -454,6 +466,7 @@ class CacheEntry { |
| } |
| data.state = CacheState.VALID; |
| data.value = value == null ? descriptor.defaultValue : value; |
| + data.memento = memento; |
| } |
| @override |
| @@ -821,6 +834,12 @@ class ResultData { |
| Object value; |
| /** |
| + * The optional data that is remembered with [value] and, when [value] is |
| + * invalidated, may help to recompute it more efficiently. |
| + */ |
| + dynamic memento; |
|
Brian Wilkerson
2015/05/04 16:22:09
nit: I generally prefer 'Object' over 'dynamic' as
|
| + |
| + /** |
| * A list of the results on which this result depends. |
| */ |
| List<TargetedResult> dependedOnResults = <TargetedResult>[]; |