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 afe021626062dab159e58d4ebd91a185f7e631e1..2aca6b1b2fba1ff0aafe380a00fafb855c30eaa7 100644 |
| --- a/pkg/analyzer/lib/src/context/cache.dart |
| +++ b/pkg/analyzer/lib/src/context/cache.dart |
| @@ -7,6 +7,8 @@ library analyzer.src.context.cache; |
| import 'dart:async'; |
| import 'dart:collection'; |
| +import 'package:analyzer/src/dart/element/element.dart' |
| + show ElementImpl, Modifier; |
| import 'package:analyzer/src/generated/engine.dart'; |
| import 'package:analyzer/src/generated/java_engine.dart'; |
| import 'package:analyzer/src/generated/source.dart'; |
| @@ -239,7 +241,14 @@ class AnalysisCache { |
| AnalysisEngine.instance.logger |
| .logInformation('Removed the cache entry for $target.'); |
| } |
| - return partition.remove(target); |
| + var entry = partition.remove(target); |
|
Brian Wilkerson
2016/02/16 15:10:48
Missing type
skybrian
2016/02/17 01:23:41
Done.
|
| + if (entry != null) { |
| + entry.dispose(); |
| + if (target is ElementImpl) { |
| + target.setModifier(Modifier.CACHE_KEY, false); |
|
Brian Wilkerson
2016/02/16 15:10:48
Won't `dispose` have already cleared the flag?
skybrian
2016/02/17 01:23:41
Fixed. (Yes, this was left over from debugging.)
|
| + } |
| + } |
| + return entry; |
| } |
| } |
| return null; |
| @@ -307,7 +316,11 @@ class CacheEntry { |
| Map<ResultDescriptor, ResultData> _resultMap = |
| new HashMap<ResultDescriptor, ResultData>(); |
| - CacheEntry(this.target); |
| + CacheEntry(this.target) { |
| + if (target is ElementImpl) { |
| + (target as ElementImpl).setModifier(Modifier.CACHE_KEY, true); |
|
skybrian
2016/02/16 07:11:06
Since target is a field, the extra cast is necessa
|
| + } |
| + } |
| /** |
| * The exception that caused one or more values to have a state of |
| @@ -350,6 +363,9 @@ class CacheEntry { |
| } |
| }); |
| _resultMap.clear(); |
| + if (target is ElementImpl) { |
| + (target as ElementImpl).setModifier(Modifier.CACHE_KEY, false); |
| + } |
| } |
| /** |
| @@ -384,7 +400,7 @@ class CacheEntry { |
| * Return the value of the result represented by the given [descriptor], or |
| * the default value for the result if this entry does not have a valid value. |
| */ |
| - dynamic /*=V*/ getValue /*<V>*/ (ResultDescriptor /*<V>*/ descriptor) { |
| + dynamic/*=V*/ getValue/*<V>*/(ResultDescriptor/*<V>*/ descriptor) { |
| ResultData data = _resultMap[descriptor]; |
| if (data == null) { |
| return descriptor.defaultValue; |
| @@ -482,8 +498,8 @@ class CacheEntry { |
| * Set the value of the result represented by the given [descriptor] to the |
| * given [value]. |
| */ |
| - void setValue /*<V>*/ (ResultDescriptor /*<V>*/ descriptor, |
| - dynamic /*=V*/ value, List<TargetedResult> dependedOn) { |
| + void setValue/*<V>*/(ResultDescriptor/*<V>*/ descriptor, dynamic/*=V*/ value, |
| + List<TargetedResult> dependedOn) { |
| // { |
| // String valueStr = '$value'; |
| // if (valueStr.length > 20) { |
| @@ -581,7 +597,13 @@ class CacheEntry { |
| _invalidateDependentResults(id, thisData, delta, level + 1); |
| // If empty and not explicitly added, remove the entry altogether. |
| if (_resultMap.isEmpty && !explicitlyAdded) { |
| - _partition.entryMap.remove(target); |
| + var entry = _partition.entryMap.remove(target); |
|
Brian Wilkerson
2016/02/16 15:10:48
Missing type
skybrian
2016/02/17 01:23:41
Done.
|
| + if (entry != null) { |
| + entry.dispose(); |
| + if (target is ElementImpl) { |
| + (target as ElementImpl).setModifier(Modifier.CACHE_KEY, false); |
| + } |
| + } |
| _partition._removeIfSource(target); |
| } |
| // Notify controller. |