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

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

Issue 2052553003: Add AnalysisCache.flush() utility method. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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/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 ae7961546a45a8f433ac8b2bf88b5b653f4f30fa..fa7fbadc89f83d4eefe032fbcde45e536ac9a83a 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -17,6 +17,12 @@ import 'package:analyzer/src/task/model.dart';
import 'package:analyzer/task/model.dart';
/**
+ * Return `true` if the [result] of the [target] should be flushed.
+ */
+typedef bool FlushResultFilter<V>(
+ AnalysisTarget target, ResultDescriptor<V> result);
+
+/**
* Return `true` if the given [target] is a priority one.
*/
typedef bool IsPriorityAnalysisTarget(AnalysisTarget target);
@@ -103,6 +109,15 @@ class AnalysisCache {
}
/**
+ * Flush results that satisfy the given [filter].
+ */
+ void flush(FlushResultFilter filter) {
+ for (CachePartition partition in _partitions) {
+ partition.flush(filter);
+ }
+ }
+
+ /**
* Return the entry associated with the given [target].
*/
CacheEntry get(AnalysisTarget target) {
@@ -392,6 +407,17 @@ class CacheEntry {
}
/**
+ * Flush results that satisfy the given [filter].
+ */
+ void flush(FlushResultFilter filter) {
+ _resultMap.forEach((ResultDescriptor result, ResultData data) {
+ if (filter(target, result)) {
+ data.flush();
+ }
+ });
+ }
+
+ /**
* Return the result data associated with the [descriptor], creating one if it
* isn't there.
*/
@@ -998,6 +1024,15 @@ abstract class CachePartition {
}
/**
+ * Flush results that satisfy the given [filter].
+ */
+ void flush(FlushResultFilter filter) {
+ for (CacheEntry entry in entryMap.values) {
+ entry.flush(filter);
+ }
+ }
+
+ /**
* Return the entry associated with the given [target].
*/
CacheEntry get(AnalysisTarget target) => entryMap[target];
« 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