LLVM 23.0.0git
Protocol.h
Go to the documentation of this file.
1//===--- Protocol.h - Language Server Protocol Implementation ---*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains structs based on the LSP specification at
10// https://microsoft.github.io/language-server-protocol/specification
11//
12// This is not meant to be a complete implementation, new interfaces are added
13// when they're needed.
14//
15// Each struct has a toJSON and fromJSON function, that converts between
16// the struct and a JSON representation. (See JSON.h)
17//
18// Some structs also have operator<< serialization. This is for debugging and
19// tests, and is not generally machine-readable.
20//
21//===----------------------------------------------------------------------===//
22
23#ifndef LLVM_SUPPORT_LSP_PROTOCOL_H
24#define LLVM_SUPPORT_LSP_PROTOCOL_H
25
27#include "llvm/Support/JSON.h"
31#include <bitset>
32#include <optional>
33#include <string>
34#include <utility>
35
36// This file is using the LSP syntax for identifier names which is different
37// from the LLVM coding standard. To avoid the clang-tidy warnings, we're
38// disabling one check here.
39// NOLINTBEGIN(readability-identifier-naming)
40
41namespace llvm {
42namespace lsp {
43
44enum class ErrorCode {
45 // Defined by JSON RPC.
46 ParseError = -32700,
49 InvalidParams = -32602,
50 InternalError = -32603,
51
54
55 // Defined by the protocol.
58 RequestFailed = -32803,
59};
60
61/// Defines how the host (editor) should sync document changes to the language
62/// server.
64 /// Documents should not be synced at all.
65 None = 0,
66
67 /// Documents are synced by always sending the full content of the document.
68 Full = 1,
69
70 /// Documents are synced by sending the full content on open. After that only
71 /// incremental updates to the document are sent.
73};
74
75//===----------------------------------------------------------------------===//
76// LSPError
77//===----------------------------------------------------------------------===//
78
79/// This class models an LSP error as an llvm::Error.
80class LSPError : public llvm::ErrorInfo<LSPError> {
81public:
82 std::string message;
84 LLVM_ABI_FOR_TEST static char ID;
85
88
89 void log(raw_ostream &os) const override {
90 os << int(code) << ": " << message;
91 }
92 std::error_code convertToErrorCode() const override {
94 }
95};
96
97//===----------------------------------------------------------------------===//
98// URIForFile
99//===----------------------------------------------------------------------===//
100
101/// URI in "file" scheme for a file.
103public:
104 URIForFile() = default;
105
106 /// Try to build a URIForFile from the given URI string.
108
109 /// Try to build a URIForFile from the given absolute file path and optional
110 /// scheme.
111 static llvm::Expected<URIForFile> fromFile(StringRef absoluteFilepath,
112 StringRef scheme = "file");
113
114 /// Returns the absolute path to the file.
115 StringRef file() const { return filePath; }
116
117 /// Returns the original uri of the file.
118 StringRef uri() const { return uriStr; }
119
120 /// Return the scheme of the uri.
121 StringRef scheme() const;
122
123 explicit operator bool() const { return !filePath.empty(); }
124
125 friend bool operator==(const URIForFile &lhs, const URIForFile &rhs) {
126 return lhs.filePath == rhs.filePath;
127 }
128 friend bool operator!=(const URIForFile &lhs, const URIForFile &rhs) {
129 return !(lhs == rhs);
130 }
131 friend bool operator<(const URIForFile &lhs, const URIForFile &rhs) {
132 return lhs.filePath < rhs.filePath;
133 }
134
135 /// Register a supported URI scheme. The protocol supports `file` by default,
136 /// so this is only necessary for any additional schemes that a server wants
137 /// to support.
139
140private:
141 explicit URIForFile(std::string &&filePath, std::string &&uriStr)
142 : filePath(std::move(filePath)), uriStr(uriStr) {}
143
144 std::string filePath;
145 std::string uriStr;
146};
147
148/// Add support for JSON serialization.
149LLVM_ABI_FOR_TEST llvm::json::Value toJSON(const URIForFile &value);
151 URIForFile &result, llvm::json::Path path);
152raw_ostream &operator<<(raw_ostream &os, const URIForFile &value);
153
154//===----------------------------------------------------------------------===//
155// ClientCapabilities
156//===----------------------------------------------------------------------===//
157
159 /// Client supports hierarchical document symbols.
160 /// textDocument.documentSymbol.hierarchicalDocumentSymbolSupport
162
163 /// Client supports CodeAction return value for textDocument/codeAction.
164 /// textDocument.codeAction.codeActionLiteralSupport.
166
167 /// Client supports server-initiated progress via the
168 /// window/workDoneProgress/create method.
169 ///
170 /// window.workDoneProgress
171 bool workDoneProgress = false;
172};
173
174/// Add support for JSON serialization.
176 ClientCapabilities &result,
178
179//===----------------------------------------------------------------------===//
180// ClientInfo
181//===----------------------------------------------------------------------===//
182
184 /// The name of the client as defined by the client.
185 std::string name;
186
187 /// The client's version as defined by the client.
188 std::optional<std::string> version;
189};
190
191/// Add support for JSON serialization.
194
195//===----------------------------------------------------------------------===//
196// InitializeParams
197//===----------------------------------------------------------------------===//
198
199enum class TraceLevel {
200 Off = 0,
203};
204
205/// Add support for JSON serialization.
208
210 /// The capabilities provided by the client (editor or tool).
212
213 /// Information about the client.
214 std::optional<ClientInfo> clientInfo;
215
216 /// The initial trace setting. If omitted trace is disabled ('off').
217 std::optional<TraceLevel> trace;
218
219 /// The root URI of the workspace. Is null if no folder is open.
220 std::optional<std::string> rootUri;
221
222 /// The root path of the workspace. Is null if no folder is open.
223 /// This is deprecated, use rootUri instead, but kept for more compatibility.
224 std::optional<std::string> rootPath;
225};
226
227/// Add support for JSON serialization.
229 InitializeParams &result,
231
232//===----------------------------------------------------------------------===//
233// InitializedParams
234//===----------------------------------------------------------------------===//
235
236struct NoParams {};
238 return true;
239}
241
242//===----------------------------------------------------------------------===//
243// TextDocumentItem
244//===----------------------------------------------------------------------===//
245
247 /// The text document's URI.
249
250 /// The text document's language identifier.
251 std::string languageId;
252
253 /// The content of the opened text document.
254 std::string text;
255
256 /// The version number of this document.
257 int64_t version;
258};
259
260/// Add support for JSON serialization.
262 TextDocumentItem &result,
264
265//===----------------------------------------------------------------------===//
266// TextDocumentIdentifier
267//===----------------------------------------------------------------------===//
268
270 /// The text document's URI.
272};
273
274/// Add support for JSON serialization.
279
280//===----------------------------------------------------------------------===//
281// VersionedTextDocumentIdentifier
282//===----------------------------------------------------------------------===//
283
285 /// The text document's URI.
287 /// The version number of this document.
288 int64_t version;
289};
290
291/// Add support for JSON serialization.
297
298//===----------------------------------------------------------------------===//
299// Position
300//===----------------------------------------------------------------------===//
301
302struct Position {
303 Position(int line = 0, int character = 0)
305
306 /// Construct a position from the given source location.
308 std::pair<unsigned, unsigned> lineAndCol = mgr.getLineAndColumn(loc);
309 line = lineAndCol.first - 1;
310 character = lineAndCol.second - 1;
311 }
312
313 /// Line position in a document (zero-based).
314 int line = 0;
315
316 /// Character offset on a line in a document (zero-based).
317 int character = 0;
318
319 friend bool operator==(const Position &lhs, const Position &rhs) {
320 return std::tie(lhs.line, lhs.character) ==
321 std::tie(rhs.line, rhs.character);
322 }
323 friend bool operator!=(const Position &lhs, const Position &rhs) {
324 return !(lhs == rhs);
325 }
326 friend bool operator<(const Position &lhs, const Position &rhs) {
327 return std::tie(lhs.line, lhs.character) <
328 std::tie(rhs.line, rhs.character);
329 }
330 friend bool operator<=(const Position &lhs, const Position &rhs) {
331 return std::tie(lhs.line, lhs.character) <=
332 std::tie(rhs.line, rhs.character);
333 }
334
335 /// Convert this position into a source location in the main file of the given
336 /// source manager.
338 return mgr.FindLocForLineAndColumn(mgr.getMainFileID(), line + 1,
339 character + 1);
340 }
341};
342
343/// Add support for JSON serialization.
345 Position &result, llvm::json::Path path);
346LLVM_ABI_FOR_TEST llvm::json::Value toJSON(const Position &value);
347raw_ostream &operator<<(raw_ostream &os, const Position &value);
348
349//===----------------------------------------------------------------------===//
350// Range
351//===----------------------------------------------------------------------===//
352
353struct Range {
354 Range() = default;
356 Range(Position loc) : Range(loc, loc) {}
357
358 /// Construct a range from the given source range.
360 : Range(Position(mgr, range.Start), Position(mgr, range.End)) {}
361
362 /// The range's start position.
364
365 /// The range's end position.
367
368 friend bool operator==(const Range &lhs, const Range &rhs) {
369 return std::tie(lhs.start, lhs.end) == std::tie(rhs.start, rhs.end);
370 }
371 friend bool operator!=(const Range &lhs, const Range &rhs) {
372 return !(lhs == rhs);
373 }
374 friend bool operator<(const Range &lhs, const Range &rhs) {
375 return std::tie(lhs.start, lhs.end) < std::tie(rhs.start, rhs.end);
376 }
377
378 bool contains(Position pos) const { return start <= pos && pos < end; }
379 bool contains(Range range) const {
380 return start <= range.start && range.end <= end;
381 }
382
383 /// Convert this range into a source range in the main file of the given
384 /// source manager.
386 SMLoc startLoc = start.getAsSMLoc(mgr);
387 SMLoc endLoc = end.getAsSMLoc(mgr);
388 // Check that the start and end locations are valid.
389 if (!startLoc.isValid() || !endLoc.isValid() ||
390 startLoc.getPointer() > endLoc.getPointer())
391 return SMRange();
392 return SMRange(startLoc, endLoc);
393 }
394};
395
396/// Add support for JSON serialization.
397LLVM_ABI_FOR_TEST bool fromJSON(const llvm::json::Value &value, Range &result,
400raw_ostream &operator<<(raw_ostream &os, const Range &value);
401
402//===----------------------------------------------------------------------===//
403// Location
404//===----------------------------------------------------------------------===//
405
406struct Location {
407 Location() = default;
409
410 /// Construct a Location from the given source range.
413
414 /// The text document's URI.
417
418 friend bool operator==(const Location &lhs, const Location &rhs) {
419 return lhs.uri == rhs.uri && lhs.range == rhs.range;
420 }
421
422 friend bool operator!=(const Location &lhs, const Location &rhs) {
423 return !(lhs == rhs);
424 }
425
426 friend bool operator<(const Location &lhs, const Location &rhs) {
427 return std::tie(lhs.uri, lhs.range) < std::tie(rhs.uri, rhs.range);
428 }
429};
430
431/// Add support for JSON serialization.
433 Location &result, llvm::json::Path path);
434LLVM_ABI_FOR_TEST llvm::json::Value toJSON(const Location &value);
435raw_ostream &operator<<(raw_ostream &os, const Location &value);
436
437//===----------------------------------------------------------------------===//
438// TextDocumentPositionParams
439//===----------------------------------------------------------------------===//
440
442 /// The text document.
444
445 /// The position inside the text document.
447};
448
449/// Add support for JSON serialization.
453
454//===----------------------------------------------------------------------===//
455// ReferenceParams
456//===----------------------------------------------------------------------===//
457
459 /// Include the declaration of the current symbol.
460 bool includeDeclaration = false;
461};
462
463/// Add support for JSON serialization.
465 ReferenceContext &result,
467
471
472/// Add support for JSON serialization.
475
476//===----------------------------------------------------------------------===//
477// DidOpenTextDocumentParams
478//===----------------------------------------------------------------------===//
479
481 /// The document that was opened.
483};
484
485/// Add support for JSON serialization.
489
490//===----------------------------------------------------------------------===//
491// DidCloseTextDocumentParams
492//===----------------------------------------------------------------------===//
493
495 /// The document that was closed.
497};
498
499/// Add support for JSON serialization.
503
504//===----------------------------------------------------------------------===//
505// DidSaveTextDocumentParams
506//===----------------------------------------------------------------------===//
507
509 /// The document that was saved.
511};
512
515
516//===----------------------------------------------------------------------===//
517// DidChangeTextDocumentParams
518//===----------------------------------------------------------------------===//
519
521 /// Try to apply this change to the given contents string.
522 LogicalResult applyTo(std::string &contents) const;
523 /// Try to apply a set of changes to the given contents string.
525 std::string &contents);
526
527 /// The range of the document that changed.
528 std::optional<Range> range;
529
530 /// The length of the range that got replaced.
531 std::optional<int> rangeLength;
532
533 /// The new text of the range/document.
534 std::string text;
535};
536
537/// Add support for JSON serialization.
541
543 /// The document that changed.
545
546 /// The actual content changes.
547 std::vector<TextDocumentContentChangeEvent> contentChanges;
548};
549
550/// Add support for JSON serialization.
554
555//===----------------------------------------------------------------------===//
556// MarkupContent
557//===----------------------------------------------------------------------===//
558
559/// Describes the content type that a client supports in various result literals
560/// like `Hover`.
565raw_ostream &operator<<(raw_ostream &os, MarkupKind kind);
566
571
572/// Add support for JSON serialization.
574
575//===----------------------------------------------------------------------===//
576// Hover
577//===----------------------------------------------------------------------===//
578
579struct Hover {
580 /// Construct a default hover with the given range that uses Markdown content.
582
583 /// The hover's content.
585
586 /// An optional range is a range inside a text document that is used to
587 /// visualize a hover, e.g. by changing the background color.
588 std::optional<Range> range;
589};
590
591/// Add support for JSON serialization.
593
594//===----------------------------------------------------------------------===//
595// SymbolKind
596//===----------------------------------------------------------------------===//
597
626
627//===----------------------------------------------------------------------===//
628// DocumentSymbol
629//===----------------------------------------------------------------------===//
630
631/// Represents programming constructs like variables, classes, interfaces etc.
632/// that appear in a document. Document symbols can be hierarchical and they
633/// have two ranges: one that encloses its definition and one that points to its
634/// most interesting range, e.g. the range of an identifier.
636 DocumentSymbol() = default;
642
643 /// The name of this symbol.
644 std::string name;
645
646 /// More detail for this symbol, e.g the signature of a function.
647 std::string detail;
648
649 /// The kind of this symbol.
651
652 /// The range enclosing this symbol not including leading/trailing whitespace
653 /// but everything else like comments. This information is typically used to
654 /// determine if the clients cursor is inside the symbol to reveal in the
655 /// symbol in the UI.
657
658 /// The range that should be selected and revealed when this symbol is being
659 /// picked, e.g the name of a function. Must be contained by the `range`.
661
662 /// Children of this symbol, e.g. properties of a class.
663 std::vector<DocumentSymbol> children;
664};
665
666/// Add support for JSON serialization.
668
669//===----------------------------------------------------------------------===//
670// DocumentSymbolParams
671//===----------------------------------------------------------------------===//
672
674 // The text document to find symbols in.
676};
677
678/// Add support for JSON serialization.
680 DocumentSymbolParams &result,
682
683//===----------------------------------------------------------------------===//
684// DiagnosticRelatedInformation
685//===----------------------------------------------------------------------===//
686
687/// Represents a related message and source code location for a diagnostic.
688/// This should be used to point to code locations that cause or related to a
689/// diagnostics, e.g. when duplicating a symbol in a scope.
694
695 /// The location of this related diagnostic information.
697 /// The message of this related diagnostic information.
698 std::string message;
699};
700
701/// Add support for JSON serialization.
707
708//===----------------------------------------------------------------------===//
709// Diagnostic
710//===----------------------------------------------------------------------===//
711
713 /// It is up to the client to interpret diagnostics as error, warning, info or
714 /// hint.
716 Error = 1,
720};
721
722enum class DiagnosticTag {
725};
726
727/// Add support for JSON serialization.
731
733 /// The source range where the message applies.
735
736 /// The diagnostic's severity. Can be omitted. If omitted it is up to the
737 /// client to interpret diagnostics as error, warning, info or hint.
739
740 /// A human-readable string describing the source of this diagnostic, e.g.
741 /// 'typescript' or 'super lint'.
742 std::string source;
743
744 /// The diagnostic's message.
745 std::string message;
746
747 /// An array of related diagnostic information, e.g. when symbol-names within
748 /// a scope collide all definitions can be marked via this property.
749 std::optional<std::vector<DiagnosticRelatedInformation>> relatedInformation;
750
751 /// Additional metadata about the diagnostic.
752 std::vector<DiagnosticTag> tags;
753
754 /// The diagnostic's category. Can be omitted.
755 /// An LSP extension that's used to send the name of the category over to the
756 /// client. The category typically describes the compilation stage during
757 /// which the issue was produced, e.g. "Semantic Issue" or "Parse Issue".
758 std::optional<std::string> category;
759};
760
761/// Add support for JSON serialization.
765
766//===----------------------------------------------------------------------===//
767// PublishDiagnosticsParams
768//===----------------------------------------------------------------------===//
769
773
774 /// The URI for which diagnostic information is reported.
776 /// The list of reported diagnostics.
777 std::vector<Diagnostic> diagnostics;
778 /// The version number of the document the diagnostics are published for.
779 int64_t version;
780};
781
782/// Add support for JSON serialization.
784toJSON(const PublishDiagnosticsParams &params);
785
786//===----------------------------------------------------------------------===//
787// TextEdit
788//===----------------------------------------------------------------------===//
789
790struct TextEdit {
791 /// The range of the text document to be manipulated. To insert
792 /// text into a document create a range where start === end.
794
795 /// The string to be inserted. For delete operations use an
796 /// empty string.
797 std::string newText;
798};
799
800inline bool operator==(const TextEdit &lhs, const TextEdit &rhs) {
801 return std::tie(lhs.newText, lhs.range) == std::tie(rhs.newText, rhs.range);
802}
803
805 TextEdit &result, llvm::json::Path path);
806LLVM_ABI_FOR_TEST llvm::json::Value toJSON(const TextEdit &value);
807raw_ostream &operator<<(raw_ostream &os, const TextEdit &value);
808
809//===----------------------------------------------------------------------===//
810// CompletionItemKind
811//===----------------------------------------------------------------------===//
812
813/// The kind of a completion entry.
843 CompletionItemKind &result,
845
847 static_cast<size_t>(CompletionItemKind::Text);
849 static_cast<size_t>(CompletionItemKind::TypeParameter);
850using CompletionItemKindBitset = std::bitset<kCompletionItemKindMax + 1>;
854
857 CompletionItemKindBitset &supportedCompletionItemKinds);
858
859//===----------------------------------------------------------------------===//
860// CompletionItem
861//===----------------------------------------------------------------------===//
862
863/// Defines whether the insert text in a completion item should be interpreted
864/// as plain text or a snippet.
867 /// The primary text to be inserted is treated as a plain string.
869 /// The primary text to be inserted is treated as a snippet.
870 ///
871 /// A snippet can define tab stops and placeholders with `$1`, `$2`
872 /// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end
873 /// of the snippet. Placeholders with equal identifiers are linked, that is
874 /// typing in one will update others too.
875 ///
876 /// See also:
877 /// https//github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
879};
880
882 CompletionItem() = default;
887
888 /// The label of this completion item. By default also the text that is
889 /// inserted when selecting this completion.
890 std::string label;
891
892 /// The kind of this completion item. Based of the kind an icon is chosen by
893 /// the editor.
895
896 /// A human-readable string with additional information about this item, like
897 /// type or symbol information.
898 std::string detail;
899
900 /// A human-readable string that represents a doc-comment.
901 std::optional<MarkupContent> documentation;
902
903 /// A string that should be used when comparing this item with other items.
904 /// When `falsy` the label is used.
905 std::string sortText;
906
907 /// A string that should be used when filtering a set of completion items.
908 /// When `falsy` the label is used.
909 std::string filterText;
910
911 /// A string that should be inserted to a document when selecting this
912 /// completion. When `falsy` the label is used.
913 std::string insertText;
914
915 /// The format of the insert text. The format applies to both the `insertText`
916 /// property and the `newText` property of a provided `textEdit`.
918
919 /// An edit which is applied to a document when selecting this completion.
920 /// When an edit is provided `insertText` is ignored.
921 ///
922 /// Note: The range of the edit must be a single line range and it must
923 /// contain the position at which completion has been requested.
924 std::optional<TextEdit> textEdit;
925
926 /// An optional array of additional text edits that are applied when selecting
927 /// this completion. Edits must not overlap with the main edit nor with
928 /// themselves.
929 std::vector<TextEdit> additionalTextEdits;
930
931 /// Indicates if this item is deprecated.
932 bool deprecated = false;
933};
934
935/// Add support for JSON serialization.
938bool operator<(const CompletionItem &lhs, const CompletionItem &rhs);
939
940//===----------------------------------------------------------------------===//
941// CompletionList
942//===----------------------------------------------------------------------===//
943
944/// Represents a collection of completion items to be presented in the editor.
946 /// The list is not complete. Further typing should result in recomputing the
947 /// list.
948 bool isIncomplete = false;
949
950 /// The completion items.
951 std::vector<CompletionItem> items;
952};
953
954/// Add support for JSON serialization.
956
957//===----------------------------------------------------------------------===//
958// CompletionContext
959//===----------------------------------------------------------------------===//
960
962 /// Completion was triggered by typing an identifier (24x7 code
963 /// complete), manual invocation (e.g Ctrl+Space) or via API.
965
966 /// Completion was triggered by a trigger character specified by
967 /// the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
969
970 /// Completion was re-triggered as the current completion list is incomplete.
972};
973
975 /// How the completion was triggered.
977
978 /// The trigger character (a single character) that has trigger code complete.
979 /// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
980 std::string triggerCharacter;
981};
982
983/// Add support for JSON serialization.
985 CompletionContext &result,
987
988//===----------------------------------------------------------------------===//
989// CompletionParams
990//===----------------------------------------------------------------------===//
991
995
996/// Add support for JSON serialization.
998 CompletionParams &result,
1000
1001//===----------------------------------------------------------------------===//
1002// ParameterInformation
1003//===----------------------------------------------------------------------===//
1004
1005/// A single parameter of a particular signature.
1007 /// The label of this parameter. Ignored when labelOffsets is set.
1008 std::string labelString;
1009
1010 /// Inclusive start and exclusive end offsets withing the containing signature
1011 /// label.
1012 std::optional<std::pair<unsigned, unsigned>> labelOffsets;
1013
1014 /// The documentation of this parameter. Optional.
1015 std::string documentation;
1016};
1017
1018/// Add support for JSON serialization.
1020
1021//===----------------------------------------------------------------------===//
1022// SignatureInformation
1023//===----------------------------------------------------------------------===//
1024
1025/// Represents the signature of something callable.
1027 /// The label of this signature. Mandatory.
1028 std::string label;
1029
1030 /// The documentation of this signature. Optional.
1031 std::string documentation;
1032
1033 /// The parameters of this signature.
1034 std::vector<ParameterInformation> parameters;
1035};
1036
1037/// Add support for JSON serialization.
1040
1041//===----------------------------------------------------------------------===//
1042// SignatureHelp
1043//===----------------------------------------------------------------------===//
1044
1045/// Represents the signature of a callable.
1047 /// The resulting signatures.
1048 std::vector<SignatureInformation> signatures;
1049
1050 /// The active signature.
1052
1053 /// The active parameter of the active signature.
1055};
1056
1057/// Add support for JSON serialization.
1059
1060//===----------------------------------------------------------------------===//
1061// DocumentLinkParams
1062//===----------------------------------------------------------------------===//
1063
1064/// Parameters for the document link request.
1066 /// The document to provide document links for.
1068};
1069
1070/// Add support for JSON serialization.
1072 DocumentLinkParams &result,
1074
1075//===----------------------------------------------------------------------===//
1076// DocumentLink
1077//===----------------------------------------------------------------------===//
1078
1079/// A range in a text document that links to an internal or external resource,
1080/// like another text document or a web site.
1082 DocumentLink() = default;
1085
1086 /// The range this link applies to.
1088
1089 /// The uri this link points to. If missing a resolve request is sent later.
1091
1092 // TODO: The following optional fields defined by the language server protocol
1093 // are unsupported:
1094 //
1095 // data?: any - A data entry field that is preserved on a document link
1096 // between a DocumentLinkRequest and a
1097 // DocumentLinkResolveRequest.
1098
1099 friend bool operator==(const DocumentLink &lhs, const DocumentLink &rhs) {
1100 return lhs.range == rhs.range && lhs.target == rhs.target;
1101 }
1102
1103 friend bool operator!=(const DocumentLink &lhs, const DocumentLink &rhs) {
1104 return !(lhs == rhs);
1105 }
1106};
1107
1108/// Add support for JSON serialization.
1109LLVM_ABI_FOR_TEST llvm::json::Value toJSON(const DocumentLink &value);
1110
1111//===----------------------------------------------------------------------===//
1112// InlayHintsParams
1113//===----------------------------------------------------------------------===//
1114
1115/// A parameter literal used in inlay hint requests.
1117 /// The text document.
1119
1120 /// The visible document range for which inlay hints should be computed.
1122};
1123
1124/// Add support for JSON serialization.
1126 InlayHintsParams &result,
1128
1129//===----------------------------------------------------------------------===//
1130// InlayHintKind
1131//===----------------------------------------------------------------------===//
1132
1133/// Inlay hint kinds.
1134enum class InlayHintKind {
1135 /// An inlay hint that for a type annotation.
1136 ///
1137 /// An example of a type hint is a hint in this position:
1138 /// auto var ^ = expr;
1139 /// which shows the deduced type of the variable.
1140 Type = 1,
1141
1142 /// An inlay hint that is for a parameter.
1143 ///
1144 /// An example of a parameter hint is a hint in this position:
1145 /// func(^arg);
1146 /// which shows the name of the corresponding parameter.
1148};
1149
1150//===----------------------------------------------------------------------===//
1151// InlayHint
1152//===----------------------------------------------------------------------===//
1153
1154/// Inlay hint information.
1157
1158 /// The position of this hint.
1160
1161 /// The label of this hint. A human readable string or an array of
1162 /// InlayHintLabelPart label parts.
1163 ///
1164 /// *Note* that neither the string nor the label part can be empty.
1165 std::string label;
1166
1167 /// The kind of this hint. Can be omitted in which case the client should fall
1168 /// back to a reasonable default.
1170
1171 /// Render padding before the hint.
1172 ///
1173 /// Note: Padding should use the editor's background color, not the
1174 /// background color of the hint itself. That means padding can be used
1175 /// to visually align/separate an inlay hint.
1176 bool paddingLeft = false;
1177
1178 /// Render padding after the hint.
1179 ///
1180 /// Note: Padding should use the editor's background color, not the
1181 /// background color of the hint itself. That means padding can be used
1182 /// to visually align/separate an inlay hint.
1183 bool paddingRight = false;
1184};
1185
1186/// Add support for JSON serialization.
1188bool operator==(const InlayHint &lhs, const InlayHint &rhs);
1189bool operator<(const InlayHint &lhs, const InlayHint &rhs);
1191
1192//===----------------------------------------------------------------------===//
1193// CodeActionContext
1194//===----------------------------------------------------------------------===//
1195
1197 /// An array of diagnostics known on the client side overlapping the range
1198 /// provided to the `textDocument/codeAction` request. They are provided so
1199 /// that the server knows which errors are currently presented to the user for
1200 /// the given range. There is no guarantee that these accurately reflect the
1201 /// error state of the resource. The primary parameter to compute code actions
1202 /// is the provided range.
1203 std::vector<Diagnostic> diagnostics;
1204
1205 /// Requested kind of actions to return.
1206 ///
1207 /// Actions not of this kind are filtered out by the client before being
1208 /// shown. So servers can omit computing them.
1209 std::vector<std::string> only;
1210};
1211
1212/// Add support for JSON serialization.
1214 CodeActionContext &result,
1216
1217//===----------------------------------------------------------------------===//
1218// CodeActionParams
1219//===----------------------------------------------------------------------===//
1220
1222 /// The document in which the command was invoked.
1224
1225 /// The range for which the command was invoked.
1227
1228 /// Context carrying additional information.
1230};
1231
1232/// Add support for JSON serialization.
1234 CodeActionParams &result,
1236
1237//===----------------------------------------------------------------------===//
1238// WorkspaceEdit
1239//===----------------------------------------------------------------------===//
1240
1242 /// Holds changes to existing resources.
1243 std::map<std::string, std::vector<TextEdit>> changes;
1244
1245 /// Note: "documentChanges" is not currently used because currently there is
1246 /// no support for versioned edits.
1247};
1248
1249/// Add support for JSON serialization.
1253
1254//===----------------------------------------------------------------------===//
1255// CodeAction
1256//===----------------------------------------------------------------------===//
1257
1258/// A code action represents a change that can be performed in code, e.g. to fix
1259/// a problem or to refactor code.
1260///
1261/// A CodeAction must set either `edit` and/or a `command`. If both are
1262/// supplied, the `edit` is applied first, then the `command` is executed.
1264 /// A short, human-readable, title for this code action.
1265 std::string title;
1266
1267 /// The kind of the code action.
1268 /// Used to filter code actions.
1269 std::optional<std::string> kind;
1273
1274 /// The diagnostics that this code action resolves.
1275 std::optional<std::vector<Diagnostic>> diagnostics;
1276
1277 /// Marks this as a preferred action. Preferred actions are used by the
1278 /// `auto fix` command and can be targeted by keybindings.
1279 /// A quick fix should be marked preferred if it properly addresses the
1280 /// underlying error. A refactoring should be marked preferred if it is the
1281 /// most reasonable choice of actions to take.
1282 bool isPreferred = false;
1283
1284 /// The workspace edit this code action performs.
1285 std::optional<WorkspaceEdit> edit;
1286};
1287
1288/// Add support for JSON serialization.
1290
1291//===----------------------------------------------------------------------===//
1292// ShowMessageParams
1293//===----------------------------------------------------------------------===//
1294
1295enum class MessageType { Error = 1, Warning = 2, Info = 3, Log = 4, Debug = 5 };
1296
1298 /// A short title like 'Retry', 'Open Log' etc.
1299 std::string title;
1300};
1301
1303 ShowMessageParams(MessageType Type, std::string Message)
1304 : type(Type), message(Message) {}
1306 /// The actual message.
1307 std::string message;
1308 /// The message action items to present.
1309 std::optional<std::vector<MessageActionItem>> actions;
1310};
1311
1312/// Add support for JSON serialization.
1314
1315/// Add support for JSON serialization.
1317
1318} // namespace lsp
1319} // namespace llvm
1320
1321namespace llvm {
1322template <> struct format_provider<llvm::lsp::Position> {
1323 static void format(const llvm::lsp::Position &pos, raw_ostream &os,
1324 StringRef style) {
1325 assert(style.empty() && "style modifiers for this type are not supported");
1326 os << pos;
1327 }
1328};
1329} // namespace llvm
1330
1331#endif
1332
1333// NOLINTEND(readability-identifier-naming)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI_FOR_TEST
Definition Compiler.h:218
This file supports working with JSON data.
lazy value info
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Base class for user error types.
Definition Error.h:354
Tagged union holding either a T or a Error.
Definition Error.h:485
Represents a location in source code.
Definition SMLoc.h:22
constexpr const char * getPointer() const
Definition SMLoc.h:33
constexpr bool isValid() const
Definition SMLoc.h:28
Represents a range in source code.
Definition SMLoc.h:47
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition SourceMgr.h:37
unsigned getMainFileID() const
Definition SourceMgr.h:148
LLVM_ABI std::pair< unsigned, unsigned > getLineAndColumn(SMLoc Loc, unsigned BufferID=0) const
Find the line and column number for the specified location in the specified file.
LLVM_ABI SMLoc FindLocForLineAndColumn(unsigned BufferID, unsigned LineNo, unsigned ColNo)
Given a line and column number in a mapped buffer, turn it into an SMLoc.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition StringRef.h:882
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:140
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
A "cursor" marking a position within a Value.
Definition JSON.h:665
A Value is an JSON value of unknown type.
Definition JSON.h:291
static LLVM_ABI_FOR_TEST char ID
Definition Protocol.h:84
void log(raw_ostream &os) const override
Print an error message to an output stream.
Definition Protocol.h:89
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition Protocol.h:92
std::string message
Definition Protocol.h:82
LSPError(std::string message, ErrorCode code)
Definition Protocol.h:86
URI in "file" scheme for a file.
Definition Protocol.h:102
friend bool operator==(const URIForFile &lhs, const URIForFile &rhs)
Definition Protocol.h:125
static void registerSupportedScheme(StringRef scheme)
Register a supported URI scheme.
Definition Protocol.cpp:234
static llvm::Expected< URIForFile > fromFile(StringRef absoluteFilepath, StringRef scheme="file")
Try to build a URIForFile from the given absolute file path and optional scheme.
Definition Protocol.cpp:223
static llvm::Expected< URIForFile > fromURI(StringRef uri)
Try to build a URIForFile from the given URI string.
Definition Protocol.cpp:216
StringRef scheme() const
Return the scheme of the uri.
Definition Protocol.cpp:232
friend bool operator!=(const URIForFile &lhs, const URIForFile &rhs)
Definition Protocol.h:128
StringRef uri() const
Returns the original uri of the file.
Definition Protocol.h:118
friend bool operator<(const URIForFile &lhs, const URIForFile &rhs)
Definition Protocol.h:131
StringRef file() const
Returns the absolute path to the file.
Definition Protocol.h:115
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
constexpr auto kCompletionItemKindMin
Definition Protocol.h:846
MarkupKind
Describes the content type that a client supports in various result literals like Hover.
Definition Protocol.h:561
LLVM_ABI_FOR_TEST llvm::json::Value toJSON(const URIForFile &value)
Add support for JSON serialization.
Definition Protocol.cpp:253
CompletionTriggerKind
Definition Protocol.h:961
@ Invoked
Completion was triggered by typing an identifier (24x7 code complete), manual invocation (e....
Definition Protocol.h:964
@ TriggerTriggerForIncompleteCompletions
Completion was re-triggered as the current completion list is incomplete.
Definition Protocol.h:971
@ TriggerCharacter
Completion was triggered by a trigger character specified by the triggerCharacters properties of the ...
Definition Protocol.h:968
TextDocumentSyncKind
Defines how the host (editor) should sync document changes to the language server.
Definition Protocol.h:63
@ Incremental
Documents are synced by sending the full content on open.
Definition Protocol.h:72
@ None
Documents should not be synced at all.
Definition Protocol.h:65
@ Full
Documents are synced by always sending the full content of the document.
Definition Protocol.h:68
bool operator<(const CompletionItem &lhs, const CompletionItem &rhs)
Definition Protocol.cpp:829
bool operator==(const TextEdit &lhs, const TextEdit &rhs)
Definition Protocol.h:800
NoParams InitializedParams
Definition Protocol.h:240
raw_ostream & operator<<(raw_ostream &os, const URIForFile &value)
Definition Protocol.cpp:257
CompletionItemKind adjustKindToCapability(CompletionItemKind kind, CompletionItemKindBitset &supportedCompletionItemKinds)
Definition Protocol.cpp:756
InlayHintKind
Inlay hint kinds.
Definition Protocol.h:1134
@ Parameter
An inlay hint that is for a parameter.
Definition Protocol.h:1147
@ Type
An inlay hint that for a type annotation.
Definition Protocol.h:1140
DiagnosticSeverity
Definition Protocol.h:712
@ Undetermined
It is up to the client to interpret diagnostics as error, warning, info or hint.
Definition Protocol.h:715
InsertTextFormat
Defines whether the insert text in a completion item should be interpreted as plain text or a snippet...
Definition Protocol.h:865
std::bitset< kCompletionItemKindMax+1 > CompletionItemKindBitset
Definition Protocol.h:850
constexpr auto kCompletionItemKindMax
Definition Protocol.h:848
CompletionItemKind
The kind of a completion entry.
Definition Protocol.h:814
LLVM_ABI_FOR_TEST bool fromJSON(const llvm::json::Value &value, URIForFile &result, llvm::json::Path path)
Definition Protocol.cpp:238
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870
This class represents an efficient way to signal success or failure.
static void format(const llvm::lsp::Position &pos, raw_ostream &os, StringRef style)
Definition Protocol.h:1323
bool hierarchicalDocumentSymbol
Client supports hierarchical document symbols.
Definition Protocol.h:161
bool workDoneProgress
Client supports server-initiated progress via the window/workDoneProgress/create method.
Definition Protocol.h:171
bool codeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
Definition Protocol.h:165
std::string name
The name of the client as defined by the client.
Definition Protocol.h:185
std::optional< std::string > version
The client's version as defined by the client.
Definition Protocol.h:188
std::vector< Diagnostic > diagnostics
An array of diagnostics known on the client side overlapping the range provided to the textDocument/c...
Definition Protocol.h:1203
std::vector< std::string > only
Requested kind of actions to return.
Definition Protocol.h:1209
CodeActionContext context
Context carrying additional information.
Definition Protocol.h:1229
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Definition Protocol.h:1223
Range range
The range for which the command was invoked.
Definition Protocol.h:1226
A code action represents a change that can be performed in code, e.g.
Definition Protocol.h:1263
std::optional< std::string > kind
The kind of the code action.
Definition Protocol.h:1269
static const llvm::StringLiteral kRefactor
Definition Protocol.h:1271
static const llvm::StringLiteral kInfo
Definition Protocol.h:1272
bool isPreferred
Marks this as a preferred action.
Definition Protocol.h:1282
static const llvm::StringLiteral kQuickFix
Definition Protocol.h:1270
std::optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Definition Protocol.h:1275
std::optional< WorkspaceEdit > edit
The workspace edit this code action performs.
Definition Protocol.h:1285
std::string title
A short, human-readable, title for this code action.
Definition Protocol.h:1265
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
Definition Protocol.h:980
CompletionTriggerKind triggerKind
How the completion was triggered.
Definition Protocol.h:976
CompletionItem(const Twine &label, CompletionItemKind kind, StringRef sortText="")
Definition Protocol.h:883
std::string filterText
A string that should be used when filtering a set of completion items.
Definition Protocol.h:909
std::string insertText
A string that should be inserted to a document when selecting this completion.
Definition Protocol.h:913
bool deprecated
Indicates if this item is deprecated.
Definition Protocol.h:932
std::optional< TextEdit > textEdit
An edit which is applied to a document when selecting this completion.
Definition Protocol.h:924
std::vector< TextEdit > additionalTextEdits
An optional array of additional text edits that are applied when selecting this completion.
Definition Protocol.h:929
CompletionItemKind kind
The kind of this completion item.
Definition Protocol.h:894
InsertTextFormat insertTextFormat
The format of the insert text.
Definition Protocol.h:917
std::string label
The label of this completion item.
Definition Protocol.h:890
std::optional< MarkupContent > documentation
A human-readable string that represents a doc-comment.
Definition Protocol.h:901
std::string sortText
A string that should be used when comparing this item with other items.
Definition Protocol.h:905
Represents a collection of completion items to be presented in the editor.
Definition Protocol.h:945
bool isIncomplete
The list is not complete.
Definition Protocol.h:948
std::vector< CompletionItem > items
The completion items.
Definition Protocol.h:951
CompletionContext context
Definition Protocol.h:993
Represents a related message and source code location for a diagnostic.
Definition Protocol.h:690
DiagnosticRelatedInformation(Location location, std::string message)
Definition Protocol.h:692
std::string message
The message of this related diagnostic information.
Definition Protocol.h:698
Location location
The location of this related diagnostic information.
Definition Protocol.h:696
std::vector< DiagnosticTag > tags
Additional metadata about the diagnostic.
Definition Protocol.h:752
std::string message
The diagnostic's message.
Definition Protocol.h:745
Range range
The source range where the message applies.
Definition Protocol.h:734
std::optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
An array of related diagnostic information, e.g.
Definition Protocol.h:749
std::string source
A human-readable string describing the source of this diagnostic, e.g.
Definition Protocol.h:742
DiagnosticSeverity severity
The diagnostic's severity.
Definition Protocol.h:738
std::optional< std::string > category
The diagnostic's category.
Definition Protocol.h:758
VersionedTextDocumentIdentifier textDocument
The document that changed.
Definition Protocol.h:544
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
Definition Protocol.h:547
TextDocumentIdentifier textDocument
The document that was closed.
Definition Protocol.h:496
TextDocumentItem textDocument
The document that was opened.
Definition Protocol.h:482
TextDocumentIdentifier textDocument
The document that was saved.
Definition Protocol.h:510
Parameters for the document link request.
Definition Protocol.h:1065
TextDocumentIdentifier textDocument
The document to provide document links for.
Definition Protocol.h:1067
TextDocumentIdentifier textDocument
Definition Protocol.h:675
Represents programming constructs like variables, classes, interfaces etc.
Definition Protocol.h:635
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
Definition Protocol.h:656
SymbolKind kind
The kind of this symbol.
Definition Protocol.h:650
DocumentSymbol(const Twine &name, SymbolKind kind, Range range, Range selectionRange)
Definition Protocol.h:638
std::string name
The name of this symbol.
Definition Protocol.h:644
DocumentSymbol(DocumentSymbol &&)=default
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
Definition Protocol.h:663
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition Protocol.h:660
std::optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover,...
Definition Protocol.h:588
Hover(Range range)
Construct a default hover with the given range that uses Markdown content.
Definition Protocol.h:581
MarkupContent contents
The hover's content.
Definition Protocol.h:584
std::optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
Definition Protocol.h:217
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool).
Definition Protocol.h:211
std::optional< ClientInfo > clientInfo
Information about the client.
Definition Protocol.h:214
std::optional< std::string > rootUri
The root URI of the workspace. Is null if no folder is open.
Definition Protocol.h:220
std::optional< std::string > rootPath
The root path of the workspace.
Definition Protocol.h:224
Inlay hint information.
Definition Protocol.h:1155
bool paddingRight
Render padding after the hint.
Definition Protocol.h:1183
InlayHint(InlayHintKind kind, Position pos)
Definition Protocol.h:1156
bool paddingLeft
Render padding before the hint.
Definition Protocol.h:1176
InlayHintKind kind
The kind of this hint.
Definition Protocol.h:1169
std::string label
The label of this hint.
Definition Protocol.h:1165
Position position
The position of this hint.
Definition Protocol.h:1159
A parameter literal used in inlay hint requests.
Definition Protocol.h:1116
Range range
The visible document range for which inlay hints should be computed.
Definition Protocol.h:1121
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1118
Location(const URIForFile &uri, Range range)
Definition Protocol.h:408
friend bool operator<(const Location &lhs, const Location &rhs)
Definition Protocol.h:426
friend bool operator!=(const Location &lhs, const Location &rhs)
Definition Protocol.h:422
URIForFile uri
The text document's URI.
Definition Protocol.h:415
Location(const URIForFile &uri, llvm::SourceMgr &mgr, SMRange range)
Construct a Location from the given source range.
Definition Protocol.h:411
friend bool operator==(const Location &lhs, const Location &rhs)
Definition Protocol.h:418
std::string title
A short title like 'Retry', 'Open Log' etc.
Definition Protocol.h:1299
A single parameter of a particular signature.
Definition Protocol.h:1006
std::optional< std::pair< unsigned, unsigned > > labelOffsets
Inclusive start and exclusive end offsets withing the containing signature label.
Definition Protocol.h:1012
std::string documentation
The documentation of this parameter. Optional.
Definition Protocol.h:1015
std::string labelString
The label of this parameter. Ignored when labelOffsets is set.
Definition Protocol.h:1008
Position(llvm::SourceMgr &mgr, SMLoc loc)
Construct a position from the given source location.
Definition Protocol.h:307
int line
Line position in a document (zero-based).
Definition Protocol.h:314
SMLoc getAsSMLoc(llvm::SourceMgr &mgr) const
Convert this position into a source location in the main file of the given source manager.
Definition Protocol.h:337
friend bool operator==(const Position &lhs, const Position &rhs)
Definition Protocol.h:319
Position(int line=0, int character=0)
Definition Protocol.h:303
int character
Character offset on a line in a document (zero-based).
Definition Protocol.h:317
friend bool operator<(const Position &lhs, const Position &rhs)
Definition Protocol.h:326
friend bool operator<=(const Position &lhs, const Position &rhs)
Definition Protocol.h:330
friend bool operator!=(const Position &lhs, const Position &rhs)
Definition Protocol.h:323
URIForFile uri
The URI for which diagnostic information is reported.
Definition Protocol.h:775
PublishDiagnosticsParams(URIForFile uri, int64_t version)
Definition Protocol.h:771
int64_t version
The version number of the document the diagnostics are published for.
Definition Protocol.h:779
std::vector< Diagnostic > diagnostics
The list of reported diagnostics.
Definition Protocol.h:777
bool contains(Position pos) const
Definition Protocol.h:378
friend bool operator!=(const Range &lhs, const Range &rhs)
Definition Protocol.h:371
SMRange getAsSMRange(llvm::SourceMgr &mgr) const
Convert this range into a source range in the main file of the given source manager.
Definition Protocol.h:385
friend bool operator<(const Range &lhs, const Range &rhs)
Definition Protocol.h:374
bool contains(Range range) const
Definition Protocol.h:379
Position end
The range's end position.
Definition Protocol.h:366
Position start
The range's start position.
Definition Protocol.h:363
Range(llvm::SourceMgr &mgr, SMRange range)
Construct a range from the given source range.
Definition Protocol.h:359
Range(Position start, Position end)
Definition Protocol.h:355
friend bool operator==(const Range &lhs, const Range &rhs)
Definition Protocol.h:368
Range(Position loc)
Definition Protocol.h:356
bool includeDeclaration
Include the declaration of the current symbol.
Definition Protocol.h:460
ReferenceContext context
Definition Protocol.h:469
ShowMessageParams(MessageType Type, std::string Message)
Definition Protocol.h:1303
std::string message
The actual message.
Definition Protocol.h:1307
std::optional< std::vector< MessageActionItem > > actions
The message action items to present.
Definition Protocol.h:1309
Represents the signature of a callable.
Definition Protocol.h:1046
std::vector< SignatureInformation > signatures
The resulting signatures.
Definition Protocol.h:1048
int activeParameter
The active parameter of the active signature.
Definition Protocol.h:1054
int activeSignature
The active signature.
Definition Protocol.h:1051
Represents the signature of something callable.
Definition Protocol.h:1026
std::vector< ParameterInformation > parameters
The parameters of this signature.
Definition Protocol.h:1034
std::string label
The label of this signature. Mandatory.
Definition Protocol.h:1028
std::string documentation
The documentation of this signature. Optional.
Definition Protocol.h:1031
std::optional< Range > range
The range of the document that changed.
Definition Protocol.h:528
std::optional< int > rangeLength
The length of the range that got replaced.
Definition Protocol.h:531
LogicalResult applyTo(std::string &contents) const
Try to apply this change to the given contents string.
Definition Protocol.cpp:522
std::string text
The new text of the range/document.
Definition Protocol.h:534
URIForFile uri
The text document's URI.
Definition Protocol.h:271
std::string languageId
The text document's language identifier.
Definition Protocol.h:251
URIForFile uri
The text document's URI.
Definition Protocol.h:248
int64_t version
The version number of this document.
Definition Protocol.h:257
std::string text
The content of the opened text document.
Definition Protocol.h:254
Position position
The position inside the text document.
Definition Protocol.h:446
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:443
Range range
The range of the text document to be manipulated.
Definition Protocol.h:793
std::string newText
The string to be inserted.
Definition Protocol.h:797
URIForFile uri
The text document's URI.
Definition Protocol.h:286
int64_t version
The version number of this document.
Definition Protocol.h:288
std::map< std::string, std::vector< TextEdit > > changes
Holds changes to existing resources.
Definition Protocol.h:1243