Debian Codegraph @

LspCpp/include/LibLsp/lsp/windows/MessageNotify.h

raw
1 #pragma once
2
3 #include "LibLsp/JsonRpc/NotificationInMessage.h"
4 #include "LibLsp/JsonRpc/RequestInMessage.h"
5 #include "LibLsp/JsonRpc/lsResponseMessage.h"
6
7 // Show a message to the user.
8 enum class lsMessageType : int
9 {
10 Error = 1,
11 Warning = 2,
12 Info = 3,
13 Log = 4
14 };
15 MAKE_REFLECT_TYPE_PROXY(lsMessageType)
16 struct MessageParams
17 {
18 /**
19 * The message type.
20 */
21
22 lsMessageType type = lsMessageType::Error;
23
24 /**
25 * The actual message.
26 */
27 std::string message;
28
29 void swap(MessageParams& arg) noexcept
30 {
31 lsMessageType temp = type;
32 type = arg.type;
33 arg.type = temp;
34 message.swap(arg.message);
35 }
36 };
37 MAKE_REFLECT_STRUCT(MessageParams, type, message)
38
39 /**
40 * The log message notification is send from the server to the client to ask
41 * the client to log a particular message.
42 */
43 DEFINE_NOTIFICATION_TYPE(Notify_LogMessage, MessageParams, "window/logMessage")
44
45 /**
46 * The show message notification is sent from a server to a client to ask
47 * the client to display a particular message in the user interface.
48 */
49 DEFINE_NOTIFICATION_TYPE(Notify_ShowMessage, MessageParams, "window/showMessage")
50
51 /**
52 * The show message request is sent from a server to a client to ask the client to display a particular message in the
53 * user class. In addition to the show message notification the request allows to pass actions and to wait for an
54 * answer from the client.
55 */
56 struct MessageActionItem
57 {
58 /**
59 * A short title like 'Retry', 'Open Log' etc.
60 */
61
62 std::string title;
63 MAKE_SWAP_METHOD(MessageActionItem, title)
64 };
65 MAKE_REFLECT_STRUCT(MessageActionItem, title);
66
67 struct ShowMessageRequestParams : public MessageParams
68 {
69 /**
70 * The message action items to present.
71 */
72 std::vector<MessageActionItem> actions;
73
74 MAKE_SWAP_METHOD(ShowMessageRequestParams, type, message, actions)
75 };
76 MAKE_REFLECT_STRUCT(ShowMessageRequestParams, type, message, actions)
77
78 /**
79 * The show message request is sent from a server to a client to ask the
80 * client to display a particular message in the user interface. In addition
81 * to the show message notification the request allows to pass actions and
82 * to wait for an answer from the client.
83 */
84
85 DEFINE_REQUEST_RESPONSE_TYPE(WindowShowMessage, ShowMessageRequestParams, MessageActionItem, "window/showMessage")