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

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

Issue 298823007: add server.status notification (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove print statement Created 6 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/analysis_server/lib/src/get_handler.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 9ede7e812a2ebf9c02709d1e9bbdb4ecf77af295..b6818b0f154d32095c9eb6d54947521c54677b96 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -14,6 +14,7 @@ import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/error.dart';
import 'package:analyzer/src/generated/java_core.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/sdk_io.dart';
import 'package:analyzer/src/generated/source_io.dart';
@@ -49,6 +50,11 @@ class AnalysisServer {
static const String CONNECTED_NOTIFICATION = 'server.connected';
/**
+ * The event name of the status notification.
+ */
+ static const String STATUS_NOTIFICATION = 'server.status';
+
+ /**
* The channel from which requests are received and to which responses should
* be sent.
*/
@@ -94,6 +100,11 @@ class AnalysisServer {
final Map<Folder, PubFolder> folderMap = <Folder, PubFolder>{};
/**
+ * The context identifier used in the last status notification.
+ */
+ String lastStatusNotificationContextId = null;
+
+ /**
* A list of the analysis contexts for which analysis work needs to be
* performed.
*
@@ -197,6 +208,8 @@ class AnalysisServer {
try {
AnalysisContext context = contextWorkQueue[0];
// contextId = contextIdMap[context];
+ // TODO(danrubel): Replace with context identifier or similar
+ sendStatusNotification(context.toString());
AnalysisResult result = context.performAnalysisTask();
notices = result.changeNotices;
} finally {
@@ -216,9 +229,11 @@ class AnalysisServer {
}
}
// TODO(scheglov) implement for [PubFolder]
-// if (notices != null) {
+ if (notices != null) {
// sendNotices(contextId, notices);
-// }
+ } else {
+ sendStatusNotification(null);
+ }
}
// TODO(scheglov) rewrite for the new API.
@@ -238,6 +253,28 @@ class AnalysisServer {
// }
/**
+ * Send status notification to the client. The `contextId` indicates
+ * the current context being analyzed or `null` if analysis is complete.
+ */
+ void sendStatusNotification(String contextId) {
+ if (contextId == lastStatusNotificationContextId) {
+ return;
+ }
+ lastStatusNotificationContextId = contextId;
+ Notification notification = new Notification(STATUS_NOTIFICATION);
+ Map<String, Object> analysis = new Map();
+ if (contextId != null) {
+ analysis['analyzing'] = true;
+ // TODO(danrubel): replace contextId with real analysisTarget
+ analysis['analysisTarget'] = contextId;
+ } else {
+ analysis['analyzing'] = false;
+ }
+ notification.params['analysis'] = analysis;
+ channel.sendNotification(notification);
+ }
+
+ /**
* Implementation for `server.setAnalysisRoots`.
*
* TODO(scheglov) implement complete projects/contexts semantics.
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/get_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698