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 | |
10 | namespace newlsp { |
11 | struct DidOpenTextDocumentParams |
12 | { |
13 | TextDocumentItem textDocument; |
14 | }; |
15 | std::string toJsonValueStr(const DidOpenTextDocumentParams &val); |
16 | |
17 | struct 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 | }; |
31 | std::string toJsonValueStr(const TextDocumentContentChangeEvent &val); |
32 | |
33 | struct DidChangeTextDocumentParams |
34 | { |
35 | VersionedTextDocumentIdentifier textDocument; |
36 | std::vector<TextDocumentContentChangeEvent> contentChanges; |
37 | std::string formatValue(const std::vector<TextDocumentContentChangeEvent> &val) const; |
38 | }; |
39 | std::string toJsonValueStr(const std::vector<TextDocumentContentChangeEvent> &val); |
40 | |
41 | struct WillSaveTextDocumentParams |
42 | { |
43 | TextDocumentIdentifier textDocument; |
44 | newlsp::Enum::TextDocumentSaveReason::type_value reason; |
45 | }; |
46 | |
47 | struct SaveOptions |
48 | { |
49 | std::optional<bool> includeText; |
50 | }; |
51 | |
52 | struct TextDocumentRegistrationOptions |
53 | { |
54 | DocumentSelector documentSelector; |
55 | }; |
56 | std::string toJsonValueStr(const TextDocumentRegistrationOptions &val); |
57 | |
58 | struct TextDocumentSaveRegistrationOptions : TextDocumentRegistrationOptions |
59 | { |
60 | std::optional<bool> includeText; |
61 | }; |
62 | |
63 | struct DidSaveTextDocumentParams |
64 | { |
65 | TextDocumentIdentifier textDocument; |
66 | std::optional<std::string> text; |
67 | }; |
68 | |
69 | struct DidCloseTextDocumentParams |
70 | { |
71 | TextDocumentIdentifier textDocument; |
72 | }; |
73 | |
74 | struct 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 | |
83 | struct ExecutionSummary |
84 | { |
85 | unsigned int executionOrder; |
86 | bool success; |
87 | }; |
88 | |
89 | struct NotebookCell |
90 | { |
91 | Enum::NotebookCellKind::type_value kind; |
92 | DocumentUri document; |
93 | std::any metadata; |
94 | ExecutionSummary executionSummary; |
95 | }; |
96 | |
97 | struct 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 |