@@ -39,13 +39,33 @@ class MockLspServerChannel implements LspServerCommunicationChannel {
39
39
/// Completer that will be signalled when the input stream is closed.
40
40
final Completer _closed = Completer ();
41
41
42
+ /// Errors popups sent to the user.
43
+ final shownErrors = < lsp.ShowMessageParams > [];
44
+
45
+ /// Warning popups sent to the user.
46
+ final shownWarnings = < lsp.ShowMessageParams > [];
47
+
42
48
MockLspServerChannel (bool _printMessages) {
43
49
if (_printMessages) {
44
50
_serverToClient.stream
45
51
.listen ((message) => print ('<== ' + jsonEncode (message)));
46
52
_clientToServer.stream
47
53
.listen ((message) => print ('==> ' + jsonEncode (message)));
48
54
}
55
+
56
+ // Keep track of any errors/warnings that are sent to the user with
57
+ // `window/showMessage`.
58
+ _serverToClient.stream.listen ((message) {
59
+ if (message is lsp.NotificationMessage &&
60
+ message.method == Method .window_showMessage &&
61
+ message.params is lsp.ShowMessageParams ) {
62
+ if (message.params? .type == MessageType .Error ) {
63
+ shownErrors.add (message.params);
64
+ } else if (message.params? .type == MessageType .Warning ) {
65
+ shownWarnings.add (message.params);
66
+ }
67
+ }
68
+ });
49
69
}
50
70
51
71
/// Future that will be completed when the input stream is closed.
@@ -167,7 +187,8 @@ class MockLspServerChannel implements LspServerCommunicationChannel {
167
187
(message is lsp.ResponseMessage && message.id == request.id) ||
168
188
(throwOnError &&
169
189
message is lsp.NotificationMessage &&
170
- message.method == Method .window_showMessage));
190
+ message.method == Method .window_showMessage &&
191
+ message.params? .type == MessageType .Error ));
171
192
172
193
if (response is lsp.ResponseMessage ) {
173
194
return response;
0 commit comments