| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "LibLsp/JsonRpc/RequestInMessage.h" |
| 4 |
#include "LibLsp/JsonRpc/lsResponseMessage.h" |
| 5 |
|
| 6 |
#include <regex> |
| 7 |
#include "LibLsp/lsp/lsp_completion.h" |
| 8 |
#include "LibLsp/lsp/lsTextDocumentPositionParams.h" |
| 9 |
|
| 10 |
// How a completion was triggered |
| 11 |
enum class lsCompletionTriggerKind |
| 12 |
{ |
| 13 |
// Completion was triggered by typing an identifier (24x7 code |
| 14 |
// complete), manual invocation (e.g Ctrl+Space) or via API. |
| 15 |
Invoked = 1, |
| 16 |
|
| 17 |
// Completion was triggered by a trigger character specified by |
| 18 |
// the `triggerCharacters` properties of the `CompletionRegistrationOptions`. |
| 19 |
TriggerCharacter = 2 |
| 20 |
}; |
| 21 |
MAKE_REFLECT_TYPE_PROXY(lsCompletionTriggerKind); |
| 22 |
|
| 23 |
// Contains additional information about the context in which a completion |
| 24 |
// request is triggered. |
| 25 |
struct lsCompletionContext |
| 26 |
{ |
| 27 |
// How the completion was triggered. |
| 28 |
lsCompletionTriggerKind triggerKind = lsCompletionTriggerKind::Invoked; |
| 29 |
|
| 30 |
// The trigger character (a single character) that has trigger code complete. |
| 31 |
// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter` |
| 32 |
optional<std::string> triggerCharacter; |
| 33 |
|
| 34 |
MAKE_SWAP_METHOD(lsCompletionContext, triggerKind, triggerCharacter); |
| 35 |
}; |
| 36 |
MAKE_REFLECT_STRUCT(lsCompletionContext, triggerKind, triggerCharacter); |
| 37 |
|
| 38 |
struct lsCompletionParams : lsTextDocumentPositionParams |
| 39 |
{ |
| 40 |
// The completion context. This is only available it the client specifies to |
| 41 |
// send this using |
| 42 |
// `ClientCapabilities.textDocument.completion.contextSupport === true` |
| 43 |
optional<lsCompletionContext> context; |
| 44 |
|
| 45 |
MAKE_SWAP_METHOD(lsCompletionParams, textDocument, position, context); |
| 46 |
}; |
| 47 |
MAKE_REFLECT_STRUCT(lsCompletionParams, textDocument, position, context); |
| 48 |
|
| 49 |
namespace TextDocumentComplete |
| 50 |
{ |
| 51 |
|
| 52 |
typedef std::pair<optional<std::vector<lsCompletionItem>>, optional<CompletionList>> Either; |
| 53 |
|
| 54 |
}; |
| 55 |
extern void Reflect(Reader& visitor, TextDocumentComplete::Either& value); |
| 56 |
|
| 57 |
/** |
| 58 |
* The Completion request is sent from the client to the server to compute |
| 59 |
* completion items at a given cursor position. Completion items are |
| 60 |
* presented in the IntelliSense user interface. If computing complete |
| 61 |
* completion items is expensive servers can additional provide a handler |
| 62 |
* for the resolve completion item request. This request is sent when a |
| 63 |
* completion item is selected in the user interface. |
| 64 |
* |
| 65 |
* Registration Options: CompletionRegistrationOptions |
| 66 |
*/ |
| 67 |
DEFINE_REQUEST_RESPONSE_TYPE(td_completion, lsCompletionParams, CompletionList, "textDocument/completion") |