| Index: pkg/analysis_server/lib/src/analysis_server.dart
|
| diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
|
| index 447af90be2a6a997ba97cda0a4f08c478ed822bf..abc47c867543f8772b2c670f4b617dbcd7da2240 100644
|
| --- a/pkg/analysis_server/lib/src/analysis_server.dart
|
| +++ b/pkg/analysis_server/lib/src/analysis_server.dart
|
| @@ -208,9 +208,14 @@ class AnalysisServer {
|
| new HashMap<AnalysisContext, Completer<AnalysisDoneReason>>();
|
|
|
| /**
|
| - * The listeners that are listening for lifecycle events from this server.
|
| + * The controller that is notified when analysis is started.
|
| */
|
| - List<AnalysisServerListener> listeners = <AnalysisServerListener>[];
|
| + StreamController<AnalysisContext> _onAnalysisStartedController;
|
| +
|
| + /**
|
| + * The controller that is notified when analysis is complete.
|
| + */
|
| + StreamController _onAnalysisCompleteController;
|
|
|
| /**
|
| * True if any exceptions thrown by analysis should be propagated up the call
|
| @@ -235,6 +240,8 @@ class AnalysisServer {
|
| contextDirectoryManager =
|
| new ServerContextManager(this, resourceProvider, packageMapProvider);
|
| AnalysisEngine.instance.logger = new AnalysisLogger();
|
| + _onAnalysisStartedController = new StreamController.broadcast();
|
| + _onAnalysisCompleteController = new StreamController.broadcast();
|
| running = true;
|
| Notification notification = new ServerConnectedParams().toNotification();
|
| channel.sendNotification(notification);
|
| @@ -256,7 +263,7 @@ class AnalysisServer {
|
| * Schedules analysis of the given context.
|
| */
|
| void schedulePerformAnalysisOperation(AnalysisContext context) {
|
| - _notifyAnalysisStarted(context);
|
| + _onAnalysisStartedController.add(context);
|
| scheduleOperation(new PerformAnalysisOperation(context, false));
|
| }
|
|
|
| @@ -335,16 +342,18 @@ class AnalysisServer {
|
| }
|
|
|
| /**
|
| - * Add the given [listener] to the list of listeners that are listening for
|
| - * lifecycle events from this server.
|
| + * The stream that is notified when analysis of a context is started.
|
| */
|
| - void addAnalysisServerListener(AnalysisServerListener listener) {
|
| - if (!listeners.contains(listener)) {
|
| - listeners.add(listener);
|
| - }
|
| + Stream<AnalysisContext> get onAnalysisStarted {
|
| + return _onAnalysisStartedController.stream;
|
| }
|
|
|
| /**
|
| + * The stream that is notified when analysis is complete.
|
| + */
|
| + Stream get onAnalysisComplete => _onAnalysisCompleteController.stream;
|
| +
|
| + /**
|
| * Adds the given [ServerOperation] to the queue, but does not schedule
|
| * operations execution.
|
| */
|
| @@ -483,7 +492,7 @@ class AnalysisServer {
|
| _schedulePerformOperation();
|
| } else {
|
| sendStatusNotification(null);
|
| - _notifyAnalysisComplete();
|
| + _onAnalysisCompleteController.add(null);
|
| }
|
| }
|
| }
|
| @@ -500,14 +509,6 @@ class AnalysisServer {
|
| }
|
|
|
| /**
|
| - * Remove the given [listener] from the list of listeners that are listening
|
| - * for lifecycle events from this server.
|
| - */
|
| - void removeAnalysisServerListener(AnalysisServerListener listener) {
|
| - listeners.remove(listener);
|
| - }
|
| -
|
| - /**
|
| * Send status notification to the client. The `operation` is the operation
|
| * being performed or `null` if analysis is complete.
|
| */
|
| @@ -904,24 +905,6 @@ class AnalysisServer {
|
| }
|
|
|
| /**
|
| - * Notify all listeners that analysis of [context] is started.
|
| - */
|
| - void _notifyAnalysisStarted(AnalysisContext context) {
|
| - listeners.forEach((AnalysisServerListener listener) {
|
| - listener.analysisStarted(context);
|
| - });
|
| - }
|
| -
|
| - /**
|
| - * Notify all listeners that analysis is complete.
|
| - */
|
| - void _notifyAnalysisComplete() {
|
| - listeners.forEach((AnalysisServerListener listener) {
|
| - listener.analysisComplete();
|
| - });
|
| - }
|
| -
|
| - /**
|
| * Schedules [performOperation] exection.
|
| */
|
| void _schedulePerformOperation() {
|
| @@ -955,19 +938,4 @@ class AnalysisServer {
|
| }
|
| }
|
|
|
| -/**
|
| - * An object that is listening for lifecycle events from an analysis server.
|
| - */
|
| -abstract class AnalysisServerListener {
|
| - /**
|
| - * Analysis is complete.
|
| - */
|
| - void analysisComplete();
|
| -
|
| - /**
|
| - * Analysis is started.
|
| - */
|
| - void analysisStarted(AnalysisContext context);
|
| -}
|
| -
|
| typedef void OptionUpdater(AnalysisOptionsImpl options);
|
|
|