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 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.
112 fromFile(StringRef absoluteFilepath, 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 LLVM_ABI 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 llvm::json::Value toJSON(const URIForFile &value);
150LLVM_ABI bool fromJSON(const llvm::json::Value &value, URIForFile &result,
151 llvm::json::Path path);
152LLVM_ABI raw_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.
175LLVM_ABI bool fromJSON(const llvm::json::Value &value,
177
178//===----------------------------------------------------------------------===//
179// ClientInfo
180//===----------------------------------------------------------------------===//
181
183 /// The name of the client as defined by the client.
184 std::string name;
185
186 /// The client's version as defined by the client.
187 std::optional<std::string> version;
188};
189
190/// Add support for JSON serialization.
191LLVM_ABI bool fromJSON(const llvm::json::Value &value, ClientInfo &result,
193
194//===----------------------------------------------------------------------===//
195// InitializeParams
196//===----------------------------------------------------------------------===//
197
198enum class TraceLevel {
199 Off = 0,
202};
203
204/// Add support for JSON serialization.
205LLVM_ABI bool fromJSON(const llvm::json::Value &value, TraceLevel &result,
207
209 /// The capabilities provided by the client (editor or tool).
211
212 /// Information about the client.
213 std::optional<ClientInfo> clientInfo;
214
215 /// The initial trace setting. If omitted trace is disabled ('off').
216 std::optional<TraceLevel> trace;
217
218 /// The root URI of the workspace. Is null if no folder is open.
219 std::optional<std::string> rootUri;
220
221 /// The root path of the workspace. Is null if no folder is open.
222 /// This is deprecated, use rootUri instead, but kept for more compatibility.
223 std::optional<std::string> rootPath;
224};
225
226/// Add support for JSON serialization.
227LLVM_ABI bool fromJSON(const llvm::json::Value &value, InitializeParams &result,
229
230//===----------------------------------------------------------------------===//
231// InitializedParams
232//===----------------------------------------------------------------------===//
233
234struct NoParams {};
236 return true;
237}
239
240//===----------------------------------------------------------------------===//
241// TextDocumentItem
242//===----------------------------------------------------------------------===//
243
245 /// The text document's URI.
247
248 /// The text document's language identifier.
249 std::string languageId;
250
251 /// The content of the opened text document.
252 std::string text;
253
254 /// The version number of this document.
255 int64_t version;
256};
257
258/// Add support for JSON serialization.
259LLVM_ABI bool fromJSON(const llvm::json::Value &value, TextDocumentItem &result,
261
262//===----------------------------------------------------------------------===//
263// TextDocumentIdentifier
264//===----------------------------------------------------------------------===//
265
267 /// The text document's URI.
269};
270
271/// Add support for JSON serialization.
273LLVM_ABI bool fromJSON(const llvm::json::Value &value,
275
276//===----------------------------------------------------------------------===//
277// VersionedTextDocumentIdentifier
278//===----------------------------------------------------------------------===//
279
281 /// The text document's URI.
283 /// The version number of this document.
284 int64_t version;
285};
286
287/// Add support for JSON serialization.
289LLVM_ABI bool fromJSON(const llvm::json::Value &value,
292
293//===----------------------------------------------------------------------===//
294// Position
295//===----------------------------------------------------------------------===//
296
297struct Position {
298 Position(int line = 0, int character = 0)
300
301 /// Construct a position from the given source location.
303 std::pair<unsigned, unsigned> lineAndCol = mgr.getLineAndColumn(loc);
304 line = lineAndCol.first - 1;
305 character = lineAndCol.second - 1;
306 }
307
308 /// Line position in a document (zero-based).
309 int line = 0;
310
311 /// Character offset on a line in a document (zero-based).
312 int character = 0;
313
314 friend bool operator==(const Position &lhs, const Position &rhs) {
315 return std::tie(lhs.line, lhs.character) ==
316 std::tie(rhs.line, rhs.character);
317 }
318 friend bool operator!=(const Position &lhs, const Position &rhs) {
319 return !(lhs == rhs);
320 }
321 friend bool operator<(const Position &lhs, const Position &rhs) {
322 return std::tie(lhs.line, lhs.character) <
323 std::tie(rhs.line, rhs.character);
324 }
325 friend bool operator<=(const Position &lhs, const Position &rhs) {
326 return std::tie(lhs.line, lhs.character) <=
327 std::tie(rhs.line, rhs.character);
328 }
329
330 /// Convert this position into a source location in the main file of the given
331 /// source manager.
333 return mgr.FindLocForLineAndColumn(mgr.getMainFileID(), line + 1,
334 character + 1);
335 }
336};
337
338/// Add support for JSON serialization.
339LLVM_ABI bool fromJSON(const llvm::json::Value &value, Position &result,
341LLVM_ABI llvm::json::Value toJSON(const Position &value);
342LLVM_ABI raw_ostream &operator<<(raw_ostream &os, const Position &value);
343
344//===----------------------------------------------------------------------===//
345// Range
346//===----------------------------------------------------------------------===//
347
348struct Range {
349 Range() = default;
351 Range(Position loc) : Range(loc, loc) {}
352
353 /// Construct a range from the given source range.
355 : Range(Position(mgr, range.Start), Position(mgr, range.End)) {}
356
357 /// The range's start position.
359
360 /// The range's end position.
362
363 friend bool operator==(const Range &lhs, const Range &rhs) {
364 return std::tie(lhs.start, lhs.end) == std::tie(rhs.start, rhs.end);
365 }
366 friend bool operator!=(const Range &lhs, const Range &rhs) {
367 return !(lhs == rhs);
368 }
369 friend bool operator<(const Range &lhs, const Range &rhs) {
370 return std::tie(lhs.start, lhs.end) < std::tie(rhs.start, rhs.end);
371 }
372
373 bool contains(Position pos) const { return start <= pos && pos < end; }
374 bool contains(Range range) const {
375 return start <= range.start && range.end <= end;
376 }
377
378 /// Convert this range into a source range in the main file of the given
379 /// source manager.
381 SMLoc startLoc = start.getAsSMLoc(mgr);
382 SMLoc endLoc = end.getAsSMLoc(mgr);
383 // Check that the start and end locations are valid.
384 if (!startLoc.isValid() || !endLoc.isValid() ||
385 startLoc.getPointer() > endLoc.getPointer())
386 return SMRange();
387 return SMRange(startLoc, endLoc);
388 }
389};
390
391/// Add support for JSON serialization.
392LLVM_ABI bool fromJSON(const llvm::json::Value &value, Range &result,
396
397//===----------------------------------------------------------------------===//
398// Location
399//===----------------------------------------------------------------------===//
400
401struct Location {
402 Location() = default;
404
405 /// Construct a Location from the given source range.
408
409 /// The text document's URI.
412
413 friend bool operator==(const Location &lhs, const Location &rhs) {
414 return lhs.uri == rhs.uri && lhs.range == rhs.range;
415 }
416
417 friend bool operator!=(const Location &lhs, const Location &rhs) {
418 return !(lhs == rhs);
419 }
420
421 friend bool operator<(const Location &lhs, const Location &rhs) {
422 return std::tie(lhs.uri, lhs.range) < std::tie(rhs.uri, rhs.range);
423 }
424};
425
426/// Add support for JSON serialization.
427LLVM_ABI bool fromJSON(const llvm::json::Value &value, Location &result,
429LLVM_ABI llvm::json::Value toJSON(const Location &value);
430LLVM_ABI raw_ostream &operator<<(raw_ostream &os, const Location &value);
431
432//===----------------------------------------------------------------------===//
433// TextDocumentPositionParams
434//===----------------------------------------------------------------------===//
435
437 /// The text document.
439
440 /// The position inside the text document.
442};
443
444/// Add support for JSON serialization.
445LLVM_ABI bool fromJSON(const llvm::json::Value &value,
448
449//===----------------------------------------------------------------------===//
450// ReferenceParams
451//===----------------------------------------------------------------------===//
452
454 /// Include the declaration of the current symbol.
455 bool includeDeclaration = false;
456};
457
458/// Add support for JSON serialization.
459LLVM_ABI bool fromJSON(const llvm::json::Value &value, ReferenceContext &result,
461
465
466/// Add support for JSON serialization.
467LLVM_ABI bool fromJSON(const llvm::json::Value &value, ReferenceParams &result,
469
470//===----------------------------------------------------------------------===//
471// DidOpenTextDocumentParams
472//===----------------------------------------------------------------------===//
473
475 /// The document that was opened.
477};
478
479/// Add support for JSON serialization.
480LLVM_ABI bool fromJSON(const llvm::json::Value &value,
483
484//===----------------------------------------------------------------------===//
485// DidCloseTextDocumentParams
486//===----------------------------------------------------------------------===//
487
489 /// The document that was closed.
491};
492
493/// Add support for JSON serialization.
494LLVM_ABI bool fromJSON(const llvm::json::Value &value,
497
498//===----------------------------------------------------------------------===//
499// DidSaveTextDocumentParams
500//===----------------------------------------------------------------------===//
501
503 /// The document that was saved.
505};
506
509
510//===----------------------------------------------------------------------===//
511// DidChangeTextDocumentParams
512//===----------------------------------------------------------------------===//
513
515 /// Try to apply this change to the given contents string.
516 LLVM_ABI LogicalResult applyTo(std::string &contents) const;
517 /// Try to apply a set of changes to the given contents string.
520 std::string &contents);
521
522 /// The range of the document that changed.
523 std::optional<Range> range;
524
525 /// The length of the range that got replaced.
526 std::optional<int> rangeLength;
527
528 /// The new text of the range/document.
529 std::string text;
530};
531
532/// Add support for JSON serialization.
533LLVM_ABI bool fromJSON(const llvm::json::Value &value,
536
538 /// The document that changed.
540
541 /// The actual content changes.
542 std::vector<TextDocumentContentChangeEvent> contentChanges;
543};
544
545/// Add support for JSON serialization.
546LLVM_ABI bool fromJSON(const llvm::json::Value &value,
549
550//===----------------------------------------------------------------------===//
551// MarkupContent
552//===----------------------------------------------------------------------===//
553
554/// Describes the content type that a client supports in various result literals
555/// like `Hover`.
560LLVM_ABI raw_ostream &operator<<(raw_ostream &os, MarkupKind kind);
561
566
567/// Add support for JSON serialization.
569
570//===----------------------------------------------------------------------===//
571// Hover
572//===----------------------------------------------------------------------===//
573
574struct Hover {
575 /// Construct a default hover with the given range that uses Markdown content.
577
578 /// The hover's content.
580
581 /// An optional range is a range inside a text document that is used to
582 /// visualize a hover, e.g. by changing the background color.
583 std::optional<Range> range;
584};
585
586/// Add support for JSON serialization.
588
589//===----------------------------------------------------------------------===//
590// SymbolKind
591//===----------------------------------------------------------------------===//
592
621
622//===----------------------------------------------------------------------===//
623// DocumentSymbol
624//===----------------------------------------------------------------------===//
625
626/// Represents programming constructs like variables, classes, interfaces etc.
627/// that appear in a document. Document symbols can be hierarchical and they
628/// have two ranges: one that encloses its definition and one that points to its
629/// most interesting range, e.g. the range of an identifier.
631 DocumentSymbol() = default;
637
638 /// The name of this symbol.
639 std::string name;
640
641 /// More detail for this symbol, e.g the signature of a function.
642 std::string detail;
643
644 /// The kind of this symbol.
646
647 /// The range enclosing this symbol not including leading/trailing whitespace
648 /// but everything else like comments. This information is typically used to
649 /// determine if the clients cursor is inside the symbol to reveal in the
650 /// symbol in the UI.
652
653 /// The range that should be selected and revealed when this symbol is being
654 /// picked, e.g the name of a function. Must be contained by the `range`.
656
657 /// Children of this symbol, e.g. properties of a class.
658 std::vector<DocumentSymbol> children;
659};
660
661/// Add support for JSON serialization.
663
664//===----------------------------------------------------------------------===//
665// DocumentSymbolParams
666//===----------------------------------------------------------------------===//
667
669 // The text document to find symbols in.
671};
672
673/// Add support for JSON serialization.
674LLVM_ABI bool fromJSON(const llvm::json::Value &value,
676
677//===----------------------------------------------------------------------===//
678// DiagnosticRelatedInformation
679//===----------------------------------------------------------------------===//
680
681/// Represents a related message and source code location for a diagnostic.
682/// This should be used to point to code locations that cause or related to a
683/// diagnostics, e.g. when duplicating a symbol in a scope.
688
689 /// The location of this related diagnostic information.
691 /// The message of this related diagnostic information.
692 std::string message;
693};
694
695/// Add support for JSON serialization.
696LLVM_ABI bool fromJSON(const llvm::json::Value &value,
700
701//===----------------------------------------------------------------------===//
702// Diagnostic
703//===----------------------------------------------------------------------===//
704
706 /// It is up to the client to interpret diagnostics as error, warning, info or
707 /// hint.
709 Error = 1,
713};
714
715enum class DiagnosticTag {
718};
719
720/// Add support for JSON serialization.
722LLVM_ABI bool fromJSON(const llvm::json::Value &value, DiagnosticTag &result,
724
726 /// The source range where the message applies.
728
729 /// The diagnostic's severity. Can be omitted. If omitted it is up to the
730 /// client to interpret diagnostics as error, warning, info or hint.
732
733 /// A human-readable string describing the source of this diagnostic, e.g.
734 /// 'typescript' or 'super lint'.
735 std::string source;
736
737 /// The diagnostic's message.
738 std::string message;
739
740 /// An array of related diagnostic information, e.g. when symbol-names within
741 /// a scope collide all definitions can be marked via this property.
742 std::optional<std::vector<DiagnosticRelatedInformation>> relatedInformation;
743
744 /// Additional metadata about the diagnostic.
745 std::vector<DiagnosticTag> tags;
746
747 /// The diagnostic's category. Can be omitted.
748 /// An LSP extension that's used to send the name of the category over to the
749 /// client. The category typically describes the compilation stage during
750 /// which the issue was produced, e.g. "Semantic Issue" or "Parse Issue".
751 std::optional<std::string> category;
752};
753
754/// Add support for JSON serialization.
756LLVM_ABI bool fromJSON(const llvm::json::Value &value, Diagnostic &result,
758
759//===----------------------------------------------------------------------===//
760// PublishDiagnosticsParams
761//===----------------------------------------------------------------------===//
762
766
767 /// The URI for which diagnostic information is reported.
769 /// The list of reported diagnostics.
770 std::vector<Diagnostic> diagnostics;
771 /// The version number of the document the diagnostics are published for.
772 int64_t version;
773};
774
775/// Add support for JSON serialization.
777
778//===----------------------------------------------------------------------===//
779// TextEdit
780//===----------------------------------------------------------------------===//
781
782struct TextEdit {
783 /// The range of the text document to be manipulated. To insert
784 /// text into a document create a range where start === end.
786
787 /// The string to be inserted. For delete operations use an
788 /// empty string.
789 std::string newText;
790};
791
792inline bool operator==(const TextEdit &lhs, const TextEdit &rhs) {
793 return std::tie(lhs.newText, lhs.range) == std::tie(rhs.newText, rhs.range);
794}
795
796LLVM_ABI bool fromJSON(const llvm::json::Value &value, TextEdit &result,
798LLVM_ABI llvm::json::Value toJSON(const TextEdit &value);
799LLVM_ABI raw_ostream &operator<<(raw_ostream &os, const TextEdit &value);
800
801//===----------------------------------------------------------------------===//
802// CompletionItemKind
803//===----------------------------------------------------------------------===//
804
805/// The kind of a completion entry.
834LLVM_ABI bool fromJSON(const llvm::json::Value &value,
835 CompletionItemKind &result, llvm::json::Path path);
836
838 static_cast<size_t>(CompletionItemKind::Text);
840 static_cast<size_t>(CompletionItemKind::TypeParameter);
841using CompletionItemKindBitset = std::bitset<kCompletionItemKindMax + 1>;
842LLVM_ABI bool fromJSON(const llvm::json::Value &value,
844
847 CompletionItemKindBitset &supportedCompletionItemKinds);
848
849//===----------------------------------------------------------------------===//
850// CompletionItem
851//===----------------------------------------------------------------------===//
852
853/// Defines whether the insert text in a completion item should be interpreted
854/// as plain text or a snippet.
857 /// The primary text to be inserted is treated as a plain string.
859 /// The primary text to be inserted is treated as a snippet.
860 ///
861 /// A snippet can define tab stops and placeholders with `$1`, `$2`
862 /// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end
863 /// of the snippet. Placeholders with equal identifiers are linked, that is
864 /// typing in one will update others too.
865 ///
866 /// See also:
867 /// https//github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
869};
870
872 CompletionItem() = default;
877
878 /// The label of this completion item. By default also the text that is
879 /// inserted when selecting this completion.
880 std::string label;
881
882 /// The kind of this completion item. Based of the kind an icon is chosen by
883 /// the editor.
885
886 /// A human-readable string with additional information about this item, like
887 /// type or symbol information.
888 std::string detail;
889
890 /// A human-readable string that represents a doc-comment.
891 std::optional<MarkupContent> documentation;
892
893 /// A string that should be used when comparing this item with other items.
894 /// When `falsy` the label is used.
895 std::string sortText;
896
897 /// A string that should be used when filtering a set of completion items.
898 /// When `falsy` the label is used.
899 std::string filterText;
900
901 /// A string that should be inserted to a document when selecting this
902 /// completion. When `falsy` the label is used.
903 std::string insertText;
904
905 /// The format of the insert text. The format applies to both the `insertText`
906 /// property and the `newText` property of a provided `textEdit`.
908
909 /// An edit which is applied to a document when selecting this completion.
910 /// When an edit is provided `insertText` is ignored.
911 ///
912 /// Note: The range of the edit must be a single line range and it must
913 /// contain the position at which completion has been requested.
914 std::optional<TextEdit> textEdit;
915
916 /// An optional array of additional text edits that are applied when selecting
917 /// this completion. Edits must not overlap with the main edit nor with
918 /// themselves.
919 std::vector<TextEdit> additionalTextEdits;
920
921 /// Indicates if this item is deprecated.
922 bool deprecated = false;
923};
924
925/// Add support for JSON serialization.
928LLVM_ABI bool operator<(const CompletionItem &lhs, const CompletionItem &rhs);
929
930//===----------------------------------------------------------------------===//
931// CompletionList
932//===----------------------------------------------------------------------===//
933
934/// Represents a collection of completion items to be presented in the editor.
936 /// The list is not complete. Further typing should result in recomputing the
937 /// list.
938 bool isIncomplete = false;
939
940 /// The completion items.
941 std::vector<CompletionItem> items;
942};
943
944/// Add support for JSON serialization.
946
947//===----------------------------------------------------------------------===//
948// CompletionContext
949//===----------------------------------------------------------------------===//
950
952 /// Completion was triggered by typing an identifier (24x7 code
953 /// complete), manual invocation (e.g Ctrl+Space) or via API.
955
956 /// Completion was triggered by a trigger character specified by
957 /// the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
959
960 /// Completion was re-triggered as the current completion list is incomplete.
962};
963
965 /// How the completion was triggered.
967
968 /// The trigger character (a single character) that has trigger code complete.
969 /// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
970 std::string triggerCharacter;
971};
972
973/// Add support for JSON serialization.
974LLVM_ABI bool fromJSON(const llvm::json::Value &value,
976
977//===----------------------------------------------------------------------===//
978// CompletionParams
979//===----------------------------------------------------------------------===//
980
984
985/// Add support for JSON serialization.
986LLVM_ABI bool fromJSON(const llvm::json::Value &value, CompletionParams &result,
988
989//===----------------------------------------------------------------------===//
990// ParameterInformation
991//===----------------------------------------------------------------------===//
992
993/// A single parameter of a particular signature.
995 /// The label of this parameter. Ignored when labelOffsets is set.
996 std::string labelString;
997
998 /// Inclusive start and exclusive end offsets withing the containing signature
999 /// label.
1000 std::optional<std::pair<unsigned, unsigned>> labelOffsets;
1001
1002 /// The documentation of this parameter. Optional.
1003 std::string documentation;
1004};
1005
1006/// Add support for JSON serialization.
1008
1009//===----------------------------------------------------------------------===//
1010// SignatureInformation
1011//===----------------------------------------------------------------------===//
1012
1013/// Represents the signature of something callable.
1015 /// The label of this signature. Mandatory.
1016 std::string label;
1017
1018 /// The documentation of this signature. Optional.
1019 std::string documentation;
1020
1021 /// The parameters of this signature.
1022 std::vector<ParameterInformation> parameters;
1023};
1024
1025/// Add support for JSON serialization.
1028 const SignatureInformation &value);
1029
1030//===----------------------------------------------------------------------===//
1031// SignatureHelp
1032//===----------------------------------------------------------------------===//
1033
1034/// Represents the signature of a callable.
1036 /// The resulting signatures.
1037 std::vector<SignatureInformation> signatures;
1038
1039 /// The active signature.
1041
1042 /// The active parameter of the active signature.
1044};
1045
1046/// Add support for JSON serialization.
1048
1049//===----------------------------------------------------------------------===//
1050// DocumentLinkParams
1051//===----------------------------------------------------------------------===//
1052
1053/// Parameters for the document link request.
1055 /// The document to provide document links for.
1057};
1058
1059/// Add support for JSON serialization.
1060LLVM_ABI bool fromJSON(const llvm::json::Value &value,
1062
1063//===----------------------------------------------------------------------===//
1064// DocumentLink
1065//===----------------------------------------------------------------------===//
1066
1067/// A range in a text document that links to an internal or external resource,
1068/// like another text document or a web site.
1070 DocumentLink() = default;
1073
1074 /// The range this link applies to.
1076
1077 /// The uri this link points to. If missing a resolve request is sent later.
1079
1080 // TODO: The following optional fields defined by the language server protocol
1081 // are unsupported:
1082 //
1083 // data?: any - A data entry field that is preserved on a document link
1084 // between a DocumentLinkRequest and a
1085 // DocumentLinkResolveRequest.
1086
1087 friend bool operator==(const DocumentLink &lhs, const DocumentLink &rhs) {
1088 return lhs.range == rhs.range && lhs.target == rhs.target;
1089 }
1090
1091 friend bool operator!=(const DocumentLink &lhs, const DocumentLink &rhs) {
1092 return !(lhs == rhs);
1093 }
1094};
1095
1096/// Add support for JSON serialization.
1097LLVM_ABI llvm::json::Value toJSON(const DocumentLink &value);
1098
1099//===----------------------------------------------------------------------===//
1100// InlayHintsParams
1101//===----------------------------------------------------------------------===//
1102
1103/// A parameter literal used in inlay hint requests.
1105 /// The text document.
1107
1108 /// The visible document range for which inlay hints should be computed.
1110};
1111
1112/// Add support for JSON serialization.
1113LLVM_ABI bool fromJSON(const llvm::json::Value &value, InlayHintsParams &result,
1115
1116//===----------------------------------------------------------------------===//
1117// InlayHintKind
1118//===----------------------------------------------------------------------===//
1119
1120/// Inlay hint kinds.
1121enum class InlayHintKind {
1122 /// An inlay hint that for a type annotation.
1123 ///
1124 /// An example of a type hint is a hint in this position:
1125 /// auto var ^ = expr;
1126 /// which shows the deduced type of the variable.
1127 Type = 1,
1128
1129 /// An inlay hint that is for a parameter.
1130 ///
1131 /// An example of a parameter hint is a hint in this position:
1132 /// func(^arg);
1133 /// which shows the name of the corresponding parameter.
1135};
1136
1137//===----------------------------------------------------------------------===//
1138// InlayHint
1139//===----------------------------------------------------------------------===//
1140
1141/// Inlay hint information.
1144
1145 /// The position of this hint.
1147
1148 /// The label of this hint. A human readable string or an array of
1149 /// InlayHintLabelPart label parts.
1150 ///
1151 /// *Note* that neither the string nor the label part can be empty.
1152 std::string label;
1153
1154 /// The kind of this hint. Can be omitted in which case the client should fall
1155 /// back to a reasonable default.
1157
1158 /// Render padding before the hint.
1159 ///
1160 /// Note: Padding should use the editor's background color, not the
1161 /// background color of the hint itself. That means padding can be used
1162 /// to visually align/separate an inlay hint.
1163 bool paddingLeft = false;
1164
1165 /// Render padding after the hint.
1166 ///
1167 /// Note: Padding should use the editor's background color, not the
1168 /// background color of the hint itself. That means padding can be used
1169 /// to visually align/separate an inlay hint.
1170 bool paddingRight = false;
1171};
1172
1173/// Add support for JSON serialization.
1175LLVM_ABI bool operator==(const InlayHint &lhs, const InlayHint &rhs);
1176LLVM_ABI bool operator<(const InlayHint &lhs, const InlayHint &rhs);
1178 InlayHintKind value);
1179
1180//===----------------------------------------------------------------------===//
1181// CodeActionContext
1182//===----------------------------------------------------------------------===//
1183
1185 /// An array of diagnostics known on the client side overlapping the range
1186 /// provided to the `textDocument/codeAction` request. They are provided so
1187 /// that the server knows which errors are currently presented to the user for
1188 /// the given range. There is no guarantee that these accurately reflect the
1189 /// error state of the resource. The primary parameter to compute code actions
1190 /// is the provided range.
1191 std::vector<Diagnostic> diagnostics;
1192
1193 /// Requested kind of actions to return.
1194 ///
1195 /// Actions not of this kind are filtered out by the client before being
1196 /// shown. So servers can omit computing them.
1197 std::vector<std::string> only;
1198};
1199
1200/// Add support for JSON serialization.
1201LLVM_ABI bool fromJSON(const llvm::json::Value &value,
1203
1204//===----------------------------------------------------------------------===//
1205// CodeActionParams
1206//===----------------------------------------------------------------------===//
1207
1209 /// The document in which the command was invoked.
1211
1212 /// The range for which the command was invoked.
1214
1215 /// Context carrying additional information.
1217};
1218
1219/// Add support for JSON serialization.
1220LLVM_ABI bool fromJSON(const llvm::json::Value &value, CodeActionParams &result,
1222
1223//===----------------------------------------------------------------------===//
1224// WorkspaceEdit
1225//===----------------------------------------------------------------------===//
1226
1228 /// Holds changes to existing resources.
1229 std::map<std::string, std::vector<TextEdit>> changes;
1230
1231 /// Note: "documentChanges" is not currently used because currently there is
1232 /// no support for versioned edits.
1233};
1234
1235/// Add support for JSON serialization.
1236LLVM_ABI bool fromJSON(const llvm::json::Value &value, WorkspaceEdit &result,
1239
1240//===----------------------------------------------------------------------===//
1241// CodeAction
1242//===----------------------------------------------------------------------===//
1243
1244/// A code action represents a change that can be performed in code, e.g. to fix
1245/// a problem or to refactor code.
1246///
1247/// A CodeAction must set either `edit` and/or a `command`. If both are
1248/// supplied, the `edit` is applied first, then the `command` is executed.
1250 /// A short, human-readable, title for this code action.
1251 std::string title;
1252
1253 /// The kind of the code action.
1254 /// Used to filter code actions.
1255 std::optional<std::string> kind;
1259
1260 /// The diagnostics that this code action resolves.
1261 std::optional<std::vector<Diagnostic>> diagnostics;
1262
1263 /// Marks this as a preferred action. Preferred actions are used by the
1264 /// `auto fix` command and can be targeted by keybindings.
1265 /// A quick fix should be marked preferred if it properly addresses the
1266 /// underlying error. A refactoring should be marked preferred if it is the
1267 /// most reasonable choice of actions to take.
1268 bool isPreferred = false;
1269
1270 /// The workspace edit this code action performs.
1271 std::optional<WorkspaceEdit> edit;
1272};
1273
1274/// Add support for JSON serialization.
1276
1277//===----------------------------------------------------------------------===//
1278// ShowMessageParams
1279//===----------------------------------------------------------------------===//
1280
1281enum class MessageType { Error = 1, Warning = 2, Info = 3, Log = 4, Debug = 5 };
1282
1284 /// A short title like 'Retry', 'Open Log' etc.
1285 std::string title;
1286};
1287
1289 ShowMessageParams(MessageType Type, std::string Message)
1290 : type(Type), message(Message) {}
1292 /// The actual message.
1293 std::string message;
1294 /// The message action items to present.
1295 std::optional<std::vector<MessageActionItem>> actions;
1296};
1297
1298/// Add support for JSON serialization.
1300
1301/// Add support for JSON serialization.
1303
1304} // namespace lsp
1305} // namespace llvm
1306
1307namespace llvm {
1308template <> struct format_provider<llvm::lsp::Position> {
1309 static void format(const llvm::lsp::Position &pos, raw_ostream &os,
1310 StringRef style) {
1311 assert(style.empty() && "style modifiers for this type are not supported");
1312 os << pos;
1313 }
1314};
1315} // namespace llvm
1316
1317#endif
1318
1319// NOLINTEND(readability-identifier-naming)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:215
This file supports working with JSON data.
lazy value info
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
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:151
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:888
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
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:652
A Value is an JSON value of unknown type.
Definition JSON.h:290
static LLVM_ABI 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 LLVM_ABI void registerSupportedScheme(StringRef scheme)
Register a supported URI scheme.
Definition Protocol.cpp:234
static LLVM_ABI 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_ABI llvm::Expected< URIForFile > fromURI(StringRef uri)
Try to build a URIForFile from the given URI string.
Definition Protocol.cpp:216
LLVM_ABI 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:837
MarkupKind
Describes the content type that a client supports in various result literals like Hover.
Definition Protocol.h:556
LLVM_ABI llvm::json::Value toJSON(const URIForFile &value)
Add support for JSON serialization.
Definition Protocol.cpp:253
CompletionTriggerKind
Definition Protocol.h:951
@ Invoked
Completion was triggered by typing an identifier (24x7 code complete), manual invocation (e....
Definition Protocol.h:954
@ TriggerTriggerForIncompleteCompletions
Completion was re-triggered as the current completion list is incomplete.
Definition Protocol.h:961
@ TriggerCharacter
Completion was triggered by a trigger character specified by the triggerCharacters properties of the ...
Definition Protocol.h:958
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
LLVM_ABI bool operator<(const CompletionItem &lhs, const CompletionItem &rhs)
Definition Protocol.cpp:829
bool operator==(const TextEdit &lhs, const TextEdit &rhs)
Definition Protocol.h:792
NoParams InitializedParams
Definition Protocol.h:238
LLVM_ABI raw_ostream & operator<<(raw_ostream &os, const URIForFile &value)
Definition Protocol.cpp:257
LLVM_ABI CompletionItemKind adjustKindToCapability(CompletionItemKind kind, CompletionItemKindBitset &supportedCompletionItemKinds)
Definition Protocol.cpp:756
InlayHintKind
Inlay hint kinds.
Definition Protocol.h:1121
@ Parameter
An inlay hint that is for a parameter.
Definition Protocol.h:1134
@ Type
An inlay hint that for a type annotation.
Definition Protocol.h:1127
DiagnosticSeverity
Definition Protocol.h:705
@ Undetermined
It is up to the client to interpret diagnostics as error, warning, info or hint.
Definition Protocol.h:708
InsertTextFormat
Defines whether the insert text in a completion item should be interpreted as plain text or a snippet...
Definition Protocol.h:855
std::bitset< kCompletionItemKindMax+1 > CompletionItemKindBitset
Definition Protocol.h:841
constexpr auto kCompletionItemKindMax
Definition Protocol.h:839
CompletionItemKind
The kind of a completion entry.
Definition Protocol.h:806
LLVM_ABI 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:860
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:1309
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:184
std::optional< std::string > version
The client's version as defined by the client.
Definition Protocol.h:187
std::vector< Diagnostic > diagnostics
An array of diagnostics known on the client side overlapping the range provided to the textDocument/c...
Definition Protocol.h:1191
std::vector< std::string > only
Requested kind of actions to return.
Definition Protocol.h:1197
CodeActionContext context
Context carrying additional information.
Definition Protocol.h:1216
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Definition Protocol.h:1210
Range range
The range for which the command was invoked.
Definition Protocol.h:1213
A code action represents a change that can be performed in code, e.g.
Definition Protocol.h:1249
std::optional< std::string > kind
The kind of the code action.
Definition Protocol.h:1255
LLVM_ABI static const llvm::StringLiteral kRefactor
Definition Protocol.h:1257
LLVM_ABI static const llvm::StringLiteral kInfo
Definition Protocol.h:1258
bool isPreferred
Marks this as a preferred action.
Definition Protocol.h:1268
LLVM_ABI static const llvm::StringLiteral kQuickFix
Definition Protocol.h:1256
std::optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Definition Protocol.h:1261
std::optional< WorkspaceEdit > edit
The workspace edit this code action performs.
Definition Protocol.h:1271
std::string title
A short, human-readable, title for this code action.
Definition Protocol.h:1251
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
Definition Protocol.h:970
CompletionTriggerKind triggerKind
How the completion was triggered.
Definition Protocol.h:966
CompletionItem(const Twine &label, CompletionItemKind kind, StringRef sortText="")
Definition Protocol.h:873
std::string filterText
A string that should be used when filtering a set of completion items.
Definition Protocol.h:899
std::string insertText
A string that should be inserted to a document when selecting this completion.
Definition Protocol.h:903
bool deprecated
Indicates if this item is deprecated.
Definition Protocol.h:922
std::optional< TextEdit > textEdit
An edit which is applied to a document when selecting this completion.
Definition Protocol.h:914
std::vector< TextEdit > additionalTextEdits
An optional array of additional text edits that are applied when selecting this completion.
Definition Protocol.h:919
CompletionItemKind kind
The kind of this completion item.
Definition Protocol.h:884
InsertTextFormat insertTextFormat
The format of the insert text.
Definition Protocol.h:907
std::string label
The label of this completion item.
Definition Protocol.h:880
std::optional< MarkupContent > documentation
A human-readable string that represents a doc-comment.
Definition Protocol.h:891
std::string sortText
A string that should be used when comparing this item with other items.
Definition Protocol.h:895
Represents a collection of completion items to be presented in the editor.
Definition Protocol.h:935
bool isIncomplete
The list is not complete.
Definition Protocol.h:938
std::vector< CompletionItem > items
The completion items.
Definition Protocol.h:941
CompletionContext context
Definition Protocol.h:982
Represents a related message and source code location for a diagnostic.
Definition Protocol.h:684
DiagnosticRelatedInformation(Location location, std::string message)
Definition Protocol.h:686
std::string message
The message of this related diagnostic information.
Definition Protocol.h:692
Location location
The location of this related diagnostic information.
Definition Protocol.h:690
std::vector< DiagnosticTag > tags
Additional metadata about the diagnostic.
Definition Protocol.h:745
std::string message
The diagnostic's message.
Definition Protocol.h:738
Range range
The source range where the message applies.
Definition Protocol.h:727
std::optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
An array of related diagnostic information, e.g.
Definition Protocol.h:742
std::string source
A human-readable string describing the source of this diagnostic, e.g.
Definition Protocol.h:735
DiagnosticSeverity severity
The diagnostic's severity.
Definition Protocol.h:731
std::optional< std::string > category
The diagnostic's category.
Definition Protocol.h:751
VersionedTextDocumentIdentifier textDocument
The document that changed.
Definition Protocol.h:539
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
Definition Protocol.h:542
TextDocumentIdentifier textDocument
The document that was closed.
Definition Protocol.h:490
TextDocumentItem textDocument
The document that was opened.
Definition Protocol.h:476
TextDocumentIdentifier textDocument
The document that was saved.
Definition Protocol.h:504
Parameters for the document link request.
Definition Protocol.h:1054
TextDocumentIdentifier textDocument
The document to provide document links for.
Definition Protocol.h:1056
TextDocumentIdentifier textDocument
Definition Protocol.h:670
Represents programming constructs like variables, classes, interfaces etc.
Definition Protocol.h:630
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
Definition Protocol.h:651
SymbolKind kind
The kind of this symbol.
Definition Protocol.h:645
DocumentSymbol(const Twine &name, SymbolKind kind, Range range, Range selectionRange)
Definition Protocol.h:633
std::string name
The name of this symbol.
Definition Protocol.h:639
DocumentSymbol(DocumentSymbol &&)=default
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
Definition Protocol.h:658
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition Protocol.h:655
std::optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover,...
Definition Protocol.h:583
Hover(Range range)
Construct a default hover with the given range that uses Markdown content.
Definition Protocol.h:576
MarkupContent contents
The hover's content.
Definition Protocol.h:579
std::optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
Definition Protocol.h:216
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool).
Definition Protocol.h:210
std::optional< ClientInfo > clientInfo
Information about the client.
Definition Protocol.h:213
std::optional< std::string > rootUri
The root URI of the workspace. Is null if no folder is open.
Definition Protocol.h:219
std::optional< std::string > rootPath
The root path of the workspace.
Definition Protocol.h:223
Inlay hint information.
Definition Protocol.h:1142
bool paddingRight
Render padding after the hint.
Definition Protocol.h:1170
InlayHint(InlayHintKind kind, Position pos)
Definition Protocol.h:1143
bool paddingLeft
Render padding before the hint.
Definition Protocol.h:1163
InlayHintKind kind
The kind of this hint.
Definition Protocol.h:1156
std::string label
The label of this hint.
Definition Protocol.h:1152
Position position
The position of this hint.
Definition Protocol.h:1146
A parameter literal used in inlay hint requests.
Definition Protocol.h:1104
Range range
The visible document range for which inlay hints should be computed.
Definition Protocol.h:1109
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1106
Location(const URIForFile &uri, Range range)
Definition Protocol.h:403
friend bool operator<(const Location &lhs, const Location &rhs)
Definition Protocol.h:421
friend bool operator!=(const Location &lhs, const Location &rhs)
Definition Protocol.h:417
URIForFile uri
The text document's URI.
Definition Protocol.h:410
Location(const URIForFile &uri, llvm::SourceMgr &mgr, SMRange range)
Construct a Location from the given source range.
Definition Protocol.h:406
friend bool operator==(const Location &lhs, const Location &rhs)
Definition Protocol.h:413
std::string title
A short title like 'Retry', 'Open Log' etc.
Definition Protocol.h:1285
A single parameter of a particular signature.
Definition Protocol.h:994
std::optional< std::pair< unsigned, unsigned > > labelOffsets
Inclusive start and exclusive end offsets withing the containing signature label.
Definition Protocol.h:1000
std::string documentation
The documentation of this parameter. Optional.
Definition Protocol.h:1003
std::string labelString
The label of this parameter. Ignored when labelOffsets is set.
Definition Protocol.h:996
Position(llvm::SourceMgr &mgr, SMLoc loc)
Construct a position from the given source location.
Definition Protocol.h:302
int line
Line position in a document (zero-based).
Definition Protocol.h:309
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:332
friend bool operator==(const Position &lhs, const Position &rhs)
Definition Protocol.h:314
Position(int line=0, int character=0)
Definition Protocol.h:298
int character
Character offset on a line in a document (zero-based).
Definition Protocol.h:312
friend bool operator<(const Position &lhs, const Position &rhs)
Definition Protocol.h:321
friend bool operator<=(const Position &lhs, const Position &rhs)
Definition Protocol.h:325
friend bool operator!=(const Position &lhs, const Position &rhs)
Definition Protocol.h:318
URIForFile uri
The URI for which diagnostic information is reported.
Definition Protocol.h:768
PublishDiagnosticsParams(URIForFile uri, int64_t version)
Definition Protocol.h:764
int64_t version
The version number of the document the diagnostics are published for.
Definition Protocol.h:772
std::vector< Diagnostic > diagnostics
The list of reported diagnostics.
Definition Protocol.h:770
bool contains(Position pos) const
Definition Protocol.h:373
friend bool operator!=(const Range &lhs, const Range &rhs)
Definition Protocol.h:366
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:380
friend bool operator<(const Range &lhs, const Range &rhs)
Definition Protocol.h:369
bool contains(Range range) const
Definition Protocol.h:374
Position end
The range's end position.
Definition Protocol.h:361
Position start
The range's start position.
Definition Protocol.h:358
Range(llvm::SourceMgr &mgr, SMRange range)
Construct a range from the given source range.
Definition Protocol.h:354
Range(Position start, Position end)
Definition Protocol.h:350
friend bool operator==(const Range &lhs, const Range &rhs)
Definition Protocol.h:363
Range(Position loc)
Definition Protocol.h:351
bool includeDeclaration
Include the declaration of the current symbol.
Definition Protocol.h:455
ReferenceContext context
Definition Protocol.h:463
ShowMessageParams(MessageType Type, std::string Message)
Definition Protocol.h:1289
std::string message
The actual message.
Definition Protocol.h:1293
std::optional< std::vector< MessageActionItem > > actions
The message action items to present.
Definition Protocol.h:1295
Represents the signature of a callable.
Definition Protocol.h:1035
std::vector< SignatureInformation > signatures
The resulting signatures.
Definition Protocol.h:1037
int activeParameter
The active parameter of the active signature.
Definition Protocol.h:1043
int activeSignature
The active signature.
Definition Protocol.h:1040
Represents the signature of something callable.
Definition Protocol.h:1014
std::vector< ParameterInformation > parameters
The parameters of this signature.
Definition Protocol.h:1022
std::string label
The label of this signature. Mandatory.
Definition Protocol.h:1016
std::string documentation
The documentation of this signature. Optional.
Definition Protocol.h:1019
std::optional< Range > range
The range of the document that changed.
Definition Protocol.h:523
std::optional< int > rangeLength
The length of the range that got replaced.
Definition Protocol.h:526
LLVM_ABI 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:529
URIForFile uri
The text document's URI.
Definition Protocol.h:268
std::string languageId
The text document's language identifier.
Definition Protocol.h:249
URIForFile uri
The text document's URI.
Definition Protocol.h:246
int64_t version
The version number of this document.
Definition Protocol.h:255
std::string text
The content of the opened text document.
Definition Protocol.h:252
Position position
The position inside the text document.
Definition Protocol.h:441
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:438
Range range
The range of the text document to be manipulated.
Definition Protocol.h:785
std::string newText
The string to be inserted.
Definition Protocol.h:789
URIForFile uri
The text document's URI.
Definition Protocol.h:282
int64_t version
The version number of this document.
Definition Protocol.h:284
std::map< std::string, std::vector< TextEdit > > changes
Holds changes to existing resources.
Definition Protocol.h:1229