File: lsCommand.h

package info (click to toggle)
asymptote 3.02%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 33,400 kB
  • sloc: cpp: 172,516; ansic: 69,728; python: 14,967; sh: 5,599; javascript: 4,866; lisp: 1,507; perl: 1,417; makefile: 1,028; yacc: 610; lex: 449; xml: 182; asm: 8
file content (43 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include "LibLsp/JsonRpc/serializer.h"

#include <string>
#include <vector>
#include "lsAny.h"
//
//Represents a reference to a command.Provides a title which will be used to represent a command in the UI.
//Commands are identified by a string identifier.
//The recommended way to handle commands is to implement their execution on the server side
//if the clientand server provides the corresponding capabilities.Alternatively the tool
//extension code could handle the command.The protocol currently doesn't specify a set of well - known commands.
template<typename AnyArray>
struct lsCommand
{
    // Title of the command (ie, 'save')
    std::string title;
    // Actual command identifier.
    std::string command;
    // Arguments to run the command with.
    // **NOTE** This must be serialized as an array. Use
    // MAKE_REFLECT_STRUCT_WRITER_AS_ARRAY.
    optional<AnyArray> arguments;

    void swap(lsCommand<AnyArray>& arg) noexcept
    {
        title.swap(arg.title);
        command.swap(arg.command);
        arguments.swap(arg.arguments);
    }
};
template<typename TVisitor, typename T>
void Reflect(TVisitor& visitor, lsCommand<T>& value)
{
    REFLECT_MEMBER_START();
    REFLECT_MEMBER(title);
    REFLECT_MEMBER(command);
    REFLECT_MEMBER(arguments);
    REFLECT_MEMBER_END();
}

using lsCommandWithAny = lsCommand<std::vector<lsp::Any>>;