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

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: reduce variable scope 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/test/analysis_server_test.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 7ebd6c680fc2cfde806d6178e3a0591fd9f4b63d..d167ba4ebfdeb630512b4ff9808ff65049ebea19 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -12,6 +12,7 @@ import 'package:analysis_server/src/protocol.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';
/**
* Instances of the class [AnalysisServer] implement a server that listens on a
@@ -44,6 +45,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.
*/
@@ -73,6 +79,11 @@ class AnalysisServer {
final Map<AnalysisContext, String> contextIdMap = new Map<AnalysisContext, String>();
/**
+ * 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.
*
@@ -195,7 +206,10 @@ class AnalysisServer {
}
}
if (notices != null) {
+ sendStatusNotification(contextId);
sendNotices(contextId, notices);
+ } else {
+ sendStatusNotification(null);
}
}
@@ -214,6 +228,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);
+ }
+
static Map<String, Object> errorToJson(AnalysisError analysisError) {
// TODO(paulberry): move this function into the AnalysisError class.
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698