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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 587783003: Replace AnalysisServerListener with Stream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/analysis_server/lib/src/domain_execution.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1236eb9f99d5135c3241124678f4db8cbd63f3e3..98d1438fc711a4e721bbb96ceb21e257f8b7fa0c 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -208,9 +208,9 @@ 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 complete.
*/
- List<AnalysisServerListener> listeners = <AnalysisServerListener>[];
+ StreamController _onAnalysisCompleteController;
/**
* True if any exceptions thrown by analysis should be propagated up the call
@@ -235,6 +235,11 @@ class AnalysisServer {
contextDirectoryManager =
new ServerContextManager(this, resourceProvider, packageMapProvider);
AnalysisEngine.instance.logger = new AnalysisLogger();
+ _onAnalysisCompleteController = new StreamController.broadcast(onListen: () {
+ if (isAnalysisComplete()) {
+ _onAnalysisCompleteController.add(null);
Paul Berry 2014/09/22 15:52:21 This will notify *all* listeners that analysis is
scheglov 2014/09/22 18:03:18 Done.
+ }
+ });
running = true;
Notification notification = new ServerConnectedParams().toNotification();
channel.sendNotification(notification);
@@ -334,14 +339,9 @@ 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 is complete.
*/
- void addAnalysisServerListener(AnalysisServerListener listener) {
- if (!listeners.contains(listener)) {
- listeners.add(listener);
- }
- }
+ Stream get onAnalysisComplete => _onAnalysisCompleteController.stream;
/**
* Adds the given [ServerOperation] to the queue, but does not schedule
@@ -482,7 +482,7 @@ class AnalysisServer {
_schedulePerformOperation();
} else {
sendStatusNotification(null);
- _notifyAnalysisComplete();
+ _onAnalysisCompleteController.add(null);
}
}
}
@@ -499,14 +499,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.
*/
@@ -903,15 +895,6 @@ class AnalysisServer {
}
/**
- * Notify all listeners that analysis is complete.
- */
- void _notifyAnalysisComplete() {
- listeners.forEach((AnalysisServerListener listener) {
- listener.analysisComplete();
- });
- }
-
- /**
* Schedules [performOperation] exection.
*/
void _schedulePerformOperation() {
@@ -945,14 +928,4 @@ class AnalysisServer {
}
}
-/**
- * An object that is listening for lifecycle events from an analysis server.
- */
-abstract class AnalysisServerListener {
- /**
- * Analysis is complete.
- */
- void analysisComplete();
-}
-
typedef void OptionUpdater(AnalysisOptionsImpl options);
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/domain_execution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698