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