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

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

Issue 299513003: improve analysis server notifications (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: extract constant 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/domain_server.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 1bc01d584eacc2664d559b8d0b8db4b6433931e7..c419055030f22bc7e7b49fccb1992b38daf21e04 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -24,6 +24,11 @@ class AnalysisServer {
static const String ERROR_NOTIFICATION_NAME = 'context.errors';
/**
+ * The name of the notification sent when analysis is complete.
+ */
+ static const String ANALYSIS_COMPLETE = "analysis.complete";
+
+ /**
* The name of the contextId parameter.
*/
static const String CONTEXT_ID_PARAM = 'contextId';
@@ -68,6 +73,11 @@ class AnalysisServer {
final Map<String, AnalysisContext> contextMap = new Map<String, AnalysisContext>();
/**
+ * A table mapping analysis contexts to the context id's associated with them.
+ */
+ final Map<AnalysisContext, String> contextIdMap = new Map<AnalysisContext, String>();
+
+ /**
* A list of the analysis contexts for which analysis work needs to be
* performed.
*
@@ -162,8 +172,10 @@ class AnalysisServer {
// Look for a context that has work to be done and then perform one task.
//
List<ChangeNotice> notices = null;
+ String contextId;
try {
AnalysisContext context = contextWorkQueue[0];
+ contextId = contextIdMap[context];
AnalysisResult result = context.performAnalysisTask();
notices = result.changeNotices;
} finally {
@@ -172,7 +184,10 @@ class AnalysisServer {
// unhandled exception trying to perform the analysis. In either case,
// remove the context form the work queue so we won't try to do more
// analysis on it.
- contextWorkQueue.removeAt(0);
+ AnalysisContext context = contextWorkQueue.removeAt(0);
+ var notification = new Notification(ANALYSIS_COMPLETE);
Paul Berry 2014/05/20 15:34:58 I'm concerned that this is going to lead to bugs,
+ notification.setParameter(CONTEXT_ID_PARAM, contextId);
+ sendNotification(notification);
}
//
// Schedule this method to be run again if there is any more work to be
@@ -183,17 +198,18 @@ class AnalysisServer {
}
}
if (notices != null) {
- sendNotices(notices);
+ sendNotices(contextId, notices);
}
}
/**
* Send the information in the given list of notices back to the client.
*/
- void sendNotices(List<ChangeNotice> notices) {
+ void sendNotices(String contextId, List<ChangeNotice> notices) {
for (int i = 0; i < notices.length; i++) {
ChangeNotice notice = notices[i];
Notification notification = new Notification(ERROR_NOTIFICATION_NAME);
+ notification.setParameter(CONTEXT_ID_PARAM, contextId);
notification.setParameter(SOURCE_PARAM, notice.source.encoding);
notification.setParameter(ERRORS_PARAM, notice.errors.map(
errorToJson).toList());
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/domain_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698