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

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

Issue 1776023002: Add AnalysisContext.onResultInvalidated(descriptor). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
Index: pkg/analyzer/lib/src/context/context.dart
diff --git a/pkg/analyzer/lib/src/context/context.dart b/pkg/analyzer/lib/src/context/context.dart
index def719f33a6b86f433cc2600274ea11f8b930b00..e34d1aa863c16e3ecb567d5e0bbb0cd00179e44a 100644
--- a/pkg/analyzer/lib/src/context/context.dart
+++ b/pkg/analyzer/lib/src/context/context.dart
@@ -194,6 +194,13 @@ class AnalysisContextImpl implements InternalAnalysisContext {
ResultProvider resultProvider;
/**
+ * The map of [InvalidatedResult] controllers.
+ */
+ final Map<ResultDescriptor, StreamController<InvalidatedResult>>
+ _resultInvalidatedControllers =
+ <ResultDescriptor, StreamController<InvalidatedResult>>{};
+
+ /**
* The most recently incrementally resolved source, or `null` when it was
* already validated, or the most recent change was not incrementally resolved.
*/
@@ -682,10 +689,14 @@ class AnalysisContextImpl implements InternalAnalysisContext {
if (sdk == null) {
return new AnalysisCache(<CachePartition>[_privatePartition]);
}
- return new AnalysisCache(<CachePartition>[
+ AnalysisCache cache = new AnalysisCache(<CachePartition>[
AnalysisEngine.instance.partitionManager.forSdk(sdk),
_privatePartition
]);
+ cache.onResultInvalidated.listen((InvalidatedResult event) {
+ _resultInvalidatedControllers[event.descriptor]?.add(event);
+ });
+ return cache;
}
/**
@@ -1104,6 +1115,13 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
@override
+ Stream<InvalidatedResult> onResultInvalidated(ResultDescriptor descriptor) {
+ return _resultInvalidatedControllers.putIfAbsent(descriptor, () {
+ return new StreamController<InvalidatedResult>.broadcast(sync: true);
+ }).stream;
+ }
+
+ @override
CompilationUnit parseCompilationUnit(Source source) {
if (!AnalysisEngine.isDartFileName(source.shortName)) {
return null;

Powered by Google App Engine
This is Rietveld 408576698