1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef DOCUMENTSYNCHRONIZATION_H
6#define DOCUMENTSYNCHRONIZATION_H
7
8#include "basicjsonstructures.h"
9
10namespace newlsp {
11struct DidOpenTextDocumentParams
12{
13 TextDocumentItem textDocument;
14};
15std::string toJsonValueStr(const DidOpenTextDocumentParams &val);
16
17struct TextDocumentContentChangeEvent
18{
19 std::optional<Range> range;
20 std::optional<unsigned int> rangeLength;
21 std::string text;
22 TextDocumentContentChangeEvent(const TextDocumentContentChangeEvent &other)
23 {
24 if (other.range)
25 range = other.range;
26 if (other.rangeLength)
27 rangeLength = other.rangeLength;
28 text = other.text;
29 }
30};
31std::string toJsonValueStr(const TextDocumentContentChangeEvent &val);
32
33struct DidChangeTextDocumentParams
34{
35 VersionedTextDocumentIdentifier textDocument;
36 std::vector<TextDocumentContentChangeEvent> contentChanges;
37 std::string formatValue(const std::vector<TextDocumentContentChangeEvent> &val) const;
38};
39std::string toJsonValueStr(const std::vector<TextDocumentContentChangeEvent> &val);
40
41struct WillSaveTextDocumentParams
42{
43 TextDocumentIdentifier textDocument;
44 newlsp::Enum::TextDocumentSaveReason::type_value reason;
45};
46
47struct SaveOptions
48{
49 std::optional<bool> includeText;
50};
51
52struct TextDocumentRegistrationOptions
53{
54 DocumentSelector documentSelector;
55};
56std::string toJsonValueStr(const TextDocumentRegistrationOptions &val);
57
58struct TextDocumentSaveRegistrationOptions : TextDocumentRegistrationOptions
59{
60 std::optional<bool> includeText;
61};
62
63struct DidSaveTextDocumentParams
64{
65 TextDocumentIdentifier textDocument;
66 std::optional<std::string> text;
67};
68
69struct DidCloseTextDocumentParams
70{
71 TextDocumentIdentifier textDocument;
72};
73
74struct TextDocumentSyncOptions
75{
76 std::optional<bool> openClose;
77 std::optional<newlsp::Enum::TextDocumentSyncKind::type_value> change;
78 std::optional<bool> willSave;
79 std::optional<bool> willSaveWaitUntil;
80 std::optional<std::any> save; // boolean | SaveOptions
81};
82
83struct ExecutionSummary
84{
85 unsigned int executionOrder;
86 bool success;
87};
88
89struct NotebookCell
90{
91 Enum::NotebookCellKind::type_value kind;
92 DocumentUri document;
93 std::any metadata;
94 ExecutionSummary executionSummary;
95};
96
97struct NotebookDocument
98{
99 URI uri;
100 std::string notebookType;
101 int version;
102 std::any metadata; //export type LSPObject = { [key: string]: LSPAny };
103 std::vector<NotebookCell> cells;
104};
105
106/* *
107 * Many structural encapsulation of notebook are omitted here,
108 * which is not used temporarily
109 * */
110} // newlsp
111
112#endif // DOCUMENTSYNCHRONIZATION_H
113