| 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.
|
|
|
|
|