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

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

Issue 1139643004: Add AnalysisCache.getState() and getValue(). (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/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 5a4ef821039309718ec4b25bbf6d8c305dc0c544..4c4c46fdf594dcd1f074f1f0f529d56935ea2a5d 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -102,6 +102,34 @@ class AnalysisCache {
}
/**
+ * Return the state of the given [result] for the given [target].
+ *
+ * It does not update the cache, if the corresponding [CacheEntry] does not
+ * exist, then [CacheState.INVALID] is returned.
+ */
+ CacheState getState(AnalysisTarget target, ResultDescriptor result) {
+ CacheEntry entry = get(target);
+ if (entry == null) {
+ return CacheState.INVALID;
+ }
+ return entry.getState(result);
+ }
+
+ /**
+ * Return the value of the given [result] for the given [target].
+ *
+ * It does not update the cache, if the corresponding [CacheEntry] does not
+ * exist, then the default value is returned.
+ */
+ Object getValue(AnalysisTarget target, ResultDescriptor result) {
+ CacheEntry entry = get(target);
+ if (entry == null) {
+ return result.defaultValue;
+ }
+ return entry.getValue(result);
+ }
+
+ /**
* Return an iterator returning all of the map entries mapping targets to
* cache entries.
*/
« 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