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

Unified Diff: pkg/analyzer/lib/src/task/driver.dart

Issue 1179753002: Add AnalysisDriver.onResultComputed(). (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 | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/test/src/task/driver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/driver.dart
diff --git a/pkg/analyzer/lib/src/task/driver.dart b/pkg/analyzer/lib/src/task/driver.dart
index 36781f58b7e3639b38f3aab71ae7f8cb3db96ea5..35c474b29c95d1dccb10511203a158256d16d774 100644
--- a/pkg/analyzer/lib/src/task/driver.dart
+++ b/pkg/analyzer/lib/src/task/driver.dart
@@ -8,6 +8,7 @@ import 'dart:async';
import 'dart:collection';
import 'package:analyzer/src/context/cache.dart';
+import 'package:analyzer/src/context/context.dart' show ResultComputedEvent;
import 'package:analyzer/src/generated/engine.dart'
hide AnalysisTask, AnalysisContextImpl;
import 'package:analyzer/src/generated/java_engine.dart';
@@ -42,6 +43,12 @@ class AnalysisDriver {
final InternalAnalysisContext context;
/**
+ * The map of [ResultComputedEvent] controllers.
+ */
+ final Map<ResultDescriptor, StreamController<ResultComputedEvent>> resultComputedControllers =
+ <ResultDescriptor, StreamController<ResultComputedEvent>>{};
+
+ /**
* The work order that was previously computed but that has not yet been
* completed.
*/
@@ -187,6 +194,15 @@ class AnalysisDriver {
}
/**
+ * Return the stream that is notified when a new value for the given
+ * [descriptor] is computed.
+ */
+ Stream<ResultComputedEvent> onResultComputed(ResultDescriptor descriptor) {
+ return resultComputedControllers.putIfAbsent(descriptor, () =>
+ new StreamController<ResultComputedEvent>.broadcast(sync: true)).stream;
+ }
+
+ /**
* Perform the next analysis task, and return `true` if there is more work to
* be done in order to compute all of the required analysis information.
*/
@@ -243,7 +259,8 @@ class AnalysisDriver {
AnalysisTask task = item.buildTask();
_onTaskStartedController.add(task);
task.perform();
- CacheEntry entry = context.getCacheEntry(task.target);
+ AnalysisTarget target = task.target;
+ CacheEntry entry = context.getCacheEntry(target);
if (task.caughtException == null) {
List<TargetedResult> dependedOn = item.inputTargetedResults.toList();
Map<ResultDescriptor, dynamic> outputs = task.outputs;
@@ -252,8 +269,17 @@ class AnalysisDriver {
// and throw an exception if not (unless we want to allow null values).
entry.setValue(result, outputs[result], dependedOn);
}
+ outputs.forEach((ResultDescriptor descriptor, value) {
+ StreamController<ResultComputedEvent> controller =
+ resultComputedControllers[descriptor];
+ if (controller != null) {
+ ResultComputedEvent event =
+ new ResultComputedEvent(context, descriptor, target, value);
+ controller.add(event);
+ }
+ });
for (WorkManager manager in workManagers) {
- manager.resultsComputed(task.target, outputs);
+ manager.resultsComputed(target, outputs);
}
} else {
entry.setErrorState(task.caughtException, item.descriptor.results);
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/test/src/task/driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698