| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:analysis_server/plugin/protocol/protocol.dart' as server; | 5 import 'package:analysis_server/plugin/protocol/protocol.dart' as server; |
| 6 import 'package:analysis_server/src/channel/channel.dart'; | 6 import 'package:analysis_server/src/channel/channel.dart'; |
| 7 import 'package:analysis_server/src/plugin/notification_manager.dart'; | 7 import 'package:analysis_server/src/plugin/notification_manager.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer_plugin/protocol/protocol.dart' as plugin; | 9 import 'package:analyzer_plugin/protocol/protocol.dart' as plugin; |
| 10 import 'package:analyzer_plugin/protocol/protocol_constants.dart' as plugin; | 10 import 'package:analyzer_plugin/protocol/protocol_constants.dart' as plugin; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 }); | 118 }); |
| 119 plugin.Outline pluginOutline1 = pluginOutline(0, 0); | 119 plugin.Outline pluginOutline1 = pluginOutline(0, 0); |
| 120 plugin.AnalysisOutlineParams params = | 120 plugin.AnalysisOutlineParams params = |
| 121 new plugin.AnalysisOutlineParams(fileA, [pluginOutline1]); | 121 new plugin.AnalysisOutlineParams(fileA, [pluginOutline1]); |
| 122 manager.handlePluginNotification('a', params.toNotification()); | 122 manager.handlePluginNotification('a', params.toNotification()); |
| 123 | 123 |
| 124 server.Outline serverOutline1 = serverOutline(0, 0); | 124 server.Outline serverOutline1 = serverOutline(0, 0); |
| 125 _verifyOutlines(fileA, serverOutline1); | 125 _verifyOutlines(fileA, serverOutline1); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void test_handlePluginNotification_pluginError() { |
| 129 bool isFatal = false; |
| 130 String message = 'message'; |
| 131 String stackTrace = 'stackTrace'; |
| 132 plugin.PluginErrorParams params = |
| 133 new plugin.PluginErrorParams(isFatal, message, stackTrace); |
| 134 manager.handlePluginNotification('a', params.toNotification()); |
| 135 _verifyPluginError(isFatal, message, stackTrace); |
| 136 } |
| 137 |
| 128 void test_recordAnalysisErrors_noSubscription() { | 138 void test_recordAnalysisErrors_noSubscription() { |
| 129 server.AnalysisError error = serverAnalysisError(0, 0, file: fileA); | 139 server.AnalysisError error = serverAnalysisError(0, 0, file: fileA); |
| 130 manager.recordAnalysisErrors('a', fileA, [error]); | 140 manager.recordAnalysisErrors('a', fileA, [error]); |
| 131 expect(channel.sentNotification, isNull); | 141 expect(channel.sentNotification, isNull); |
| 132 } | 142 } |
| 133 | 143 |
| 134 void test_recordAnalysisErrors_withSubscription() { | 144 void test_recordAnalysisErrors_withSubscription() { |
| 135 manager.setAnalysisRoots([testDir], []); | 145 manager.setAnalysisRoots([testDir], []); |
| 136 // | 146 // |
| 137 // Errors should be reported when they are recorded. | 147 // Errors should be reported when they are recorded. |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 server.Notification notification = channel.sentNotification; | 475 server.Notification notification = channel.sentNotification; |
| 466 expect(notification, isNotNull); | 476 expect(notification, isNotNull); |
| 467 expect(notification.event, 'analysis.outline'); | 477 expect(notification.event, 'analysis.outline'); |
| 468 server.AnalysisOutlineParams params = | 478 server.AnalysisOutlineParams params = |
| 469 new server.AnalysisOutlineParams.fromNotification(notification); | 479 new server.AnalysisOutlineParams.fromNotification(notification); |
| 470 expect(params, isNotNull); | 480 expect(params, isNotNull); |
| 471 expect(params.file, fileName); | 481 expect(params.file, fileName); |
| 472 expect(params.outline, equals(expectedOutline)); | 482 expect(params.outline, equals(expectedOutline)); |
| 473 channel.sentNotification = null; | 483 channel.sentNotification = null; |
| 474 } | 484 } |
| 485 |
| 486 void _verifyPluginError(bool isFatal, String message, String stackTrace) { |
| 487 server.Notification notification = channel.sentNotification; |
| 488 expect(notification, isNotNull); |
| 489 expect(notification.event, 'server.error'); |
| 490 server.ServerErrorParams params = |
| 491 new server.ServerErrorParams.fromNotification(notification); |
| 492 expect(params, isNotNull); |
| 493 expect(params.isFatal, isFatal); |
| 494 expect(params.message, message); |
| 495 expect(params.stackTrace, stackTrace); |
| 496 channel.sentNotification = null; |
| 497 } |
| 475 } | 498 } |
| 476 | 499 |
| 477 class TestChannel implements ServerCommunicationChannel { | 500 class TestChannel implements ServerCommunicationChannel { |
| 478 server.Notification sentNotification; | 501 server.Notification sentNotification; |
| 479 | 502 |
| 480 @override | 503 @override |
| 481 void close() { | 504 void close() { |
| 482 fail('Unexpected invocation of close'); | 505 fail('Unexpected invocation of close'); |
| 483 } | 506 } |
| 484 | 507 |
| 485 @override | 508 @override |
| 486 void listen(void onRequest(server.Request request), | 509 void listen(void onRequest(server.Request request), |
| 487 {Function onError, void onDone()}) { | 510 {Function onError, void onDone()}) { |
| 488 fail('Unexpected invocation of listen'); | 511 fail('Unexpected invocation of listen'); |
| 489 } | 512 } |
| 490 | 513 |
| 491 @override | 514 @override |
| 492 void sendNotification(server.Notification notification) { | 515 void sendNotification(server.Notification notification) { |
| 493 sentNotification = notification; | 516 sentNotification = notification; |
| 494 } | 517 } |
| 495 | 518 |
| 496 @override | 519 @override |
| 497 void sendResponse(server.Response response) { | 520 void sendResponse(server.Response response) { |
| 498 fail('Unexpected invocation of sendResponse'); | 521 fail('Unexpected invocation of sendResponse'); |
| 499 } | 522 } |
| 500 } | 523 } |
| OLD | NEW |