| 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 int count = handlers.length; | 575 PerformanceTag prevTag = |
| 576 for (int i = 0; i < count; i++) { | 576 ServerPerformanceStatistics.serverRequests.makeCurrent(); |
| 577 try { | 577 try { |
| 578 Response response = handlers[i].handleRequest(request); | 578 int count = handlers.length; |
| 579 if (response == Response.DELAYED_RESPONSE) { | 579 for (int i = 0; i < count; i++) { |
| 580 try { |
| 581 Response response = handlers[i].handleRequest(request); |
| 582 if (response == Response.DELAYED_RESPONSE) { |
| 583 return; |
| 584 } |
| 585 if (response != null) { |
| 586 channel.sendResponse(response); |
| 587 return; |
| 588 } |
| 589 } on RequestFailure catch (exception) { |
| 590 channel.sendResponse(exception.response); |
| 580 return; | 591 return; |
| 581 } | 592 } catch (exception, stackTrace) { |
| 582 if (response != null) { | 593 RequestError error = |
| 594 new RequestError(RequestErrorCode.SERVER_ERROR, exception.toStri
ng()); |
| 595 if (stackTrace != null) { |
| 596 error.stackTrace = stackTrace.toString(); |
| 597 } |
| 598 Response response = new Response(request.id, error: error); |
| 583 channel.sendResponse(response); | 599 channel.sendResponse(response); |
| 584 return; | 600 return; |
| 585 } | 601 } |
| 586 } on RequestFailure catch (exception) { | |
| 587 channel.sendResponse(exception.response); | |
| 588 return; | |
| 589 } catch (exception, stackTrace) { | |
| 590 RequestError error = | |
| 591 new RequestError(RequestErrorCode.SERVER_ERROR, exception.toString
()); | |
| 592 if (stackTrace != null) { | |
| 593 error.stackTrace = stackTrace.toString(); | |
| 594 } | |
| 595 Response response = new Response(request.id, error: error); | |
| 596 channel.sendResponse(response); | |
| 597 return; | |
| 598 } | 602 } |
| 603 channel.sendResponse(new Response.unknownRequest(request)); |
| 604 } finally { |
| 605 prevTag.makeCurrent(); |
| 599 } | 606 } |
| 600 channel.sendResponse(new Response.unknownRequest(request)); | |
| 601 }, onError: (exception, stackTrace) { | 607 }, onError: (exception, stackTrace) { |
| 602 sendServerErrorNotification(exception, stackTrace, fatal: true); | 608 sendServerErrorNotification(exception, stackTrace, fatal: true); |
| 603 }); | 609 }); |
| 604 } | 610 } |
| 605 | 611 |
| 606 /** | 612 /** |
| 607 * Returns `true` if there is a subscription for the given [service] and | 613 * Returns `true` if there is a subscription for the given [service] and |
| 608 * [file]. | 614 * [file]. |
| 609 */ | 615 */ |
| 610 bool hasAnalysisSubscription(AnalysisService service, String file) { | 616 bool hasAnalysisSubscription(AnalysisService service, String file) { |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 * The [PerformanceTag] for time spent between calls to | 1358 * The [PerformanceTag] for time spent between calls to |
| 1353 * AnalysisServer.performOperation when the server is idle. | 1359 * AnalysisServer.performOperation when the server is idle. |
| 1354 */ | 1360 */ |
| 1355 static PerformanceTag idle = new PerformanceTag('idle'); | 1361 static PerformanceTag idle = new PerformanceTag('idle'); |
| 1356 | 1362 |
| 1357 /** | 1363 /** |
| 1358 * The [PerformanceTag] for time spent in | 1364 * The [PerformanceTag] for time spent in |
| 1359 * PerformAnalysisOperation._sendNotices. | 1365 * PerformAnalysisOperation._sendNotices. |
| 1360 */ | 1366 */ |
| 1361 static PerformanceTag notices = new PerformanceTag('notices'); | 1367 static PerformanceTag notices = new PerformanceTag('notices'); |
| 1368 |
| 1369 /** |
| 1370 * The [PerformanceTag] for time spent in server comminication channels. |
| 1371 */ |
| 1372 static PerformanceTag serverChannel = new PerformanceTag('serverChannel'); |
| 1373 |
| 1374 /** |
| 1375 * The [PerformanceTag] for time spent in server request handlers. |
| 1376 */ |
| 1377 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 1362 } | 1378 } |
| OLD | NEW |