Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: pkg/analyzer/lib/src/context/cache.dart

Issue 1211993004: Dispose private cache partition on AnalysisContext.dispose(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b2110673f7f33a1e545291ac664549ae7953ee96..0d67817f80ab56763b9737666b361f1640b8b793 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -319,6 +319,22 @@ class CacheEntry {
List<ResultDescriptor> get nonInvalidResults => _resultMap.keys.toList();
/**
+ * Notifies the entry that the client is going to stop using it.
+ */
+ void dispose() {
+ _resultMap.forEach((descriptor, data) {
+ TargetedResult result = new TargetedResult(target, descriptor);
+ for (TargetedResult dependedOnResult in data.dependedOnResults) {
+ ResultData dependedOnData = _partition._getDataFor(dependedOnResult);
+ if (dependedOnData != null) {
+ dependedOnData.dependentResults.remove(result);
+ }
+ }
+ });
+ _resultMap.clear();
+ }
+
+ /**
* Fix the state of the [exception] to match the current state of the entry.
*/
void fixExceptionState() {
@@ -520,7 +536,7 @@ class CacheEntry {
// Stop depending on other results.
TargetedResult thisResult = new TargetedResult(target, descriptor);
for (TargetedResult dependedOnResult in thisData.dependedOnResults) {
- ResultData data = _partition._getDataFor(dependedOnResult, orNull: true);
+ ResultData data = _partition._getDataFor(dependedOnResult);
if (data != null) {
data.dependentResults.remove(thisResult);
}
@@ -559,14 +575,14 @@ class CacheEntry {
void _setDependedOnResults(ResultData thisData, TargetedResult thisResult,
List<TargetedResult> dependedOn) {
thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) {
- ResultData data = _partition._getDataFor(dependedOnResult, orNull: true);
+ ResultData data = _partition._getDataFor(dependedOnResult);
if (data != null) {
data.dependentResults.remove(thisResult);
}
});
thisData.dependedOnResults = dependedOn;
thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) {
- ResultData data = _partition._getDataFor(dependedOnResult, orNull: true);
+ ResultData data = _partition._getDataFor(dependedOnResult);
if (data != null) {
data.dependentResults.add(thisResult);
}
@@ -829,6 +845,16 @@ abstract class CachePartition {
_onResultInvalidated.stream;
/**
+ * Notifies the partition that the client is going to stop using it.
+ */
+ void dispose() {
+ for (CacheEntry entry in _targetMap.values) {
+ entry.dispose();
+ }
+ _targetMap.clear();
+ }
+
+ /**
* Return the entry associated with the given [target].
*/
CacheEntry get(AnalysisTarget target) => _targetMap[target];
@@ -929,13 +955,9 @@ abstract class CachePartition {
}
}
- ResultData _getDataFor(TargetedResult result, {bool orNull: false}) {
+ ResultData _getDataFor(TargetedResult result) {
CacheEntry entry = context.analysisCache.get(result.target);
- if (orNull) {
- return entry != null ? entry._resultMap[result.result] : null;
- } else {
- return entry.getResultData(result.result);
- }
+ return entry != null ? entry._resultMap[result.result] : null;
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698