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

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

Issue 1126793004: When invalidate because of the ERROR state, propagate its exception. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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/test/src/context/cache_test.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 5ae41bd5b0ff5448bd6db22ec162dd336af56ee7..db5140363cea944bf0e1491ba26cda1c40019d03 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -413,9 +413,7 @@ class CacheEntry {
}
this._exception = exception;
for (ResultDescriptor descriptor in descriptors) {
- ResultData data = _getResultData(descriptor);
- TargetedResult thisResult = new TargetedResult(_target, descriptor);
- data.invalidate(_cache, thisResult, CacheState.ERROR);
+ _invalidate(descriptor, exception);
}
}
@@ -432,11 +430,7 @@ class CacheEntry {
}
_validateStateChange(descriptor, state);
if (state == CacheState.INVALID) {
- ResultData data = _resultMap[descriptor];
- if (data != null) {
- TargetedResult thisResult = new TargetedResult(_target, descriptor);
- data.invalidate(_cache, thisResult, CacheState.INVALID);
- }
+ _invalidate(descriptor, null);
} else {
ResultData data = _getResultData(descriptor);
data.state = state;
@@ -458,10 +452,10 @@ class CacheEntry {
/*<V>*/ void setValue(ResultDescriptor /*<V>*/ descriptor, dynamic /*V*/
value, List<TargetedResult> dependedOn, Object memento) {
_validateStateChange(descriptor, CacheState.VALID);
+ _invalidate(descriptor, null);
ResultData data = _getResultData(descriptor);
{
TargetedResult thisResult = new TargetedResult(_target, descriptor);
- data.invalidate(_cache, thisResult, CacheState.INVALID);
data.setDependedOnResults(_cache, thisResult, dependedOn);
}
data.state = CacheState.VALID;
@@ -490,6 +484,37 @@ class CacheEntry {
}
/**
+ * Invalidate the result represented by the given [descriptor].
+ * Propagate invalidation to other results that depend on it.
+ */
+ void _invalidate(ResultDescriptor descriptor, CaughtException exception) {
+ ResultData data = _getResultData(descriptor);
+ // Invalidate this result.
+ if (exception == null) {
+ data.state = CacheState.INVALID;
+ } else {
+ data.state = CacheState.ERROR;
+ _exception = exception;
+ }
+ data.value = descriptor.defaultValue;
+ // Stop depending on other results.
+ TargetedResult thisResult = new TargetedResult(_target, descriptor);
+ List<TargetedResult> dependedOnResults = data.dependedOnResults;
+ data.dependedOnResults = <TargetedResult>[];
+ dependedOnResults.forEach((TargetedResult dependedOnResult) {
+ ResultData data = _cache._getDataFor(dependedOnResult);
+ data.removeDependentResult(thisResult);
+ });
+ // Invalidate results that depend on this result.
+ List<TargetedResult> dependentResults = data.dependentResults;
+ data.dependentResults = <TargetedResult>[];
+ dependentResults.forEach((TargetedResult dependentResult) {
+ CacheEntry entry = _cache.get(dependentResult.target);
+ entry._invalidate(dependentResult.result, exception);
+ });
+ }
+
+ /**
* Set the value of the flag with the given [index] to the given [value].
*/
void _setFlag(int index, bool value) {
@@ -866,31 +891,6 @@ class ResultData {
}
/**
- * Invalidate this [ResultData] that corresponds to [thisResult] and
- * propagate invalidation to the results that depend on this one.
- */
- void invalidate(
- AnalysisCache cache, TargetedResult thisResult, CacheState newState) {
- // Invalidate this result.
- state = newState;
- value = descriptor.defaultValue;
- // Stop depending on other results.
- List<TargetedResult> dependedOnResults = this.dependedOnResults;
- this.dependedOnResults = <TargetedResult>[];
- dependedOnResults.forEach((TargetedResult dependedOnResult) {
- ResultData data = cache._getDataFor(dependedOnResult);
- data.removeDependentResult(thisResult);
- });
- // Invalidate results that depend on this result.
- List<TargetedResult> dependentResults = this.dependentResults;
- this.dependentResults = <TargetedResult>[];
- dependentResults.forEach((TargetedResult dependentResult) {
- ResultData data = cache._getDataFor(dependentResult);
- data.invalidate(cache, dependentResult, newState);
- });
- }
-
- /**
* Remove the given [result] from the list of dependent results.
*/
void removeDependentResult(TargetedResult result) {
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/cache_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698