| OLD | NEW |
| 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 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:math' show max; | 9 import 'dart:math' show max; |
| 10 | 10 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 File file = resourceProvider.getResource(path); | 565 File file = resourceProvider.getResource(path); |
| 566 return ContextManager.createSourceInContext(getAnalysisContext(path), file); | 566 return ContextManager.createSourceInContext(getAnalysisContext(path), file); |
| 567 } | 567 } |
| 568 | 568 |
| 569 /** | 569 /** |
| 570 * Handle a [request] that was read from the communication channel. | 570 * Handle a [request] that was read from the communication channel. |
| 571 */ | 571 */ |
| 572 void handleRequest(Request request) { | 572 void handleRequest(Request request) { |
| 573 _performance.logRequest(request); | 573 _performance.logRequest(request); |
| 574 runZoned(() { | 574 runZoned(() { |
| 575 PerformanceTag prevTag = | 575 ServerPerformanceStatistics.serverRequests.makeCurrentWhile(() { |
| 576 ServerPerformanceStatistics.serverRequests.makeCurrent(); | |
| 577 try { | |
| 578 int count = handlers.length; | 576 int count = handlers.length; |
| 579 for (int i = 0; i < count; i++) { | 577 for (int i = 0; i < count; i++) { |
| 580 try { | 578 try { |
| 581 Response response = handlers[i].handleRequest(request); | 579 Response response = handlers[i].handleRequest(request); |
| 582 if (response == Response.DELAYED_RESPONSE) { | 580 if (response == Response.DELAYED_RESPONSE) { |
| 583 return; | 581 return; |
| 584 } | 582 } |
| 585 if (response != null) { | 583 if (response != null) { |
| 586 channel.sendResponse(response); | 584 channel.sendResponse(response); |
| 587 return; | 585 return; |
| 588 } | 586 } |
| 589 } on RequestFailure catch (exception) { | 587 } on RequestFailure catch (exception) { |
| 590 channel.sendResponse(exception.response); | 588 channel.sendResponse(exception.response); |
| 591 return; | 589 return; |
| 592 } catch (exception, stackTrace) { | 590 } catch (exception, stackTrace) { |
| 593 RequestError error = | 591 RequestError error = |
| 594 new RequestError(RequestErrorCode.SERVER_ERROR, exception.toStri
ng()); | 592 new RequestError(RequestErrorCode.SERVER_ERROR, exception.toStri
ng()); |
| 595 if (stackTrace != null) { | 593 if (stackTrace != null) { |
| 596 error.stackTrace = stackTrace.toString(); | 594 error.stackTrace = stackTrace.toString(); |
| 597 } | 595 } |
| 598 Response response = new Response(request.id, error: error); | 596 Response response = new Response(request.id, error: error); |
| 599 channel.sendResponse(response); | 597 channel.sendResponse(response); |
| 600 return; | 598 return; |
| 601 } | 599 } |
| 602 } | 600 } |
| 603 channel.sendResponse(new Response.unknownRequest(request)); | 601 channel.sendResponse(new Response.unknownRequest(request)); |
| 604 } finally { | 602 }); |
| 605 prevTag.makeCurrent(); | |
| 606 } | |
| 607 }, onError: (exception, stackTrace) { | 603 }, onError: (exception, stackTrace) { |
| 608 sendServerErrorNotification(exception, stackTrace, fatal: true); | 604 sendServerErrorNotification(exception, stackTrace, fatal: true); |
| 609 }); | 605 }); |
| 610 } | 606 } |
| 611 | 607 |
| 612 /** | 608 /** |
| 613 * Returns `true` if there is a subscription for the given [service] and | 609 * Returns `true` if there is a subscription for the given [service] and |
| 614 * [file]. | 610 * [file]. |
| 615 */ | 611 */ |
| 616 bool hasAnalysisSubscription(AnalysisService service, String file) { | 612 bool hasAnalysisSubscription(AnalysisService service, String file) { |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 * Container with global [AnalysisServer] performance statistics. | 1327 * Container with global [AnalysisServer] performance statistics. |
| 1332 */ | 1328 */ |
| 1333 class ServerPerformanceStatistics { | 1329 class ServerPerformanceStatistics { |
| 1334 /** | 1330 /** |
| 1335 * The [PerformanceTag] for time spent in [ExecutionDomainHandler]. | 1331 * The [PerformanceTag] for time spent in [ExecutionDomainHandler]. |
| 1336 */ | 1332 */ |
| 1337 static PerformanceTag executionNotifications = | 1333 static PerformanceTag executionNotifications = |
| 1338 new PerformanceTag('executionNotifications'); | 1334 new PerformanceTag('executionNotifications'); |
| 1339 | 1335 |
| 1340 /** | 1336 /** |
| 1341 * The [PerformanceTag] for time spent in | |
| 1342 * PerformAnalysisOperation._updateIndex. | |
| 1343 */ | |
| 1344 static PerformanceTag index = new PerformanceTag('index'); | |
| 1345 | |
| 1346 /** | |
| 1347 * The [PerformanceTag] for time spent performing a _DartIndexOperation. | 1337 * The [PerformanceTag] for time spent performing a _DartIndexOperation. |
| 1348 */ | 1338 */ |
| 1349 static PerformanceTag indexOperation = new PerformanceTag('indexOperation'); | 1339 static PerformanceTag indexOperation = new PerformanceTag('indexOperation'); |
| 1350 | 1340 |
| 1351 /** | 1341 /** |
| 1352 * The [PerformanceTag] for time spent between calls to | 1342 * The [PerformanceTag] for time spent between calls to |
| 1353 * AnalysisServer.performOperation when the server is not idle. | 1343 * AnalysisServer.performOperation when the server is not idle. |
| 1354 */ | 1344 */ |
| 1355 static PerformanceTag intertask = new PerformanceTag('intertask'); | 1345 static PerformanceTag intertask = new PerformanceTag('intertask'); |
| 1356 | 1346 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1369 /** | 1359 /** |
| 1370 * The [PerformanceTag] for time spent in server comminication channels. | 1360 * The [PerformanceTag] for time spent in server comminication channels. |
| 1371 */ | 1361 */ |
| 1372 static PerformanceTag serverChannel = new PerformanceTag('serverChannel'); | 1362 static PerformanceTag serverChannel = new PerformanceTag('serverChannel'); |
| 1373 | 1363 |
| 1374 /** | 1364 /** |
| 1375 * The [PerformanceTag] for time spent in server request handlers. | 1365 * The [PerformanceTag] for time spent in server request handlers. |
| 1376 */ | 1366 */ |
| 1377 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1367 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 1378 } | 1368 } |
| OLD | NEW |