| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "LibLsp/JsonRpc/serializer.h" |
| 4 |
#include <vector> |
| 5 |
#include "lsTextDocumentEdit.h" |
| 6 |
#include "LibLsp/lsp/ResourceOperation.h" |
| 7 |
#include "lsAny.h" |
| 8 |
|
| 9 |
//A workspace edit represents changes to many resources managed in the workspace. |
| 10 |
//The edit should either provide changes or documentChanges. |
| 11 |
//If the client can handle versioned document edits and if documentChanges are present, the latter are preferred over changes. |
| 12 |
|
| 13 |
//Since version 3.13.0 a workspace edit can contain resource operations(create, delete or rename files and folders) as well. |
| 14 |
//If resource operations are present clients need to execute the operations in the order in which they are provided. |
| 15 |
//So a workspace edit for example can consist of the following two changes : (1) create file a.txt and (2) a text document edit which insert text into file a. |
| 16 |
//txt.An invalid sequence(e.g. (1) delete file a.txt and (2) insert text into file a.txt) will cause failure of the operation. |
| 17 |
//How the client recovers from the failure is described by the client capability : workspace.workspaceEdit.failureHandling |
| 18 |
|
| 19 |
struct lsChangeAnnotations |
| 20 |
{ |
| 21 |
lsChangeAnnotation id; |
| 22 |
MAKE_SWAP_METHOD(lsChangeAnnotations, id) |
| 23 |
}; |
| 24 |
MAKE_REFLECT_STRUCT(lsChangeAnnotations, id) |
| 25 |
struct lsWorkspaceEdit |
| 26 |
{ |
| 27 |
// Holds changes to existing resources. |
| 28 |
// changes ? : { [uri:string]: TextEdit[]; }; |
| 29 |
// std::unordered_map<lsDocumentUri, std::vector<lsTextEdit>> changes; |
| 30 |
|
| 31 |
// An array of `TextDocumentEdit`s to express changes to specific a specific |
| 32 |
// version of a text document. Whether a client supports versioned document |
| 33 |
// edits is expressed via `WorkspaceClientCapabilites.versionedWorkspaceEdit`. |
| 34 |
// |
| 35 |
optional<std::map<std::string, std::vector<lsTextEdit>>> changes; |
| 36 |
typedef std::pair<optional<lsTextDocumentEdit>, optional<lsp::Any>> Either; |
| 37 |
|
| 38 |
optional<std::vector<Either>> documentChanges; |
| 39 |
/** |
| 40 |
* A map of change annotations that can be referenced in |
| 41 |
* `AnnotatedTextEdit`s or create, rename and delete file / folder |
| 42 |
* operations. |
| 43 |
* |
| 44 |
* Whether clients honor this property depends on the client capability |
| 45 |
* `workspace.changeAnnotationSupport`. |
| 46 |
* |
| 47 |
* @since 3.16.0 |
| 48 |
*/ |
| 49 |
optional<lsChangeAnnotations> changeAnnotations; |
| 50 |
|
| 51 |
MAKE_SWAP_METHOD(lsWorkspaceEdit, changes, documentChanges, changeAnnotations) |
| 52 |
}; |
| 53 |
MAKE_REFLECT_STRUCT(lsWorkspaceEdit, changes, documentChanges, changeAnnotations) |
| 54 |
|
| 55 |
extern void Reflect(Reader& visitor, lsWorkspaceEdit::Either& value); |