| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "LibLsp/JsonRpc/serializer.h" |
| 4 |
#include <vector> |
| 5 |
#include "lsDocumentUri.h" |
| 6 |
#include "LibLsp/lsp/lsAny.h" |
| 7 |
#include "LibLsp/lsp/lsTextEdit.h" |
| 8 |
struct ResourceOperation |
| 9 |
{ |
| 10 |
std::string kind; |
| 11 |
virtual ~ResourceOperation() = default; |
| 12 |
|
| 13 |
MAKE_SWAP_METHOD(ResourceOperation, kind); |
| 14 |
}; |
| 15 |
MAKE_REFLECT_STRUCT(ResourceOperation, kind); |
| 16 |
extern void Reflect(Writer& visitor, ResourceOperation* value); |
| 17 |
struct CreateFileOptions |
| 18 |
{ |
| 19 |
|
| 20 |
/** |
| 21 |
* Overwrite existing file. Overwrite wins over `ignoreIfExists` |
| 22 |
*/ |
| 23 |
optional<bool> overwrite = false; |
| 24 |
|
| 25 |
/** |
| 26 |
* Ignore if exists. |
| 27 |
*/ |
| 28 |
optional<bool> ignoreIfExists = false; |
| 29 |
|
| 30 |
MAKE_SWAP_METHOD(CreateFileOptions, overwrite, ignoreIfExists) |
| 31 |
}; |
| 32 |
MAKE_REFLECT_STRUCT(CreateFileOptions, overwrite, ignoreIfExists) |
| 33 |
struct lsCreateFile : public ResourceOperation |
| 34 |
{ |
| 35 |
|
| 36 |
/** |
| 37 |
* The resource to create. |
| 38 |
*/ |
| 39 |
lsCreateFile(); |
| 40 |
lsDocumentUri uri; |
| 41 |
|
| 42 |
/** |
| 43 |
* Additional options |
| 44 |
*/ |
| 45 |
optional<CreateFileOptions> options; |
| 46 |
|
| 47 |
/** |
| 48 |
* An optional annotation identifer describing the operation. |
| 49 |
* |
| 50 |
* @since 3.16.0 |
| 51 |
*/ |
| 52 |
optional<lsChangeAnnotationIdentifier> annotationId; |
| 53 |
|
| 54 |
MAKE_SWAP_METHOD(lsCreateFile, kind, uri, options, annotationId) |
| 55 |
}; |
| 56 |
MAKE_REFLECT_STRUCT(lsCreateFile, kind, uri, options, annotationId) |
| 57 |
|
| 58 |
struct DeleteFileOptions |
| 59 |
{ |
| 60 |
/** |
| 61 |
* Delete the content recursively if a folder is denoted. |
| 62 |
*/ |
| 63 |
optional<bool> recursive = false; |
| 64 |
|
| 65 |
/** |
| 66 |
* Ignore the operation if the file doesn't exist. |
| 67 |
*/ |
| 68 |
optional<bool> ignoreIfNotExists = false; |
| 69 |
|
| 70 |
MAKE_SWAP_METHOD(DeleteFileOptions, recursive, ignoreIfNotExists); |
| 71 |
}; |
| 72 |
|
| 73 |
MAKE_REFLECT_STRUCT(DeleteFileOptions, recursive, ignoreIfNotExists) |
| 74 |
|
| 75 |
struct lsDeleteFile : public ResourceOperation |
| 76 |
{ |
| 77 |
/** |
| 78 |
* The file to delete. |
| 79 |
*/ |
| 80 |
lsDeleteFile(); |
| 81 |
lsDocumentUri uri; |
| 82 |
|
| 83 |
/** |
| 84 |
* Delete options. |
| 85 |
*/ |
| 86 |
optional<DeleteFileOptions> options; |
| 87 |
|
| 88 |
MAKE_SWAP_METHOD(lsDeleteFile, kind, uri, options); |
| 89 |
}; |
| 90 |
MAKE_REFLECT_STRUCT(lsDeleteFile, kind, uri, options); |
| 91 |
|
| 92 |
typedef CreateFileOptions RenameFileOptions; |
| 93 |
struct lsRenameFile : public ResourceOperation |
| 94 |
{ |
| 95 |
/** |
| 96 |
* The old (existing) location. |
| 97 |
*/ |
| 98 |
lsRenameFile(); |
| 99 |
lsDocumentUri oldUri; |
| 100 |
|
| 101 |
/** |
| 102 |
* The new location. |
| 103 |
*/ |
| 104 |
|
| 105 |
lsDocumentUri newUri; |
| 106 |
|
| 107 |
/** |
| 108 |
* Rename options. |
| 109 |
*/ |
| 110 |
optional<RenameFileOptions> options; |
| 111 |
|
| 112 |
/** |
| 113 |
* An optional annotation identifer describing the operation. |
| 114 |
* |
| 115 |
* @since 3.16.0 |
| 116 |
*/ |
| 117 |
optional<lsChangeAnnotationIdentifier> annotationId; |
| 118 |
|
| 119 |
MAKE_SWAP_METHOD(lsRenameFile, kind, oldUri, newUri, options, annotationId) |
| 120 |
}; |
| 121 |
MAKE_REFLECT_STRUCT(lsRenameFile, kind, oldUri, newUri, options, annotationId); |
| 122 |
|
| 123 |
extern ResourceOperation* GetResourceOperation(lsp::Any& lspAny); |