| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "LibLsp/JsonRpc/serializer.h" |
| 4 |
|
| 5 |
#include <string> |
| 6 |
#include "lsRange.h" |
| 7 |
|
| 8 |
//Since 3.16.0 there is also the concept of an annotated text edit which supports to add an annotation to a text edit. |
| 9 |
//The annotation can add information describing the change to the text edit. |
| 10 |
/** |
| 11 |
* Additional information that describes document changes. |
| 12 |
* |
| 13 |
* @since 3.16.0 |
| 14 |
*/ |
| 15 |
struct lsChangeAnnotation |
| 16 |
{ |
| 17 |
/** |
| 18 |
* A human-readable string describing the actual change. The string |
| 19 |
* is rendered prominent in the user interface. |
| 20 |
*/ |
| 21 |
std::string label; |
| 22 |
|
| 23 |
/** |
| 24 |
* A flag which indicates that user confirmation is needed |
| 25 |
* before applying the change. |
| 26 |
*/ |
| 27 |
optional<bool> needsConfirmation; |
| 28 |
|
| 29 |
/** |
| 30 |
* A human-readable string which is rendered less prominent in |
| 31 |
* the user interface. |
| 32 |
*/ |
| 33 |
optional<std::string> description; |
| 34 |
MAKE_REFLECT_STRUCT(lsChangeAnnotation, label, needsConfirmation, description) |
| 35 |
}; |
| 36 |
MAKE_REFLECT_STRUCT(lsChangeAnnotation, label, needsConfirmation, description) |
| 37 |
|
| 38 |
//Usually clients provide options to group the changes along the annotations they are associated with. |
| 39 |
//To support this in the protocol an edit or resource operation refers to a change annotation |
| 40 |
//using an identifier and not the change annotation literal directly.This allows servers to use |
| 41 |
//the identical annotation across multiple edits or resource operations which then allows clients |
| 42 |
//to group the operations under that change annotation.The actual change annotations together with |
| 43 |
//their identifers are managed by the workspace edit via the new property changeAnnotations. |
| 44 |
|
| 45 |
/** |
| 46 |
* An identifier referring to a change annotation managed by a workspace |
| 47 |
* edit. |
| 48 |
* |
| 49 |
* @since 3.16.0. |
| 50 |
*/ |
| 51 |
using lsChangeAnnotationIdentifier = std::string; |
| 52 |
/** |
| 53 |
* A special text edit with an additional change annotation. |
| 54 |
* |
| 55 |
* @since 3.16.0. |
| 56 |
*/ |
| 57 |
|
| 58 |
//A textual edit applicable to a text document. |
| 59 |
struct lsTextEdit |
| 60 |
{ |
| 61 |
// The range of the text document to be manipulated. To insert |
| 62 |
// text into a document create a range where start === end. |
| 63 |
lsRange range; |
| 64 |
|
| 65 |
// The string to be inserted. For delete operations use an |
| 66 |
// empty string. |
| 67 |
std::string newText; |
| 68 |
|
| 69 |
/** |
| 70 |
* The actual annotation identifier. |
| 71 |
*/ |
| 72 |
optional<lsChangeAnnotationIdentifier> annotationId; |
| 73 |
|
| 74 |
bool operator==(lsTextEdit const& that); |
| 75 |
std::string ToString() const; |
| 76 |
MAKE_SWAP_METHOD(lsTextEdit, range, newText, annotationId) |
| 77 |
}; |
| 78 |
MAKE_REFLECT_STRUCT(lsTextEdit, range, newText, annotationId) |
| 79 |
|
| 80 |
using lsAnnotatedTextEdit = lsTextEdit; |