1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef LANGUAGEFEATURES_H
6#define LANGUAGEFEATURES_H
7
8#include "basicjsonstructures.h"
9
10namespace newlsp {
11
12/** Goto Declaration Request
13 * @brief The DeclarationParams struct
14 * Request:
15 * method: textDocument/declaration
16 * params: DeclarationParams defined as follows:
17 * Response:
18 * result: Location | Location[] | LocationLink[] |null
19 * partial result: Location[] | LocationLink[]
20 * error: code and message set in case an exception happens during the declaration request.
21 */
22struct DeclarationParams : TextDocumentPositionParams,
23 WorkDoneProgressParams, PartialResultParams {
24};
25std::string toJsonValueStr(const DeclarationParams &val);
26
27/**
28 * @brief The DefinitionParams struct
29 * Request:
30 * method: textDocument/definition
31 * params: DefinitionParams defined as follows:
32 * Response:
33 * result: Location | Location[] | LocationLink[] | null
34 * partial result: Location[] | LocationLink[]
35 * error: code and message set in case an exception happens during the definition request.
36 */
37struct DefinitionParams : TextDocumentPositionParams,
38 WorkDoneProgressParams, PartialResultParams {
39};
40std::string toJsonValueStr(const DefinitionParams &val);
41
42/** Goto Type Definition Request
43 * @brief The TypeDefinitionParams struct
44 * Request:
45 * method: textDocument/typeDefinition
46 * params: TypeDefinitionParams defined as follows:
47 * Response:
48 * result: Location | Location[] | LocationLink[] | null
49 * partial result: Location[] | LocationLink[]
50 * error: code and message set in case an exception happens during the definition request.
51 */
52struct TypeDefinitionParams : TextDocumentPositionParams,
53 WorkDoneProgressParams, PartialResultParams {
54};
55std::string toJsonValueStr(const TypeDefinitionParams &val);
56
57/** Goto Implementation Request
58 * @brief The ImplementationParams struct
59 * Request:
60 * method: textDocument/implementation
61 * params: ImplementationParams defined as follows:
62 * Response:
63 * result: Location | Location[] | LocationLink[] | null
64 * partial result: Location[] | LocationLink[]
65 * error: code and message set in case an exception happens during the definition request.
66 */
67struct ImplementationParams : TextDocumentPositionParams,
68 WorkDoneProgressParams, PartialResultParams {
69};
70std::string toJsonValueStr(const ImplementationParams &val);
71
72/** Find References Request
73 * @brief The ReferenceParams struct
74 * Request:
75 * method: textDocument/references
76 * params: ReferenceParams defined
77 * Response:
78 * result: Location[] | null
79 * partial result: Location[]
80 * error: code and message set in case an exception happens during the reference request.
81 */
82struct ReferenceParams : TextDocumentPositionParams,
83 WorkDoneProgressParams, PartialResultParams
84{
85 struct ReferenceContext
86 {
87 bool includeDeclaration;
88 };
89 ReferenceContext context;
90};
91std::string toJsonValueStr(const ReferenceParams::ReferenceContext &val);
92std::string toJsonValueStr(const ReferenceParams &val);
93
94/** namespace { Prepare Call Hierarchy Request
95 * @brief The CallHierarchyPrepareParams struct
96 * Request:
97 * method: textDocument/prepareCallHierarchy
98 * params: CallHierarchyPrepareParams defined
99 * Response:
100 * result: CallHierarchyItem[] | null defined
101 * error: code and message set in case an exception happens during the ‘textDocument/prepareCallHierarchy’ request
102 */
103struct CallHierarchyPrepareParams : TextDocumentPositionParams,
104 WorkDoneProgressParams {
105};
106std::string toJsonValueStr(const CallHierarchyPrepareParams &val);
107
108struct CallHierarchyItem
109{
110 std::string name;
111 newlsp::Enum::SymbolKind::type_value kind;
112 std::optional<std::vector<newlsp::Enum::SymbolTag::type_value>> tags;
113 std::optional<std::string> detail;
114 DocumentUri uri;
115 Range range;
116 Range selectionRange;
117 std::optional<std::string> data; //unknown;
118};
119
120/** Call Hierarchy Incoming Calls
121 * @brief The CallHierarchyIncomingCallsParams struct
122 * Request:
123 * method: callHierarchy/incomingCalls
124 * params: CallHierarchyIncomingCallsParams defined
125 * Response:
126 * result: CallHierarchyIncomingCall[] | null
127 * partial result: CallHierarchyIncomingCall[]
128 * error: code and message set in case an exception happens during the ‘callHierarchy/incomingCalls’ request
129 */
130struct CallHierarchyIncomingCallsParams : WorkDoneProgressParams,
131 PartialResultParams {
132 CallHierarchyItem item;
133};
134std::string toJsonValueStr(const CallHierarchyIncomingCallsParams &val);
135
136struct CallHierarchyIncomingCall {
137 CallHierarchyItem from;
138 std::vector<Range> fromRanges;
139};
140
141/** Call Hierarchy Outgoing Calls
142 * @brief The CallHierarchyOutgoingCallsParams struct
143 * Request:
144 * method: callHierarchy/outgoingCalls
145 * params: CallHierarchyOutgoingCallsParams defined
146 * Response:
147 * result: CallHierarchyOutgoingCall[] | null defined
148 * partial result: CallHierarchyOutgoingCall[]
149 * error: code and message set in case an exception happens during the ‘callHierarchy/outgoingCalls’ request
150 */
151struct CallHierarchyOutgoingCallsParams : WorkDoneProgressParams,
152 PartialResultParams {
153 CallHierarchyItem item;
154};
155std::string toJsonValueStr(const CallHierarchyOutgoingCallsParams &val);
156
157struct CallHierarchyOutgoingCall {
158 CallHierarchyItem to;
159 std::vector<Range> fromRanges;
160};
161
162/** Prepare Type Hierarchy Request
163 * @brief The TypeHierarchyPrepareParams struct
164 * Request:
165 * method: ‘textDocument/prepareTypeHierarchy’
166 * params: TypeHierarchyPrepareParams defined
167 * Response:
168 * result: TypeHierarchyItem[] | null defined
169 * error: code and message set in case an exception happens during the ‘textDocument/prepareTypeHierarchy’ request
170 */
171struct TypeHierarchyPrepareParams : TextDocumentPositionParams,
172 WorkDoneProgressParams {
173};
174std::string toJsonValueStr(const TypeHierarchyPrepareParams &val);
175
176struct TypeHierarchyItem {
177 std::string name;
178 newlsp::Enum::SymbolKind::type_value kind;
179 std::optional<std::vector<newlsp::Enum::SymbolTag::type_value>> tags;
180 std::optional<std::string> detail;
181 DocumentUri uri;
182 Range range;
183 Range selectionRange;
184 std::optional<std::string> data; // LSPAny
185};
186std::string toJsonValueStr(const TypeHierarchyItem &val);
187
188/** Type Hierarchy Supertypes
189 * @brief The TypeHierarchySupertypesParams struct
190 * Request:
191 * method: ‘typeHierarchy/supertypes’
192 * params: TypeHierarchySupertypesParams defined as follows:
193 * Response:
194 * result: TypeHierarchyItem[] | null
195 * partial result: TypeHierarchyItem[]
196 * error: code and message set in case an exception happens during the ‘typeHierarchy/supertypes’ request
197 */
198struct TypeHierarchySupertypesParams : WorkDoneProgressParams,
199 PartialResultParams {
200 TypeHierarchyItem item;
201};
202std::string toJsonValueStr(const TypeHierarchySupertypesParams &val);
203
204/** Type Hierarchy Subtypes
205 * @brief The TypeHierarchySubtypesParams struct
206 * Request:
207 * method: ‘typeHierarchy/subtypes’
208 * params: TypeHierarchySubtypesParams defined as follows:
209 * Response:
210 * result: TypeHierarchyItem[] | null
211 * partial result: TypeHierarchyItem[]
212 * error: code and message set in case an exception happens during the ‘typeHierarchy/subtypes’ request
213 */
214struct TypeHierarchySubtypesParams : WorkDoneProgressParams,
215 PartialResultParams {
216 TypeHierarchyItem item;
217};
218std::string toJsonValueStr(const TypeHierarchySubtypesParams &val);
219
220/** Document Highlights Request
221 * @brief The DocumentHighlightParams struct
222 * Request:
223 * method: textDocument/documentHighlight
224 * params: DocumentHighlightParams defined
225 * Response:
226 * result: DocumentHighlight[] | null defined
227 * partial result: DocumentHighlight[]
228 * error: code and message set in case an exception happens during the document highlight request.
229 */
230struct DocumentHighlightParams : TextDocumentPositionParams,
231 WorkDoneProgressParams, PartialResultParams {
232};
233std::string toJsonValueStr(const DocumentHighlightParams &val);
234
235struct DocumentHighlight {
236 Range range;
237 std::optional<Enum::DocumentHighlightKind::type_value> kind;
238};
239
240/** Document Link Request
241 * @brief The DocumentLinkParams struct
242 * Request:
243 * method: textDocument/documentLink
244 * params: DocumentLinkParams defined as follows:
245 * Response:
246 * result: DocumentLink[] | null.
247 * partial result: DocumentLink[]
248 * error: code and message set in case an exception happens during the document link request.
249 */
250struct DocumentLinkParams : WorkDoneProgressParams,
251 PartialResultParams {
252 TextDocumentIdentifier textDocument;
253};
254std::string toJsonValueStr(const DocumentLinkParams &val);
255
256struct DocumentLink {
257 Range range;
258 std::optional<DocumentUri> target;
259 std::string tooltip;
260 std::optional<std::string> data;
261};
262
263/** Document Link Resolve Request
264 * Request:
265 * method: documentLink/resolve
266 * params: DocumentLink
267 * Response:
268 * result: DocumentLink
269 * error: code and message set in case an exception happens during the document link resolve request.
270 */
271std::string toJsonValueStr(const DocumentLink &val);
272
273/** Hover Request
274 * @brief The HoverParams struct
275 * Request:
276 * method: textDocument/hover
277 * params: HoverParams defined
278 * Response:
279 * result: Hover | null defined
280 * error: code and message set in case an exception happens during the hover request.
281 */
282struct HoverParams : TextDocumentPositionParams,
283 WorkDoneProgressParams {
284};
285std::string toJsonValueStr(const HoverParams &val);
286
287struct MarkedString : std::string
288{
289 std::string language;
290 std::string value;
291 MarkedString() = default;
292 MarkedString(const std::string &language, const std::string value)
293 : language(language), value(value){}
294 MarkedString(const std::string &other)
295 : std::string(other){
296 }
297};
298struct Hover
299{
300 std::any contents; //MarkedString | MarkedString[] | MarkupContent;
301 std::optional<Range> range;
302};
303
304/** Code Lens Request
305 * @brief The CodeLensParams struct
306 * Request:
307 * method: textDocument/codeLens
308 * params: CodeLensParams defined
309 * Response:
310 * result: CodeLens[] | null defined
311 * partial result: CodeLens[]
312 * error: code and message set in case an exception happens during the code lens request.
313 */
314struct CodeLensParams : WorkDoneProgressParams, PartialResultParams {
315 TextDocumentIdentifier textDocument;
316};
317std::string toJsonValueStr(const CodeLensParams &val);
318
319struct CodeLens {
320 Range range;
321 std::optional<Command> command;
322 std::optional<std::string> data;
323};
324
325/** Code Lens Resolve Request
326 * Request:
327 * method: codeLens/resolve
328 * params: CodeLens
329 * Response:
330 * result: CodeLens
331 * error: code and message set in case an exception happens during the code lens resolve request.
332 */
333std::string toJsonValueStr(const CodeLens &val);
334
335/** Code Lens Refresh Request
336 * Request:
337 * method: workspace/codeLens/refresh
338 * params: none
339 * Response:
340 * result: void
341 * error: code and message set in case an exception happens during the ‘workspace/codeLens/refresh’ request
342 */
343
344
345/** Folding Range Request
346 * @brief The FoldingRangeParams struct
347 * Request:
348 * method: textDocument/foldingRange
349 * params: FoldingRangeParams defined
350 * Response:
351 * result: FoldingRange[] | null defined
352 * partial result: FoldingRange[]
353 * error: code and message set in case an exception happens during the ‘textDocument/foldingRange’ request
354 */
355struct FoldingRangeParams : WorkDoneProgressParams,
356 PartialResultParams {
357 TextDocumentIdentifier textDocument;
358};
359std::string toJsonValueStr(const FoldingRangeParams &val);
360
361struct FoldingRange {
362 unsigned int startLine;
363 std::optional<unsigned int> startCharacter;
364 unsigned int endLine;
365 std::optional<unsigned int> endCharacter;
366 std::optional<newlsp::Enum::FoldingRangeKind::type_value> kind;
367 std::optional<std::string> collapsedText;
368};
369
370/** Selection Range Request
371 * @brief The SelectionRangeParams struct
372 * Request:
373 * method: textDocument/selectionRange
374 * params: SelectionRangeParams defined
375 * Response:
376 * result: SelectionRange[] | null defined
377 * partial result: SelectionRange[]
378 * error: code and message set in case an exception happens during the ‘textDocument/selectionRange’ request
379 */
380struct SelectionRangeParams : WorkDoneProgressParams,
381 PartialResultParams {
382 TextDocumentIdentifier textDocument;
383 std::vector<Position> positions;
384};
385std::string toJsonValueStr(const std::vector<Position> &val);
386std::string toJsonValueStr(const SelectionRangeParams &val);
387
388struct SelectionRange {
389 Range range;
390 std::optional<std::string> parent;
391};
392
393/** Document Symbols Request
394 * @brief The DocumentSymbolParams struct
395 * Request:
396 * method: textDocument/documentSymbol
397 * params: DocumentSymbolParams defined
398 * Response:
399 * result: DocumentSymbol[] | SymbolInformation[] | null defined
400 * partial result: DocumentSymbol[] | SymbolInformation[]. DocumentSymbol[] and SymbolInformation[] can not be mixed. That means the first chunk defines the type of all the other chunks.
401 * error: code and message set in case an exception happens during the document symbol request.
402 */
403struct DocumentSymbolParams : WorkDoneProgressParams,
404 PartialResultParams {
405 TextDocumentIdentifier textDocument;
406};
407std::string toJsonValueStr(const DocumentSymbolParams &val);
408
409struct DocumentSymbol {
410 std::string name;
411 std::optional<std::string> detail;
412 newlsp::Enum::SymbolKind::type_value kind;
413 std::optional<std::vector<newlsp::Enum::SymbolTag::type_value>> tags;
414 std::optional<bool> deprecated;
415 Range range;
416 Range selectionRange;
417 std::optional<std::vector<DocumentSymbol>> children;
418};
419struct SymbolInformation {
420 std::string name;
421 newlsp::Enum::SymbolKind::type_value kind;
422 std::optional<std::vector<newlsp::Enum::SymbolTag::type_value>> tags;
423 std::optional<bool> deprecated;
424 Location location;
425 std::optional<std::string> containerName;
426};
427
428/** Semantic Tokens
429 * @brief The SemanticTokensParams struct
430 * Request:
431 * method: textDocument/semanticTokens/full
432 * params: SemanticTokensParams defined
433 * Response:
434 * result: SemanticTokens | null where SemanticTokens is defined
435 * partial result: SemanticTokensPartialResult defines
436 * error: code and message set in case an exception happens during the ‘textDocument/semanticTokens/full’ request
437 */
438struct SemanticTokensParams : WorkDoneProgressParams,
439 PartialResultParams {
440 TextDocumentIdentifier textDocument;
441};
442std::string toJsonValueStr(const SemanticTokensParams &val);
443
444struct SemanticTokens {
445 std::optional<std::string> resultId;
446 std::vector<unsigned int> data;
447};
448struct SemanticTokensPartialResult {
449 std::vector<unsigned int> data;
450};
451
452/**
453 * @brief The SemanticTokensDeltaParams struct
454 * Request:
455 * method: textDocument/semanticTokens/full/delta
456 * params: SemanticTokensDeltaParams defined as follows:
457 * Response:
458 * result: SemanticTokens | SemanticTokensDelta | null where SemanticTokensDelta is defined
459 * partial result: SemanticTokensDeltaPartialResult defines as follows:
460 * error: code and message set in case an exception happens during the ‘textDocument/semanticTokens/full/delta’ request
461 */
462struct SemanticTokensDeltaParams : WorkDoneProgressParams,
463 PartialResultParams {
464 TextDocumentIdentifier textDocument;
465 std::string previousResultId;
466};
467std::string toJsonValueStr(const SemanticTokensDeltaParams &val);
468
469struct SemanticTokensEdit {
470 unsigned int start;
471 unsigned int deleteCount;
472 std::vector<unsigned int> data;
473};
474struct SemanticTokensDelta {
475 std::optional<std::string> resultId;
476 std::vector<SemanticTokensEdit> edits;
477};
478struct SemanticTokensDeltaPartialResult {
479 std::vector<SemanticTokensEdit> edits;
480};
481
482/**
483 * @brief The SemanticTokensRangeParams struct
484 * Request:
485 * method: textDocument/semanticTokens/range
486 * params: SemanticTokensRangeParams defined as follows:
487 * Response:
488 * result: SemanticTokens | null
489 * partial result: SemanticTokensPartialResult
490 * error: code and message set in case an exception happens during the ‘textDocument/semanticTokens/range’ request
491 */
492struct SemanticTokensRangeParams : WorkDoneProgressParams,
493 PartialResultParams {
494 TextDocumentIdentifier textDocument;
495 Range range;
496};
497std::string toJsonValueStr(const SemanticTokensRangeParams &val);
498
499/**
500 * Request:
501 * method: workspace/semanticTokens/refresh
502 * params: none
503 * Response:
504 * result: void
505 * error: code and message set in case an exception happens during the ‘workspace/semanticTokens/refresh’ request
506 */
507
508
509/** Inlay Hint Request
510 * @brief The InlayHintParams struct
511 * Request:
512 * method: textDocument/inlayHint
513 * params: InlayHintParams defined as follows:
514 * Response:
515 * result: InlayHint[] | null defined as follows:
516 * error: code and message set in case an exception happens during the inlay hint request.
517 */
518struct InlayHintParams : WorkDoneProgressParams {
519 TextDocumentIdentifier textDocument;
520 Range range;
521};
522std::string toJsonValueStr(const InlayHintParams &val);
523
524struct InlayHintLabelPart {
525 std::string value;
526 std::optional<std::any> tooltip; // string | MarkupContent
527 std::optional<Location> location;
528 std::optional<Command> command;
529};
530struct InlayHint {
531 struct _Label : std::string, std::vector<InlayHintLabelPart>{
532 _Label(const std::string &string) : std::string(string){}
533 _Label(const std::vector<InlayHintLabelPart> &inlayHintLabelPart)
534 : std::vector<InlayHintLabelPart>(inlayHintLabelPart){}
535 };
536 struct _Tooltip : std::string, MarkupContent{
537 _Tooltip(const std::string &string) : std::string(string){}
538 _Tooltip(const MarkupContent &content) : MarkupContent(content){}
539 };
540 Position position;
541 _Label label;
542 newlsp::Enum::InlayHintKind::type_value kind;
543 std::optional<std::vector<TextEdit>> textEdits;
544 std::optional<_Tooltip> tooltip;
545 std::optional<bool> paddingLeft;
546 std::optional<bool> paddingRight;
547 std::optional<std::any> data; // LSPAny
548};
549
550/** Inlay Hint Resolve Request
551 * Request:
552 * method: inlayHint/resolve
553 * params: InlayHint
554 * Response:
555 * result: InlayHint
556 * error: code and message set in case an exception happens during the completion resolve request.
557 */
558
559/** Inlay Hint Refresh Request
560 * Request:
561 * method: workspace/inlayHint/refresh
562 * params: none
563 * Response:
564 * result: void
565 * error: code and message set in case an exception happens during the ‘workspace/inlayHint/refresh’ request
566 */
567
568
569/** Inline Value Request
570 * @brief The InlineValueParams struct
571 * Request:
572 * method: textDocument/inlineValue
573 * params: InlineValueParams defined
574 * Response:
575 * result: InlineValue[] | null defined
576 * error: code and message set in case an exception happens during the inline values request.
577 */
578struct InlineValueContext {
579 int frameId;
580 Range stoppedLocation;
581};
582struct InlineValueParams : WorkDoneProgressParams {
583 TextDocumentIdentifier textDocument;
584 Range range;
585 InlineValueContext context;
586};
587std::string toJsonValueStr(const InlineValueContext &val);
588std::string toJsonValueStr(const InlineValueParams &val);
589
590struct InlineValueText {
591 Range range;
592 std::string text;
593};
594struct InlineValueVariableLookup {
595 Range range;
596 std::optional<std::string> variableName;
597 bool caseSensitiveLookup;
598};
599struct InlineValueEvaluatableExpression {
600 Range range;
601 std::optional<std::string> expression;
602};
603struct InlineValue : InlineValueText, InlineValueVariableLookup,
604 InlineValueEvaluatableExpression{
605 InlineValue(const Range &range, const std::string text) : InlineValueText{range, text} {}
606 InlineValue(const Range &range, bool caseSensitiveLookup, const std::optional<std::string> &variableName)
607 : InlineValueVariableLookup{range,variableName, caseSensitiveLookup}{}
608 InlineValue(const Range &range, const std::optional<std::string> &expression)
609 : InlineValueEvaluatableExpression{range, expression}{}
610};
611
612/** Inline Value Refresh Request
613 *
614 * Request:
615 * method: workspace/inlineValue/refresh
616 * params: none
617 * Response:
618 * result: void
619 * error: code and message set in case an exception happens during the ‘workspace/inlineValue/refresh’ request
620 */
621
622/** Monikers
623 * @brief The MonikerParams struct
624 * Request:
625 * method: textDocument/moniker
626 * params: MonikerParams defined as follows:
627 * Response:
628 * result: Moniker[] | null
629 * partial result: Moniker[]
630 * error: code and message set in case an exception happens during the ‘textDocument/moniker’ request
631 */
632struct MonikerParams : TextDocumentPositionParams,
633 WorkDoneProgressParams, PartialResultParams {
634};
635std::string toJsonValueStr(const MonikerParams &val);
636
637struct Moniker {
638 std::string scheme;
639 std::string identifier;
640 newlsp::Enum::UniquenessLevel::type_value unique;
641 std::optional<newlsp::Enum::MonikerKind::type_value> kind;
642};
643
644/** Completion Request
645 * @brief The CompletionParams struct
646 * Request:
647 * method: textDocument/completion
648 * params: CompletionParams defined as follows:
649 * Response:
650 * result: CompletionItem[] | CompletionList | null.
651 * If a CompletionItem[] is provided it is interpreted to be complete.
652 * So it is the same as { isIncomplete: false, items }
653 */
654struct CompletionContext{
655 newlsp::Enum::CompletionTriggerKind::type_value triggerKind;
656 std::optional<std::string> triggerCharacter;
657};
658struct CompletionParams : TextDocumentPositionParams,
659 WorkDoneProgressParams, PartialResultParams {
660 std::optional<CompletionContext> context;
661};
662std::string toJsonValueStr(const CompletionContext &val);
663std::string toJsonValueStr(const CompletionParams &val);
664
665struct CompletionItemLabelDetails {
666 std::optional<std::string> detail;
667 std::optional<std::string> description;
668};
669struct InsertReplaceEdit {
670 std::string newText;
671 Range insert;
672 Range replace;
673};
674struct DocumentationPart: std::string, MarkupContent{
675 DocumentationPart(const std::string &str) : std::string(str){}
676 DocumentationPart(const MarkupContent &content) : MarkupContent(content){}
677};
678struct TextEditPart : newlsp::TextEdit, InsertReplaceEdit{
679 TextEditPart(const newlsp::TextEdit &textEdit) : newlsp::TextEdit(textEdit){}
680 TextEditPart(const InsertReplaceEdit &insertReplaceEdit) : InsertReplaceEdit(insertReplaceEdit){}
681};
682struct CompletionItem {
683 std::string label;
684 std::optional<CompletionItemLabelDetails> labelDetails;
685 std::optional<newlsp::Enum::CompletionItemKind::type_value> kind;
686 std::optional<std::vector<newlsp::Enum::CompletionItemTag::type_value>> tags;
687 std::optional<std::string> detail;
688 std::optional<DocumentationPart> documentation;
689 std::optional<bool> deprecated;
690 std::optional<bool> preselect;
691 std::optional<std::string> sortText;
692 std::optional<std::string> filterText;
693 std::optional<std::string> insertText;
694 std::optional<newlsp::Enum::InsertTextFormat::type_value> insertTextFormat;
695 std::optional<newlsp::Enum::InsertTextMode::type_value> insertTextMode;
696 std::optional<TextEditPart> textEdit;
697 std::optional<std::string> textEditText;
698 std::optional<std::vector<TextEdit>> additionalTextEdits;
699 std::optional<std::vector<std::string>> commitCharacters;
700 std::optional<Command> command;
701 std::optional<std::any> data; // LSPAny;
702};
703struct CompletionList
704{
705 bool isIncomplete;
706 struct ItemDefaults {
707 struct EditRange : Range {
708 Range insert;
709 Range replace;
710 EditRange(const Range &range) : Range(range){}
711 EditRange(const Range &insert, const Range &replace) : insert(insert), replace(replace){}
712 };
713 std::optional<std::vector<std::string>> commitCharacters;
714 std::optional<EditRange> editRange;
715 std::optional<newlsp::Enum::InsertTextFormat::type_value> insertTextFormat;
716 std::optional<newlsp::Enum::InsertTextMode::type_value> insertTextMode;
717 std::optional<std::any> data;
718 };
719 std::optional<ItemDefaults> itemDefaults;
720 std::vector<CompletionItem> items;
721};
722
723/** Completion Item Resolve Request
724 * The request is sent from the client to the server to resolve additional information for a given completion item.
725 * Request:
726 * method: completionItem/resolve
727 * params: CompletionItem
728 * Response:
729 * result: CompletionItem
730 * error: code and message set in case an exception happens during the completion resolve request.
731 */
732
733/** PublishDiagnostics Notification
734 * caller is server
735 * Notification:
736 * method: textDocument/publishDiagnostics
737 * params: PublishDiagnosticsParams defined
738 */
739struct PublishDiagnosticsParams {
740 DocumentUri uri;
741 std::optional<int> version;
742 std::vector<Diagnostic> diagnostics;
743};
744
745/** Document Diagnostics Request
746 * @brief The DocumentDiagnosticParams struct
747 * Request:
748 * method: ‘textDocument/diagnostic’.
749 * params: DocumentDiagnosticParams defined
750 * Response:
751 * result: DocumentDiagnosticReport defined
752 * partial result: The first literal send need to be a DocumentDiagnosticReport followed by
753 * n DocumentDiagnosticReportPartialResult literals defined
754 * error: code and message set in case an exception happens during the diagnostic request.
755 * A server is also allowed to return an error with code ServerCancelled indicating
756 * that the server can’t compute the result right now.
757 * A server can return a DiagnosticServerCancellationData data to indicate whether the
758 * client should re-trigger the request.
759 * If no data is provided it defaults to { retriggerRequest: true }:
760 */
761struct DocumentDiagnosticParams : WorkDoneProgressParams,
762 PartialResultParams {
763 TextDocumentIdentifier textDocument;
764 std::optional<std::string> identifier;
765 std::optional<std::string> previousResultId;
766};
767std::string toJsonValueStr(const DocumentDiagnosticParams &val);
768
769enum_def(DocumentDiagnosticReportKind, std::string) {
770 enum_exp Full = "Full";
771 enum_exp Unchanged = "unchanged";
772};
773struct FullDocumentDiagnosticReport {
774 DocumentDiagnosticReportKind::type_value kind = DocumentDiagnosticReportKind::get()->Full;
775 std::optional<std::string> resultId;
776 std::vector<Diagnostic> items;
777};
778struct UnchangedDocumentDiagnosticReport {
779 DocumentDiagnosticReportKind::type_value kind = DocumentDiagnosticReportKind::get()->Unchanged;
780 std::string resultId;
781};
782struct RelatedDocuments_Value : FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport{
783 RelatedDocuments_Value(const FullDocumentDiagnosticReport &full)
784 : FullDocumentDiagnosticReport(full){}
785 RelatedDocuments_Value(const UnchangedDocumentDiagnosticReport &unchanged)
786 : UnchangedDocumentDiagnosticReport(unchanged){}
787};
788typedef std::string RelatedDocuments_Key;
789struct RelatedDocuments : std::pair<RelatedDocuments_Value, RelatedDocuments_Key> {};
790struct RelatedFullDocumentDiagnosticReport : FullDocumentDiagnosticReport {
791 std::optional<RelatedDocuments> relatedDocuments;
792};
793struct RelatedUnchangedDocumentDiagnosticReport : UnchangedDocumentDiagnosticReport {
794 struct _Value : FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport{
795 _Value(const FullDocumentDiagnosticReport &full)
796 : FullDocumentDiagnosticReport(full){}
797 _Value(const UnchangedDocumentDiagnosticReport &unchanged)
798 : UnchangedDocumentDiagnosticReport(unchanged){}
799 };
800 typedef std::string _Key;
801 typedef std::optional<std::pair<_Key, _Value>> _RelatedDocuments;
802 std::optional<_RelatedDocuments> relatedDocuments;
803};
804struct DocumentDiagnosticReport : RelatedFullDocumentDiagnosticReport, RelatedUnchangedDocumentDiagnosticReport {
805 DocumentDiagnosticReport(const RelatedFullDocumentDiagnosticReport &full)
806 : RelatedFullDocumentDiagnosticReport(full){}
807 DocumentDiagnosticReport(const RelatedUnchangedDocumentDiagnosticReport &unchanged)
808 : RelatedUnchangedDocumentDiagnosticReport(unchanged){}
809};
810struct DocumentDiagnosticReportPartialResult {
811 RelatedDocuments relatedDocuments;
812};
813struct DiagnosticServerCancellationData {
814 std::optional<bool> retriggerRequest;
815};
816
817/** Workspace Diagnostics Request
818 * @brief The WorkspaceDiagnosticParams struct
819 * Request:
820 * method: ‘workspace/diagnostic’.
821 * params: WorkspaceDiagnosticParams defined as follows:
822 * Response:
823 * result: WorkspaceDiagnosticReport defined as follows:
824 * error: code and message set in case an exception happens during the diagnostic request.
825 * A server is also allowed to return and error with
826 * code ServerCancelled indicating that the server can’t compute the result right now.
827 * A server can return a DiagnosticServerCancellationData data to indicate whether
828 * the client should re-trigger the request.
829 * If no data is provided it defaults to { retriggerRequest: true }
830 */
831struct PreviousResultId {
832 DocumentUri uri;
833 std::string value;
834};
835struct WorkspaceDiagnosticParams : WorkDoneProgressParams,
836 PartialResultParams {
837 std::optional<std::string> identifier;
838 std::vector<PreviousResultId> previousResultIds;
839};
840std::string toJsonValueStr(const PreviousResultId &val);
841std::string toJsonValueStr(const WorkspaceDiagnosticParams &val);
842
843struct WorkspaceFullDocumentDiagnosticReport : FullDocumentDiagnosticReport {
844 DocumentUri uri;
845 std::optional<int> version; // null;
846};
847struct WorkspaceUnchangedDocumentDiagnosticReport : UnchangedDocumentDiagnosticReport {
848 DocumentUri uri;
849 std::optional<int> version; // null;
850};
851struct WorkspaceDocumentDiagnosticReport : WorkspaceFullDocumentDiagnosticReport,
852 WorkspaceUnchangedDocumentDiagnosticReport{
853 WorkspaceDocumentDiagnosticReport(const WorkspaceFullDocumentDiagnosticReport &full)
854 : WorkspaceFullDocumentDiagnosticReport(full){}
855 WorkspaceDocumentDiagnosticReport(const WorkspaceUnchangedDocumentDiagnosticReport &unchanged)
856 : WorkspaceUnchangedDocumentDiagnosticReport(unchanged){}
857};
858struct WorkspaceDiagnosticReport {
859 std::vector<WorkspaceDocumentDiagnosticReport> items;
860};
861
862/** Diagnostics Refresh
863 * Request:
864 * method: workspace/diagnostic/refresh
865 * params: none
866 * Response:
867 * result: void
868 * error: code and message set in case an exception happens during the
869 * ‘workspace/diagnostic/refresh’ request
870 */
871
872
873/** Signature Help Request
874 * @brief The SignatureHelpParams struct
875 * Request:
876 * method: textDocument/signatureHelp
877 * params: SignatureHelpParams defined
878 * Response:
879 * result: SignatureHelp | null defined
880 * error: code and message set in case an exception happens during the signature help request.
881 */
882struct SignatureHelpParams : TextDocumentPositionParams,
883 WorkDoneProgressParams {
884 struct SignatureHelpContext {
885 struct SignatureHelp {
886 struct SignatureInformation {
887 struct ParameterInformation {
888 std::string label; // string | [uinteger, uinteger]; ???
889 std::optional<DocumentationPart> documentation;
890 };
891 std::string label;
892 std::optional<DocumentationPart> documentation;
893 std::optional<std::vector<ParameterInformation>> parameters;
894 std::optional<unsigned int> activeParameter;
895 };
896 std::vector<SignatureInformation> signatures;
897 std::optional<unsigned int> activeSignature;
898 std::optional<unsigned int> activeParameter;
899 };
900 Enum::SignatureHelpTriggerKind::type_value triggerKind;
901 std::optional<std::string> triggerCharacter;
902 bool isRetrigger;
903 std::optional<SignatureHelp> activeSignatureHelp;
904 };
905 std::optional<SignatureHelpContext> context;
906};
907std::string toJsonValueStr(const SignatureHelpParams::SignatureHelpContext::SignatureHelp::SignatureInformation::ParameterInformation &val);
908std::string toJsonValueStr(const SignatureHelpParams::SignatureHelpContext::SignatureHelp::SignatureInformation &val);
909std::string toJsonValueStr(const SignatureHelpParams::SignatureHelpContext::SignatureHelp &val);
910std::string toJsonValueStr(const SignatureHelpParams::SignatureHelpContext &val);
911std::string toJsonValueStr(const SignatureHelpParams &val);
912
913/** Code Action Request
914 * @brief The CodeActionParams struct
915 * Request:
916 * method: textDocument/codeAction
917 * params: CodeActionParams defined
918 * Response:
919 * result: (Command | CodeAction)[] | null where CodeAction is defined
920 * partial result: (Command | CodeAction)[]
921 * error: code and message set in case an exception happens during the code action request.
922 */
923struct CodeActionContext {
924 std::vector<Diagnostic> diagnostics;
925 std::optional<std::vector<Enum::CodeActionKind::type_value>> only;
926 std::optional<Enum::CodeActionTriggerKind::type_value> triggerKind;
927};
928struct CodeActionParams : WorkDoneProgressParams, PartialResultParams {
929 TextDocumentIdentifier textDocument;
930 Range range;
931 CodeActionContext context;
932};
933struct CodeAction {
934 struct Disabled {
935 std::string reason;
936 };
937 std::string title;
938 std::optional<Enum::CodeActionKind::type_value> kind;
939 std::optional<std::vector<Diagnostic>> diagnostics;
940 std::optional<bool> isPreferred;
941 std::optional<Disabled> disabled;
942 std::optional<WorkspaceEdit> edit;
943 std::optional<Command> command;
944 std::optional<std::string> data; //LSPAny
945};
946std::string toJsonValueStr(const CodeAction::Disabled &val);
947std::string toJsonValueStr(const CodeAction &val);
948std::string toJsonValueStr(const CodeActionContext &val);
949std::string toJsonValueStr(const CodeActionParams &val);
950
951/** Code Action Resolve Request
952 * Request:
953 * method: codeAction/resolve
954 * params: CodeAction
955 * Response:
956 * result: CodeAction
957 * error: code and message set in case an exception happens during the completion resolve request.
958 */
959
960/** Document Color Request
961 * @brief The DocumentColorParams struct
962 * Request:
963 * method: textDocument/documentColor
964 * params: DocumentColorParams defined
965 * Response:
966 * result: ColorInformation[] defined
967 * partial result: ColorInformation[]
968 * error: code and message set in case an exception happens during the ‘textDocument/documentColor’ request
969 */
970struct DocumentColorParams : WorkDoneProgressParams, PartialResultParams {
971 TextDocumentIdentifier textDocument;
972};
973std::string toJsonValueStr(const DocumentColorParams &val);
974
975struct Color {
976 float red;
977 float green;
978 float blue;
979 float alpha;
980};
981std::string toJsonValueStr(const Color &val);
982
983struct ColorInformation {
984 Range range;
985 Color color;
986};
987
988/** Color Presentation Request
989 * @brief The ColorPresentationParams struct
990 * Request:
991 * method: textDocument/colorPresentation
992 * params: ColorPresentationParams defined
993 * Response:
994 * result: ColorPresentation[] defined
995 * partial result: ColorPresentation[]
996 * error: code and message set in case an exception happens during the ‘textDocument/colorPresentation’ request
997 */
998struct ColorPresentationParams : WorkDoneProgressParams, PartialResultParams {
999 TextDocumentIdentifier textDocument;
1000 Color color;
1001 Range range;
1002};
1003std::string toJsonValueStr(const ColorPresentationParams &val);
1004
1005struct ColorPresentation {
1006 std::string label;
1007 std::optional<TextEdit> textEdit;
1008 std::optional<std::vector<TextEdit>> additionalTextEdits;
1009};
1010
1011/** Document Formatting Request
1012 * @brief The DocumentFormattingParams struct
1013 * Request:
1014 * method: textDocument/formatting
1015 * params: DocumentFormattingParams defined as follows
1016 * Response:
1017 * result: TextEdit[] | null describing the modification to the document to be formatted.
1018 * error: code and message set in case an exception happens during the formatting request.
1019 */
1020struct FormattingOptions : std::vector<std::pair<std::string, std::any>> {
1021 unsigned int tabSize;
1022 bool insertSpaces;
1023 std::optional<bool> trimTrailingWhitespace;
1024 std::optional<bool> insertFinalNewline;
1025 std::optional<bool> trimFinalNewlines;
1026};
1027struct DocumentFormattingParams : WorkDoneProgressParams {
1028 TextDocumentIdentifier textDocument;
1029 FormattingOptions options;
1030};
1031std::string toJsonValueStr(const FormattingOptions &val);
1032std::string toJsonValueStr(const DocumentFormattingParams &val);
1033
1034/** Document Range Formatting Request
1035 * @brief The DocumentRangeFormattingParams struct
1036 * Request:
1037 * method: textDocument/rangeFormatting,
1038 * params: DocumentRangeFormattingParams defined
1039 * Response:
1040 * result: TextEdit[] | null describing the modification to the document to be formatted.
1041 * error: code and message set in case an exception happens during the range formatting request.
1042 */
1043struct DocumentRangeFormattingParams : WorkDoneProgressParams {
1044 TextDocumentIdentifier textDocument;
1045 Range range;
1046 FormattingOptions options;
1047};
1048std::string toJsonValueStr(const DocumentRangeFormattingParams &val);
1049
1050/** Document on Type Formatting Request
1051 * @brief The DocumentOnTypeFormattingParams struct
1052 * Request:
1053 * method: textDocument/onTypeFormatting
1054 * params: DocumentOnTypeFormattingParams defined as follows:
1055 * Response:
1056 * result: TextEdit[] | null describing the modification to the document.
1057 * error: code and message set in case an exception happens during the range formatting request.
1058 */
1059struct DocumentOnTypeFormattingParams {
1060 TextDocumentIdentifier textDocument;
1061 Position position;
1062 std::string ch;
1063 FormattingOptions options;
1064};
1065std::string toJsonValueStr(const DocumentOnTypeFormattingParams &val);
1066
1067/** Rename Request
1068 * @brief The RenameParams struct
1069 * Request:
1070 * method: textDocument/rename
1071 * params: RenameParams defined as follows
1072 * Response:
1073 * result: WorkspaceEdit | null describing the modification to the workspace.
1074 * null should be treated the same was as WorkspaceEdit with no changes (no change was required).
1075 * error: code and message set in case when rename could not be performed for any reason.
1076 * Examples include: there is nothing at given position to rename (like a space),
1077 * given symbol does not support renaming by the server or the code is invalid (e.g. does not compile).
1078 */
1079struct RenameParams : TextDocumentPositionParams,
1080 WorkDoneProgressParams {
1081 std::string newName;
1082};
1083std::string toJsonValueStr(const RenameParams &val);
1084
1085/** Prepare Rename Request
1086 * @brief The PrepareRenameParams struct
1087 * Request:
1088 * method: textDocument/prepareRename
1089 * params: PrepareRenameParams defined
1090 * Response:
1091 * result: Range | { range: Range, placeholder: string } | { defaultBehavior: boolean } | null
1092 * describing a Range of the string to rename and optionally a placeholder text of
1093 * the string content to be renamed. If { defaultBehavior: boolean } is returned (since 3.16)
1094 * the rename position is valid and the client should use its default behavior to compute the rename range.
1095 * If null is returned then it is deemed that a ‘textDocument/rename’ request is not valid at the given position.
1096 * error: code and message set in case the element can’t be renamed.
1097 * Clients should show the information in their user interface.
1098 */
1099struct PrepareRenameParams : TextDocumentPositionParams
1100 , WorkDoneProgressParams {
1101};
1102std::string toJsonValueStr(const PrepareRenameParams &val);
1103
1104/** Linked Editing Range
1105 * @brief The LinkedEditingRangeParams struct
1106 * Request:
1107 * method: textDocument/linkedEditingRange
1108 * params: LinkedEditingRangeParams defined
1109 * Response:
1110 * result: LinkedEditingRanges | null defined
1111 * error: code and message set in case an exception happens during the ‘textDocument/linkedEditingRange’ request
1112 */
1113struct LinkedEditingRangeParams : TextDocumentPositionParams
1114 , WorkDoneProgressParams {
1115};
1116std::string toJsonValueStr(const LinkedEditingRangeParams &val);
1117
1118struct LinkedEditingRanges {
1119 std::vector<Range> ranges;
1120 std::optional<std::string> wordPattern;
1121};
1122
1123} // namespace newlsp
1124#endif // LANGUAGEFEATURES_H
1125