Debian Codegraph @

LspCpp/include/LibLsp/lsp/lsCommand.h

raw
1 #pragma once
2
3 #include "LibLsp/JsonRpc/serializer.h"
4
5 #include <string>
6 #include <vector>
7 #include "lsAny.h"
8 //
9 //Represents a reference to a command.Provides a title which will be used to represent a command in the UI.
10 //Commands are identified by a string identifier.
11 //The recommended way to handle commands is to implement their execution on the server side
12 //if the clientand server provides the corresponding capabilities.Alternatively the tool
13 //extension code could handle the command.The protocol currently doesn't specify a set of well - known commands.
14 template<typename AnyArray>
15 struct lsCommand
16 {
17 // Title of the command (ie, 'save')
18 std::string title;
19 // Actual command identifier.
20 std::string command;
21 // Arguments to run the command with.
22 // **NOTE** This must be serialized as an array. Use
23 // MAKE_REFLECT_STRUCT_WRITER_AS_ARRAY.
24 optional<AnyArray> arguments;
25
26 void swap(lsCommand<AnyArray>& arg) noexcept
27 {
28 title.swap(arg.title);
29 command.swap(arg.command);
30 arguments.swap(arg.arguments);
31 }
32 };
33 template<typename TVisitor, typename T>
34 void Reflect(TVisitor& visitor, lsCommand<T>& value)
35 {
36 REFLECT_MEMBER_START();
37 REFLECT_MEMBER(title);
38 REFLECT_MEMBER(command);
39 REFLECT_MEMBER(arguments);
40 REFLECT_MEMBER_END();
41 }
42
43 using lsCommandWithAny = lsCommand<std::vector<lsp::Any>>;