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

Side by Side Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 303233007: First cut at server timing tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed some bugs, added tests Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analysis.server; 5 library analysis.server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_logger.dart'; 9 import 'package:analysis_server/src/analysis_logger.dart';
10 import 'package:analysis_server/src/channel.dart'; 10 import 'package:analysis_server/src/channel.dart';
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 contextWorkQueue.clear(); 204 contextWorkQueue.clear();
205 } 205 }
206 if (contextWorkQueue.isEmpty) { 206 if (contextWorkQueue.isEmpty) {
207 // Nothing to do. 207 // Nothing to do.
208 return; 208 return;
209 } 209 }
210 // 210 //
211 // Look for a context that has work to be done and then perform one task. 211 // Look for a context that has work to be done and then perform one task.
212 // 212 //
213 List<ChangeNotice> notices = null; 213 List<ChangeNotice> notices = null;
214 // String contextId;
215 try { 214 try {
216 AnalysisContext context = contextWorkQueue[0]; 215 AnalysisContext context = contextWorkQueue[0];
217 // contextId = contextIdMap[context]; 216 //
218 // TODO(danrubel): Replace with context identifier or similar 217 // TODO(brianwilkerson) Add an optional function-valued parameter to
218 // performAnalysisTask that will be called when the task has been computed
219 // but before it is performed and send notification in the function:
220 //
221 // AnalysisResult result = context.performAnalysisTask((taskDescription) {
222 // sendStatusNotification(context.toString(), taskDescription);
223 // });
224 //
219 sendStatusNotification(context.toString()); 225 sendStatusNotification(context.toString());
220 AnalysisResult result = context.performAnalysisTask(); 226 AnalysisResult result = context.performAnalysisTask();
221 notices = result.changeNotices; 227 notices = result.changeNotices;
222 } finally { 228 } finally {
223 if (notices == null) { 229 if (notices == null) {
224 // Either we have no more work to do for this context, or there was an 230 // Either we have no more work to do for this context, or there was an
225 // unhandled exception trying to perform the analysis. In either case, 231 // unhandled exception trying to perform the analysis. In either case,
226 // remove the context form the work queue so we won't try to do more 232 // remove the context form the work queue so we won't try to do more
227 // analysis on it. 233 // analysis on it.
228 contextWorkQueue.removeAt(0); 234 contextWorkQueue.removeAt(0);
235 } else {
236 sendNotices(notices);
229 } 237 }
230 // 238 //
231 // Schedule this method to be run again if there is any more work to be 239 // Schedule this method to be run again if there is any more work to be
232 // done. 240 // done.
233 // 241 //
234 if (!contextWorkQueue.isEmpty) { 242 if (contextWorkQueue.isEmpty) {
243 sendStatusNotification(null);
244 } else {
235 _scheduleTask(); 245 _scheduleTask();
236 } 246 }
237 } 247 }
238 if (notices != null) {
239 sendNotices(notices);
240 } else {
241 sendStatusNotification(null);
242 }
243 } 248 }
244 249
245 /** 250 /**
246 * Send the information in the given list of notices back to the client. 251 * Send the information in the given list of notices back to the client.
247 */ 252 */
248 void sendNotices(List<ChangeNotice> notices) { 253 void sendNotices(List<ChangeNotice> notices) {
249 for (int i = 0; i < notices.length; i++) { 254 for (int i = 0; i < notices.length; i++) {
250 ChangeNotice notice = notices[i]; 255 ChangeNotice notice = notices[i];
251 Source source = notice.source; 256 Source source = notice.source;
252 CompilationUnit dartUnit = notice.compilationUnit; 257 CompilationUnit dartUnit = notice.compilationUnit;
(...skipping 26 matching lines...) Expand all
279 REGIONS, 284 REGIONS,
280 new DartUnitHighlightsComputer(dartUnit).compute()); 285 new DartUnitHighlightsComputer(dartUnit).compute());
281 sendNotification(notification); 286 sendNotification(notification);
282 } 287 }
283 288
284 /** 289 /**
285 * Send status notification to the client. The `contextId` indicates 290 * Send status notification to the client. The `contextId` indicates
286 * the current context being analyzed or `null` if analysis is complete. 291 * the current context being analyzed or `null` if analysis is complete.
287 */ 292 */
288 void sendStatusNotification(String contextId) { 293 void sendStatusNotification(String contextId) {
289 if (contextId == lastStatusNotificationContextId) { 294 // if (contextId == lastStatusNotificationContextId) {
290 return; 295 // return;
291 } 296 // }
292 lastStatusNotificationContextId = contextId; 297 lastStatusNotificationContextId = contextId;
293 Notification notification = new Notification(NOTIFICATION_STATUS); 298 Notification notification = new Notification(NOTIFICATION_STATUS);
294 Map<String, Object> analysis = new Map(); 299 Map<String, Object> analysis = new Map();
295 if (contextId != null) { 300 if (contextId != null) {
296 analysis['analyzing'] = true; 301 analysis['analyzing'] = true;
297 // TODO(danrubel): replace contextId with real analysisTarget 302 // TODO(danrubel): replace contextId with real analysisTarget
298 analysis['analysisTarget'] = contextId; 303 analysis['analysisTarget'] = contextId;
299 } else { 304 } else {
300 analysis['analyzing'] = false; 305 analysis['analyzing'] = false;
301 } 306 }
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 /** 521 /**
517 * An enumeration of the services provided by the server domain. 522 * An enumeration of the services provided by the server domain.
518 */ 523 */
519 class ServerService extends Enum2<ServerService> { 524 class ServerService extends Enum2<ServerService> {
520 static const ServerService STATUS = const ServerService('STATUS', 0); 525 static const ServerService STATUS = const ServerService('STATUS', 0);
521 526
522 static const List<ServerService> VALUES = const [STATUS]; 527 static const List<ServerService> VALUES = const [STATUS];
523 528
524 const ServerService(String name, int ordinal) : super(name, ordinal); 529 const ServerService(String name, int ordinal) : super(name, ordinal);
525 } 530 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698