nixd
Loading...
Searching...
No Matches
lspserver/include/lspserver/Protocol.h
Go to the documentation of this file.
1#pragma once
2
3#include "URI.h"
4
5#include <bitset>
6#include <memory>
7#include <optional>
8#include <string>
9#include <variant>
10#include <vector>
11
12#include <llvm/ADT/SmallVector.h>
13#include <llvm/Support/JSON.h>
14#include <llvm/Support/raw_ostream.h>
15
16// This file is using the LSP syntax for identifier names which is different
17// from the LLVM coding standard. To avoid the clang-tidy warnings, we're
18// disabling one check here.
19// NOLINTBEGIN(readability-identifier-naming)
20
21namespace lspserver {
22
23enum class ErrorCode {
24 // Defined by JSON RPC.
25 ParseError = -32700,
28 InvalidParams = -32602,
29 InternalError = -32603,
30
33
34 // Defined by the protocol.
37};
38// Models an LSP error as an llvm::Error.
39class LSPError : public llvm::ErrorInfo<LSPError> {
40public:
41 std::string Message;
43 static char ID;
44
46 : Message(std::move(Message)), Code(Code) {}
47
48 void log(llvm::raw_ostream &OS) const override {
49 OS << int(Code) << ": " << Message;
50 }
51 std::error_code convertToErrorCode() const override {
52 return llvm::inconvertibleErrorCode();
53 }
54};
55
56// URI in "file" scheme for a file.
57struct URIForFile {
58 URIForFile() = default;
59
60 /// Canonicalizes \p AbsPath via URI.
61 ///
62 /// File paths in URIForFile can come from index or local AST. Path from
63 /// index goes through URI transformation, and the final path is resolved by
64 /// URI scheme and could potentially be different from the original path.
65 /// Hence, we do the same transformation for all paths.
66 ///
67 /// Files can be referred to by several paths (e.g. in the presence of links).
68 /// Which one we prefer may depend on where we're coming from. \p TUPath is a
69 /// hint, and should usually be the main entrypoint file we're processing.
70 static URIForFile canonicalize(llvm::StringRef AbsPath,
71 llvm::StringRef TUPath);
72
73 static llvm::Expected<URIForFile> fromURI(const URI &U,
74 llvm::StringRef HintPath);
75
76 /// Retrieves absolute path to the file.
77 llvm::StringRef file() const { return File; }
78
79 explicit operator bool() const { return !File.empty(); }
80 std::string uri() const { return URI::createFile(File).toString(); }
81
82 friend bool operator==(const URIForFile &LHS, const URIForFile &RHS) {
83 return LHS.File == RHS.File;
84 }
85
86 friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS) {
87 return !(LHS == RHS);
88 }
89
90 friend bool operator<(const URIForFile &LHS, const URIForFile &RHS) {
91 return LHS.File < RHS.File;
92 }
93
94private:
95 explicit URIForFile(std::string &&File) : File(std::move(File)) {}
96
97 std::string File;
98};
99
100/// Serialize/deserialize \p URIForFile to/from a string URI.
101llvm::json::Value toJSON(const URIForFile &U);
102bool fromJSON(const llvm::json::Value &, URIForFile &, llvm::json::Path);
103
105 /// The text document's URI.
107};
108llvm::json::Value toJSON(const TextDocumentIdentifier &);
109bool fromJSON(const llvm::json::Value &, TextDocumentIdentifier &,
110 llvm::json::Path);
111
113 /// The version number of this document. If a versioned text document
114 /// identifier is sent from the server to the client and the file is not open
115 /// in the editor (the server has not received an open notification before)
116 /// the server can send `null` to indicate that the version is known and the
117 /// content on disk is the master (as speced with document content ownership).
118 ///
119 /// The version number of a document will increase after each change,
120 /// including undo/redo. The number doesn't need to be consecutive.
121 ///
122 /// clangd extension: versions are optional, and synthesized if missing.
123 std::optional<std::int64_t> version;
124};
125llvm::json::Value toJSON(const VersionedTextDocumentIdentifier &);
126bool fromJSON(const llvm::json::Value &, VersionedTextDocumentIdentifier &,
127 llvm::json::Path);
128
129struct Position {
130 /// Line position in a document (zero-based).
131 int64_t line = 0;
132
133 /// Character offset on a line in a document (zero-based).
134 /// WARNING: this is in UTF-16 codepoints, not bytes or characters!
135 /// Use the functions in SourceCode.h to construct/interpret Positions.
136 int64_t character = 0;
137
138 friend bool operator==(const Position &LHS, const Position &RHS) {
139 return std::tie(LHS.line, LHS.character) ==
140 std::tie(RHS.line, RHS.character);
141 }
142 friend bool operator!=(const Position &LHS, const Position &RHS) {
143 return !(LHS == RHS);
144 }
145 friend bool operator<(const Position &LHS, const Position &RHS) {
146 return std::tie(LHS.line, LHS.character) <
147 std::tie(RHS.line, RHS.character);
148 }
149 friend bool operator<=(const Position &LHS, const Position &RHS) {
150 return std::tie(LHS.line, LHS.character) <=
151 std::tie(RHS.line, RHS.character);
152 }
153};
154bool fromJSON(const llvm::json::Value &, Position &, llvm::json::Path);
155llvm::json::Value toJSON(const Position &);
156llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Position &);
157
158struct Range {
159 /// The range's start position.
161
162 /// The range's end position.
164
165 friend bool operator==(const Range &LHS, const Range &RHS) {
166 return std::tie(LHS.start, LHS.end) == std::tie(RHS.start, RHS.end);
167 }
168 friend bool operator!=(const Range &LHS, const Range &RHS) {
169 return !(LHS == RHS);
170 }
171 friend bool operator<(const Range &LHS, const Range &RHS) {
172 return std::tie(LHS.start, LHS.end) < std::tie(RHS.start, RHS.end);
173 }
174
175 bool contains(Position Pos) const { return start <= Pos && Pos < end; }
176 bool contains(Range Rng) const {
177 return start <= Rng.start && Rng.end <= end;
178 }
179
180 Range operator/(const Range &RHS) const {
181 return {std::min(start, RHS.start), std::max(end, RHS.end)};
182 }
183
184 /// \returns true if the ranges overlap.
185 [[nodiscard]] bool overlap(const Range &RHS) const {
186 return start <= RHS.end && RHS.start <= end;
187 }
188};
189bool fromJSON(const llvm::json::Value &, Range &, llvm::json::Path);
190llvm::json::Value toJSON(const Range &);
191llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Range &);
192
193struct Location {
194 /// The text document's URI.
197
198 friend bool operator==(const Location &LHS, const Location &RHS) {
199 return LHS.uri == RHS.uri && LHS.range == RHS.range;
200 }
201
202 friend bool operator!=(const Location &LHS, const Location &RHS) {
203 return !(LHS == RHS);
204 }
205
206 friend bool operator<(const Location &LHS, const Location &RHS) {
207 return std::tie(LHS.uri, LHS.range) < std::tie(RHS.uri, RHS.range);
208 }
209};
210llvm::json::Value toJSON(const Location &);
211bool fromJSON(const llvm::json::Value &, Location &, llvm::json::Path);
212llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Location &);
213
214/// Extends Locations returned by textDocument/references with extra info.
215/// This is a clangd extension: LSP uses `Location`.
217 /// clangd extension: contains the name of the function or class in which the
218 /// reference occurs
219 std::optional<std::string> containerName;
220};
221llvm::json::Value toJSON(const ReferenceLocation &);
222llvm::raw_ostream &operator<<(llvm::raw_ostream &, const ReferenceLocation &);
223
224using ChangeAnnotationIdentifier = std::string;
225// A combination of a LSP standard TextEdit and AnnotatedTextEdit.
226struct TextEdit {
227 /// The range of the text document to be manipulated. To insert
228 /// text into a document create a range where start === end.
230
231 /// The string to be inserted. For delete operations use an
232 /// empty string.
233 std::string newText;
234
235 /// The actual annotation identifier (optional)
236 /// If empty, then this field is nullopt.
238};
239inline bool operator==(const TextEdit &L, const TextEdit &R) {
240 return std::tie(L.newText, L.range, L.annotationId) ==
241 std::tie(R.newText, R.range, L.annotationId);
242}
243bool fromJSON(const llvm::json::Value &, TextEdit &, llvm::json::Path);
244llvm::json::Value toJSON(const TextEdit &);
245llvm::raw_ostream &operator<<(llvm::raw_ostream &, const TextEdit &);
246
248 /// A human-readable string describing the actual change. The string
249 /// is rendered prominent in the user interface.
250 std::string label;
251
252 /// A flag which indicates that user confirmation is needed
253 /// before applying the change.
254 std::optional<bool> needsConfirmation;
255
256 /// A human-readable string which is rendered less prominent in
257 /// the user interface.
258 std::string description;
259};
260bool fromJSON(const llvm::json::Value &, ChangeAnnotation &, llvm::json::Path);
261llvm::json::Value toJSON(const ChangeAnnotation &);
262
264 /// The text document to change.
266
267 /// The edits to be applied.
268 /// FIXME: support the AnnotatedTextEdit variant.
269 std::vector<TextEdit> edits;
270};
271bool fromJSON(const llvm::json::Value &, TextDocumentEdit &, llvm::json::Path);
272llvm::json::Value toJSON(const TextDocumentEdit &);
273
274//===----------------------------------------------------------------------===//
275// Resource Operations (LSP 3.13+)
276//===----------------------------------------------------------------------===//
277
278/// Options for CreateFile operation.
280 /// Overwrite existing file. Overwrite wins over `ignoreIfExists`.
281 std::optional<bool> overwrite;
282 /// Ignore if exists.
283 std::optional<bool> ignoreIfExists;
284};
285llvm::json::Value toJSON(const CreateFileOptions &);
286
287/// Create file operation.
289 /// The resource to create.
291 /// Additional options.
292 std::optional<CreateFileOptions> options;
293 /// An optional annotation identifier.
294 std::optional<std::string> annotationId;
295};
296llvm::json::Value toJSON(const CreateFile &);
297
298/// Options for RenameFile operation.
300 /// Overwrite target if existing. Overwrite wins over `ignoreIfExists`.
301 std::optional<bool> overwrite;
302 /// Ignores if target exists.
303 std::optional<bool> ignoreIfExists;
304};
305llvm::json::Value toJSON(const RenameFileOptions &);
306
307/// Rename file operation.
309 /// The old (existing) location.
311 /// The new location.
313 /// Rename options.
314 std::optional<RenameFileOptions> options;
315 /// An optional annotation identifier.
316 std::optional<std::string> annotationId;
317};
318llvm::json::Value toJSON(const RenameFile &);
319
320/// Options for DeleteFile operation.
322 /// Delete the content recursively if a folder is denoted.
323 std::optional<bool> recursive;
324 /// Ignore the operation if the file doesn't exist.
325 std::optional<bool> ignoreIfNotExists;
326};
327llvm::json::Value toJSON(const DeleteFileOptions &);
328
329/// Delete file operation.
331 /// The file to delete.
333 /// Delete options.
334 std::optional<DeleteFileOptions> options;
335 /// An optional annotation identifier.
336 std::optional<std::string> annotationId;
337};
338llvm::json::Value toJSON(const DeleteFile &);
339
340/// A document change is either a TextDocumentEdit or a resource operation
341/// (CreateFile, RenameFile, DeleteFile).
342/// The discriminator is the presence of a "kind" field for resource operations.
344 std::variant<TextDocumentEdit, CreateFile, RenameFile, DeleteFile>;
345llvm::json::Value toJSON(const DocumentChange &);
346bool fromJSON(const llvm::json::Value &, DocumentChange &, llvm::json::Path);
347
349 /// The text document's URI.
351
352 /// The text document's language identifier.
353 std::string languageId;
354
355 /// The version number of this document (it will strictly increase after each
356 /// change, including undo/redo.
357 ///
358 /// clangd extension: versions are optional, and synthesized if missing.
359 std::optional<int64_t> version;
360
361 /// The content of the opened text document.
362 std::string text;
363};
364bool fromJSON(const llvm::json::Value &, TextDocumentItem &, llvm::json::Path);
365
366enum class TraceLevel {
367 Off = 0,
370};
371bool fromJSON(const llvm::json::Value &E, TraceLevel &Out, llvm::json::Path);
372
373struct NoParams {};
374inline llvm::json::Value toJSON(const NoParams &) { return nullptr; }
375inline bool fromJSON(const llvm::json::Value &, NoParams &, llvm::json::Path) {
376 return true;
377}
379
380/// Defines how the host (editor) should sync document changes to the language
381/// server.
383 /// Documents should not be synced at all.
384 None = 0,
385
386 /// Documents are synced by always sending the full content of the document.
387 Full = 1,
388
389 /// Documents are synced by sending the full content on open. After that
390 /// only incremental updates to the document are send.
392};
393
394/// The kind of a completion entry.
423bool fromJSON(const llvm::json::Value &, CompletionItemKind &,
424 llvm::json::Path);
425constexpr auto CompletionItemKindMin =
426 static_cast<size_t>(CompletionItemKind::Text);
427constexpr auto CompletionItemKindMax =
428 static_cast<size_t>(CompletionItemKind::TypeParameter);
429using CompletionItemKindBitset = std::bitset<CompletionItemKindMax + 1>;
430bool fromJSON(const llvm::json::Value &, CompletionItemKindBitset &,
431 llvm::json::Path);
434 CompletionItemKindBitset &SupportedCompletionItemKinds);
435
436/// A symbol kind.
465bool fromJSON(const llvm::json::Value &, SymbolKind &, llvm::json::Path);
466constexpr auto SymbolKindMin = static_cast<size_t>(SymbolKind::File);
467constexpr auto SymbolKindMax = static_cast<size_t>(SymbolKind::TypeParameter);
468using SymbolKindBitset = std::bitset<SymbolKindMax + 1>;
469bool fromJSON(const llvm::json::Value &, SymbolKindBitset &, llvm::json::Path);
471 SymbolKindBitset &supportedSymbolKinds);
472
473// Determines the encoding used to measure offsets and lengths of source in LSP.
474enum class OffsetEncoding {
475 // Any string is legal on the wire. Unrecognized encodings parse as this.
477 // Length counts code units of UTF-16 encoded text. (Standard LSP behavior).
479 // Length counts bytes of UTF-8 encoded text. (Clangd extension).
481 // Length counts codepoints in unicode text. (Clangd extension).
483};
484llvm::json::Value toJSON(const OffsetEncoding &);
485bool fromJSON(const llvm::json::Value &, OffsetEncoding &, llvm::json::Path);
486llvm::raw_ostream &operator<<(llvm::raw_ostream &, OffsetEncoding);
487
488// Describes the content type that a client supports in various result literals
489// like `Hover`, `ParameterInfo` or `CompletionItem`.
494bool fromJSON(const llvm::json::Value &, MarkupKind &, llvm::json::Path);
495llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, MarkupKind);
496
497// This struct doesn't mirror LSP!
498// The protocol defines deeply nested structures for client capabilities.
499// Instead of mapping them all, this just parses out the bits we care about.
501 /// The supported set of SymbolKinds for workspace/symbol.
502 /// workspace.symbol.symbolKind.valueSet
503 std::optional<SymbolKindBitset> WorkspaceSymbolKinds;
504
505 /// Whether the client accepts diagnostics with codeActions attached inline.
506 /// textDocument.publishDiagnostics.codeActionsInline.
507 bool DiagnosticFixes = false;
508
509 /// Whether the client accepts diagnostics with related locations.
510 /// textDocument.publishDiagnostics.relatedInformation.
512
513 /// Whether the client accepts diagnostics with category attached to it
514 /// using the "category" extension.
515 /// textDocument.publishDiagnostics.categorySupport
516 bool DiagnosticCategory = false;
517
518 /// Client supports snippets as insert text.
519 /// textDocument.completion.completionItem.snippetSupport
520 bool CompletionSnippets = false;
521
522 /// Client supports completions with additionalTextEdit near the cursor.
523 /// This is a clangd extension. (LSP says this is for unrelated text only).
524 /// textDocument.completion.editsNearCursor
525 bool CompletionFixes = false;
526
527 /// Client supports displaying a container string for results of
528 /// textDocument/reference (clangd extension)
529 bool ReferenceContainer = false;
530
531 /// Client supports hierarchical document symbols.
532 /// textDocument.documentSymbol.hierarchicalDocumentSymbolSupport
534
535 /// Client supports signature help.
536 /// textDocument.signatureHelp
537 bool HasSignatureHelp = false;
538
539 /// Client signals that it only supports folding complete lines.
540 /// Client will ignore specified `startCharacter` and `endCharacter`
541 /// properties in a FoldingRange.
542 /// textDocument.foldingRange.lineFoldingOnly
543 bool LineFoldingOnly = false;
544
545 /// Client supports processing label offsets instead of a simple label string.
546 /// textDocument.signatureHelp.signatureInformation.parameterInformation.labelOffsetSupport
548
549 /// The documentation format that should be used for
550 /// textDocument/signatureHelp.
551 /// textDocument.signatureHelp.signatureInformation.documentationFormat
553
554 /// The supported set of CompletionItemKinds for textDocument/completion.
555 /// textDocument.completion.completionItemKind.valueSet
556 std::optional<CompletionItemKindBitset> CompletionItemKinds;
557
558 /// The documentation format that should be used for textDocument/completion.
559 /// textDocument.completion.completionItem.documentationFormat
561
562 /// Client supports CodeAction return value for textDocument/codeAction.
563 /// textDocument.codeAction.codeActionLiteralSupport.
565
566 /// Client advertises support for the semanticTokens feature.
567 /// We support the textDocument/semanticTokens request in any case.
568 /// textDocument.semanticTokens
569 bool SemanticTokens = false;
570 /// Client supports Theia semantic highlighting extension.
571 /// https://github.com/microsoft/vscode-languageserver-node/pull/367
572 /// clangd no longer supports this, we detect it just to log a warning.
573 /// textDocument.semanticHighlightingCapabilities.semanticHighlighting
575
576 /// Supported encodings for LSP character offsets. (clangd extension).
577 std::optional<std::vector<OffsetEncoding>> offsetEncoding;
578
579 /// The content format that should be used for Hover requests.
580 /// textDocument.hover.contentEncoding
582
583 /// The client supports testing for validity of rename operations
584 /// before execution.
586
587 /// The client supports progress notifications.
588 /// window.workDoneProgress
589 bool WorkDoneProgress = false;
590
591 /// The client supports implicit $/progress work-done progress streams,
592 /// without a preceding window/workDoneProgress/create.
593 /// This is a clangd extension.
594 /// window.implicitWorkDoneProgressCreate
596
597 /// Whether the client claims to cancel stale requests.
598 /// general.staleRequestSupport.cancel
600
601 /// Whether the client implementation supports a refresh request sent from the
602 /// server to the client.
604
605 /// The client supports versioned document changes for WorkspaceEdit.
606 bool DocumentChanges = false;
607
608 /// The client supports change annotations on text edits,
609 bool ChangeAnnotation = false;
610
611 /// Whether the client supports the textDocument/inactiveRegions
612 /// notification. This is a clangd extension.
613 bool InactiveRegions = false;
614
616};
617bool fromJSON(const llvm::json::Value &, ClientCapabilities &,
618 llvm::json::Path);
619
620/// Clangd extension that's used in the 'compilationDatabaseChanges' in
621/// workspace/didChangeConfiguration to record updates to the in-memory
622/// compilation database.
624 std::string workingDirectory;
625 std::vector<std::string> compilationCommand;
626};
627bool fromJSON(const llvm::json::Value &, ClangdCompileCommand &,
628 llvm::json::Path);
629
630/// Clangd extension: parameters configurable at any time, via the
631/// `workspace/didChangeConfiguration` notification.
632/// LSP defines this type as `any`.
634 // Changes to the in-memory compilation database.
635 // The key of the map is a file name.
636 std::map<std::string, ClangdCompileCommand> compilationDatabaseChanges;
637};
638bool fromJSON(const llvm::json::Value &, ConfigurationSettings &,
639 llvm::json::Path);
640
641/// Clangd extension: parameters configurable at `initialize` time.
642/// LSP defines this type as `any`.
644 // What we can change throught the didChangeConfiguration request, we can
645 // also set through the initialize request (initializationOptions field).
647
648 std::optional<std::string> compilationDatabasePath;
649 // Additional flags to be included in the "fallback command" used when
650 // the compilation database doesn't describe an opened file.
651 // The command used will be approximately `clang $FILE $fallbackFlags`.
652 std::vector<std::string> fallbackFlags;
653
654 /// Clients supports show file status for textDocument/clangd.fileStatus.
655 bool FileStatus = false;
656};
657bool fromJSON(const llvm::json::Value &, InitializationOptions &,
658 llvm::json::Path);
659
661 /// The process Id of the parent process that started
662 /// the server. Is null if the process has not been started by another
663 /// process. If the parent process is not alive then the server should exit
664 /// (see exit notification) its process.
665 std::optional<int> processId;
666
667 /// The rootPath of the workspace. Is null
668 /// if no folder is open.
669 ///
670 /// deprecated, in favour of rootUri.
671 std::optional<std::string> rootPath;
672
673 /// The rootUri of the workspace. Is null if no
674 /// folder is open. If both `rootPath` and `rootUri` are set
675 /// `rootUri` wins.
676 std::optional<URIForFile> rootUri;
677
678 // User provided initialization options.
679 // initializationOptions?: any;
680
681 /// The capabilities provided by the client (editor or tool)
683 /// The same data as capabilities, but not parsed (to expose to modules).
684 llvm::json::Object rawCapabilities;
685
686 /// The initial trace setting. If omitted trace is disabled ('off').
687 std::optional<TraceLevel> trace;
688
689 /// User-provided initialization options.
691};
692bool fromJSON(const llvm::json::Value &, InitializeParams &, llvm::json::Path);
693
695 /// The token to be used to report progress.
696 llvm::json::Value token = nullptr;
697};
698llvm::json::Value toJSON(const WorkDoneProgressCreateParams &P);
699
700template <typename T> struct ProgressParams {
701 /// The progress token provided by the client or server.
702 llvm::json::Value token = nullptr;
703
704 /// The progress data.
706};
707template <typename T> llvm::json::Value toJSON(const ProgressParams<T> &P) {
708 return llvm::json::Object{{"token", P.token}, {"value", P.value}};
709}
710/// To start progress reporting a $/progress notification with the following
711/// payload must be sent.
713 /// Mandatory title of the progress operation. Used to briefly inform about
714 /// the kind of operation being performed.
715 ///
716 /// Examples: "Indexing" or "Linking dependencies".
717 std::string title;
718
719 /// Controls if a cancel button should show to allow the user to cancel the
720 /// long-running operation. Clients that don't support cancellation are
721 /// allowed to ignore the setting.
722 bool cancellable = false;
723
724 /// Optional progress percentage to display (value 100 is considered 100%).
725 /// If not provided infinite progress is assumed and clients are allowed
726 /// to ignore the `percentage` value in subsequent in report notifications.
727 ///
728 /// The value should be steadily rising. Clients are free to ignore values
729 /// that are not following this rule.
730 ///
731 /// Clangd implementation note: we only send nonzero percentages in
732 /// the WorkProgressReport. 'true' here means percentages will be used.
733 bool percentage = false;
734};
735llvm::json::Value toJSON(const WorkDoneProgressBegin &);
736
737/// Reporting progress is done using the following payload.
739 /// Mandatory title of the progress operation. Used to briefly inform about
740 /// the kind of operation being performed.
741 ///
742 /// Examples: "Indexing" or "Linking dependencies".
743 std::string title;
744
745 /// Controls enablement state of a cancel button. This property is only valid
746 /// if a cancel button got requested in the `WorkDoneProgressStart` payload.
747 ///
748 /// Clients that don't support cancellation or don't support control
749 /// the button's enablement state are allowed to ignore the setting.
750 std::optional<bool> cancellable;
751
752 /// Optional, more detailed associated progress message. Contains
753 /// complementary information to the `title`.
754 ///
755 /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
756 /// If unset, the previous progress message (if any) is still valid.
757 std::optional<std::string> message;
758
759 /// Optional progress percentage to display (value 100 is considered 100%).
760 /// If not provided infinite progress is assumed and clients are allowed
761 /// to ignore the `percentage` value in subsequent in report notifications.
762 ///
763 /// The value should be steadily rising. Clients are free to ignore values
764 /// that are not following this rule.
765 std::optional<unsigned> percentage;
766};
767llvm::json::Value toJSON(const WorkDoneProgressReport &);
768//
769/// Signals the end of progress reporting.
771 /// Optional, a final message indicating to for example indicate the outcome
772 /// of the operation.
773 std::optional<std::string> message;
774};
775llvm::json::Value toJSON(const WorkDoneProgressEnd &);
776
777enum class MessageType {
778 /// An error message.
779 Error = 1,
780 /// A warning message.
782 /// An information message.
783 Info = 3,
784 /// A log message.
785 Log = 4,
786};
787llvm::json::Value toJSON(const MessageType &);
788
789/// The show message notification is sent from a server to a client to ask the
790/// client to display a particular message in the user interface.
792 /// The message type.
794 /// The actual message.
795 std::string message;
796};
797llvm::json::Value toJSON(const ShowMessageParams &);
798
800 /// The document that was opened.
802};
803bool fromJSON(const llvm::json::Value &, DidOpenTextDocumentParams &,
804 llvm::json::Path);
805
807 /// The document that was closed.
809};
810bool fromJSON(const llvm::json::Value &, DidCloseTextDocumentParams &,
811 llvm::json::Path);
812
814 /// The document that was saved.
816};
817bool fromJSON(const llvm::json::Value &, DidSaveTextDocumentParams &,
818 llvm::json::Path);
819
821 /// The range of the document that changed.
822 std::optional<Range> range;
823
824 /// The length of the range that got replaced.
825 std::optional<int> rangeLength;
826
827 /// The new text of the range/document.
828 std::string text;
829};
830bool fromJSON(const llvm::json::Value &, TextDocumentContentChangeEvent &,
831 llvm::json::Path);
832
834 /// The document that did change. The version number points
835 /// to the version after all provided content changes have
836 /// been applied.
838
839 /// The actual content changes.
840 std::vector<TextDocumentContentChangeEvent> contentChanges;
841
842 /// Forces diagnostics to be generated, or to not be generated, for this
843 /// version of the file. If not set, diagnostics are eventually consistent:
844 /// either they will be provided for this version or some subsequent one.
845 /// This is a clangd extension.
846 std::optional<bool> wantDiagnostics;
847
848 /// Force a complete rebuild of the file, ignoring all cached state. Slow!
849 /// This is useful to defeat clangd's assumption that missing headers will
850 /// stay missing.
851 /// This is a clangd extension.
852 bool forceRebuild = false;
853};
854bool fromJSON(const llvm::json::Value &, DidChangeTextDocumentParams &,
855 llvm::json::Path);
856
857enum class FileChangeType {
858 /// The file got created.
860 /// The file got changed.
862 /// The file got deleted.
864};
865bool fromJSON(const llvm::json::Value &E, FileChangeType &Out,
866 llvm::json::Path);
867
868struct FileEvent {
869 /// The file's URI.
871 /// The change type.
873};
874bool fromJSON(const llvm::json::Value &, FileEvent &, llvm::json::Path);
875
877 /// The actual file events.
878 std::vector<FileEvent> changes;
879};
880bool fromJSON(const llvm::json::Value &, DidChangeWatchedFilesParams &,
881 llvm::json::Path);
882
886bool fromJSON(const llvm::json::Value &, DidChangeConfigurationParams &,
887 llvm::json::Path);
888
889// Note: we do not parse FormattingOptions for *FormattingParams.
890// In general, we use a clang-format style detected from common mechanisms
891// (.clang-format files and the -fallback-style flag).
892// It would be possible to override these with FormatOptions, but:
893// - the protocol makes FormatOptions mandatory, so many clients set them to
894// useless values, and we can't tell when to respect them
895// - we also format in other places, where FormatOptions aren't available.
896
898 /// The document to format.
900
901 /// The range to format
903};
904bool fromJSON(const llvm::json::Value &, DocumentRangeFormattingParams &,
905 llvm::json::Path);
906
908 /// The document to format.
910
911 /// The position at which this request was sent.
913
914 /// The character that has been typed.
915 std::string ch;
916};
917bool fromJSON(const llvm::json::Value &, DocumentOnTypeFormattingParams &,
918 llvm::json::Path);
919
921 /// The document to format.
923};
924bool fromJSON(const llvm::json::Value &, DocumentFormattingParams &,
925 llvm::json::Path);
926
928 // The text document to find symbols in.
930};
931bool fromJSON(const llvm::json::Value &, DocumentSymbolParams &,
932 llvm::json::Path);
933
934/// Represents a related message and source code location for a diagnostic.
935/// This should be used to point to code locations that cause or related to a
936/// diagnostics, e.g when duplicating a symbol in a scope.
938 /// The location of this related diagnostic information.
940 /// The message of this related diagnostic information.
941 std::string message;
942};
943llvm::json::Value toJSON(const DiagnosticRelatedInformation &);
944
946 /// Unused or unnecessary code.
947 ///
948 /// Clients are allowed to render diagnostics with this tag faded out instead
949 /// of having an error squiggle.
951 /// Deprecated or obsolete code.
952 ///
953 /// Clients are allowed to rendered diagnostics with this tag strike through.
955};
956llvm::json::Value toJSON(DiagnosticTag Tag);
957
958/// Structure to capture a description for an error code.
960 /// An URI to open with more information about the diagnostic error.
961 std::string href;
962};
963llvm::json::Value toJSON(const CodeDescription &);
964
965struct CodeAction;
967 /// The range at which the message applies.
969
970 /// The diagnostic's severity. Can be omitted. If omitted it is up to the
971 /// client to interpret diagnostics as error, warning, info or hint.
972 int severity = 0;
973
974 /// The diagnostic's code. Can be omitted.
975 std::string code;
976
977 /// An optional property to describe the error code.
978 std::optional<CodeDescription> codeDescription;
979
980 /// A human-readable string describing the source of this
981 /// diagnostic, e.g. 'typescript' or 'super lint'.
982 std::string source;
983
984 /// The diagnostic's message.
985 std::string message;
986
987 /// Additional metadata about the diagnostic.
988 llvm::SmallVector<DiagnosticTag, 1> tags;
989
990 /// An array of related diagnostic information, e.g. when symbol-names within
991 /// a scope collide all definitions can be marked via this property.
992 std::optional<std::vector<DiagnosticRelatedInformation>> relatedInformation;
993
994 /// The diagnostic's category. Can be omitted.
995 /// An LSP extension that's used to send the name of the category over to the
996 /// client. The category typically describes the compilation stage during
997 /// which the issue was produced, e.g. "Semantic Issue" or "Parse Issue".
998 std::optional<std::string> category;
999
1000 /// Clangd extension: code actions related to this diagnostic.
1001 /// Only with capability textDocument.publishDiagnostics.codeActionsInline.
1002 /// (These actions can also be obtained using textDocument/codeAction).
1003 std::optional<std::vector<CodeAction>> codeActions;
1004
1005 /// A data entry field that is preserved between a
1006 /// `textDocument/publishDiagnostics` notification
1007 /// and `textDocument/codeAction` request.
1008 /// Mutating users should associate their data with a unique key they can use
1009 /// to retrieve later on.
1010 llvm::json::Object data;
1011};
1012llvm::json::Value toJSON(const Diagnostic &);
1013
1014/// A LSP-specific comparator used to find diagnostic in a container like
1015/// std:map.
1016/// We only use the required fields of Diagnostic to do the comparison to avoid
1017/// any regression issues from LSP clients (e.g. VScode), see
1018/// https://git.io/vbr29
1020 bool operator()(const Diagnostic &LHS, const Diagnostic &RHS) const {
1021 return std::tie(LHS.range, LHS.message) < std::tie(RHS.range, RHS.message);
1022 }
1023};
1024bool fromJSON(const llvm::json::Value &, Diagnostic &, llvm::json::Path);
1025llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Diagnostic &);
1026
1028 /// The URI for which diagnostic information is reported.
1030 /// An array of diagnostic information items.
1031 std::vector<Diagnostic> diagnostics;
1032 /// The version number of the document the diagnostics are published for.
1033 std::optional<int64_t> version;
1034};
1035llvm::json::Value toJSON(const PublishDiagnosticsParams &);
1036
1038 /// An array of diagnostics known on the client side overlapping the range
1039 /// provided to the `textDocument/codeAction` request. They are provided so
1040 /// that the server knows which errors are currently presented to the user for
1041 /// the given range. There is no guarantee that these accurately reflect the
1042 /// error state of the resource. The primary parameter to compute code actions
1043 /// is the provided range.
1044 std::vector<Diagnostic> diagnostics;
1045
1046 /// Requested kind of actions to return.
1047 ///
1048 /// Actions not of this kind are filtered out by the client before being
1049 /// shown. So servers can omit computing them.
1050 std::vector<std::string> only;
1051};
1052bool fromJSON(const llvm::json::Value &, CodeActionContext &, llvm::json::Path);
1053
1055 /// The document in which the command was invoked.
1057
1058 /// The range for which the command was invoked.
1060
1061 /// Context carrying additional information.
1063};
1064bool fromJSON(const llvm::json::Value &, CodeActionParams &, llvm::json::Path);
1065
1066/// The edit should either provide changes or documentChanges. If the client
1067/// can handle versioned document edits and if documentChanges are present,
1068/// the latter are preferred over changes.
1070 /// Holds changes to existing resources.
1071 std::optional<std::map<std::string, std::vector<TextEdit>>> changes;
1072 /// Document changes including text edits and resource operations.
1073 ///
1074 /// If a client supports `workspace.workspaceEdit.resourceOperations`, this
1075 /// can contain TextDocumentEdit, CreateFile, RenameFile, and DeleteFile
1076 /// operations. Otherwise, only TextDocumentEdit is supported.
1077 std::optional<std::vector<DocumentChange>> documentChanges;
1078
1079 /// A map of change annotations that can be referenced in
1080 /// AnnotatedTextEdit.
1081 std::map<std::string, ChangeAnnotation> changeAnnotations;
1082};
1083bool fromJSON(const llvm::json::Value &, WorkspaceEdit &, llvm::json::Path);
1084llvm::json::Value toJSON(const WorkspaceEdit &WE);
1085
1086/// Arguments for the 'applyTweak' command. The server sends these commands as a
1087/// response to the textDocument/codeAction request. The client can later send a
1088/// command back to the server if the user requests to execute a particular code
1089/// tweak.
1091 /// A file provided by the client on a textDocument/codeAction request.
1093 /// A selection provided by the client on a textDocument/codeAction request.
1095 /// ID of the tweak that should be executed. Corresponds to Tweak::id().
1096 std::string tweakID;
1097};
1098bool fromJSON(const llvm::json::Value &, TweakArgs &, llvm::json::Path);
1099llvm::json::Value toJSON(const TweakArgs &A);
1100
1102 /// The identifier of the actual command handler.
1103 std::string command;
1104
1105 // This is `arguments?: []any` in LSP.
1106 // All clangd's commands accept a single argument (or none => null).
1107 llvm::json::Value argument = nullptr;
1108};
1109bool fromJSON(const llvm::json::Value &, ExecuteCommandParams &,
1110 llvm::json::Path);
1111
1113 std::string title;
1114};
1115llvm::json::Value toJSON(const Command &C);
1116
1117/// A code action represents a change that can be performed in code, e.g. to fix
1118/// a problem or to refactor code.
1119///
1120/// A CodeAction must set either `edit` and/or a `command`. If both are
1121/// supplied, the `edit` is applied first, then the `command` is executed.
1123 /// A short, human-readable, title for this code action.
1124 std::string title;
1125
1126 /// The kind of the code action.
1127 /// Used to filter code actions.
1128 std::optional<std::string> kind;
1129 const static llvm::StringLiteral QUICKFIX_KIND;
1130 const static llvm::StringLiteral REFACTOR_KIND;
1131 const static llvm::StringLiteral REFACTOR_REWRITE_KIND;
1132 const static llvm::StringLiteral INFO_KIND;
1133
1134 /// The diagnostics that this code action resolves.
1135 std::optional<std::vector<Diagnostic>> diagnostics;
1136
1137 /// Marks this as a preferred action. Preferred actions are used by the
1138 /// `auto fix` command and can be targeted by keybindings.
1139 /// A quick fix should be marked preferred if it properly addresses the
1140 /// underlying error. A refactoring should be marked preferred if it is the
1141 /// most reasonable choice of actions to take.
1142 bool isPreferred = false;
1143
1144 /// The workspace edit this code action performs.
1145 std::optional<WorkspaceEdit> edit;
1146
1147 /// A command this code action executes. If a code action provides an edit
1148 /// and a command, first the edit is executed and then the command.
1149 std::optional<Command> command;
1150
1151 /// A data entry field that is preserved on a code action between a
1152 /// `textDocument/codeAction` and a `codeAction/resolve` request.
1153 /// @since LSP 3.16.0
1154 std::optional<llvm::json::Value> data;
1155};
1156llvm::json::Value toJSON(const CodeAction &);
1157bool fromJSON(const llvm::json::Value &, CodeAction &, llvm::json::Path);
1158
1159/// Represents programming constructs like variables, classes, interfaces etc.
1160/// that appear in a document. Document symbols can be hierarchical and they
1161/// have two ranges: one that encloses its definition and one that points to its
1162/// most interesting range, e.g. the range of an identifier.
1164 /// The name of this symbol.
1165 std::string name;
1166
1167 /// More detail for this symbol, e.g the signature of a function.
1168 std::string detail;
1169
1170 /// The kind of this symbol.
1172
1173 /// Indicates if this symbol is deprecated.
1174 bool deprecated = false;
1175
1176 /// The range enclosing this symbol not including leading/trailing whitespace
1177 /// but everything else like comments. This information is typically used to
1178 /// determine if the clients cursor is inside the symbol to reveal in the
1179 /// symbol in the UI.
1181
1182 /// The range that should be selected and revealed when this symbol is being
1183 /// picked, e.g the name of a function. Must be contained by the `range`.
1185
1186 /// Children of this symbol, e.g. properties of a class.
1187 std::vector<DocumentSymbol> children;
1188};
1189llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S);
1190llvm::json::Value toJSON(const DocumentSymbol &S);
1191
1192/// Represents information about programming constructs like variables, classes,
1193/// interfaces etc.
1195 /// The name of this symbol.
1196 std::string name;
1197
1198 /// The kind of this symbol.
1200
1201 /// The location of this symbol.
1203
1204 /// The name of the symbol containing this symbol.
1205 std::string containerName;
1206
1207 /// The score that clangd calculates to rank the returned symbols.
1208 /// This excludes the fuzzy-matching score between `name` and the query.
1209 /// (Specifically, the last ::-separated component).
1210 /// This can be used to re-rank results as the user types, using client-side
1211 /// fuzzy-matching (that score should be multiplied with this one).
1212 /// This is a clangd extension, set only for workspace/symbol responses.
1213 std::optional<float> score;
1214};
1215llvm::json::Value toJSON(const SymbolInformation &);
1216llvm::raw_ostream &operator<<(llvm::raw_ostream &, const SymbolInformation &);
1217
1218/// The parameters of a Workspace Symbol Request.
1220 /// A query string to filter symbols by.
1221 /// Clients may send an empty string here to request all the symbols.
1222 std::string query;
1223
1224 /// Max results to return, overriding global default. 0 means no limit.
1225 /// Clangd extension.
1226 std::optional<int> limit;
1227};
1228bool fromJSON(const llvm::json::Value &, WorkspaceSymbolParams &,
1229 llvm::json::Path);
1230
1234llvm::json::Value toJSON(const ApplyWorkspaceEditParams &);
1235
1237 bool applied = true;
1238 std::optional<std::string> failureReason;
1239};
1240bool fromJSON(const llvm::json::Value &, ApplyWorkspaceEditResponse &,
1241 llvm::json::Path);
1242
1243/// Parameters for the `window/showDocument` request.
1244/// @since LSP 3.16.0
1246 /// The document URI to show (for file:// URIs).
1248
1249 /// External URI string (for https:// or other non-file URIs).
1250 /// When set, this takes precedence over `uri` in serialization.
1251 std::optional<std::string> externalUri;
1252
1253 /// Indicates to show the resource in an external program.
1254 /// To show, for example, `https://noogle.dev/` in the default web browser,
1255 /// set `external` to `true`.
1256 std::optional<bool> external;
1257
1258 /// An optional property to indicate whether the editor showing the document
1259 /// should take focus or not. Clients might ignore this property if an
1260 /// external program is started.
1261 std::optional<bool> takeFocus;
1262
1263 /// An optional selection range if the document is a text document.
1264 /// Clients might ignore the property if an external program is started or
1265 /// the file is not a text file.
1266 std::optional<Range> selection;
1267};
1268llvm::json::Value toJSON(const ShowDocumentParams &);
1269
1270/// Result of the `window/showDocument` request.
1271/// @since LSP 3.16.0
1273 /// A boolean indicating if the show was successful.
1274 bool success = false;
1275};
1276bool fromJSON(const llvm::json::Value &, ShowDocumentResult &,
1277 llvm::json::Path);
1278
1280 /// The text document.
1282
1283 /// The position inside the text document.
1285};
1286bool fromJSON(const llvm::json::Value &, TextDocumentPositionParams &,
1287 llvm::json::Path);
1288
1290 /// Completion was triggered by typing an identifier (24x7 code
1291 /// complete), manual invocation (e.g Ctrl+Space) or via API.
1293 /// Completion was triggered by a trigger character specified by
1294 /// the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
1296 /// Completion was re-triggered as the current completion list is incomplete.
1298};
1299
1301 /// How the completion was triggered.
1303 /// The trigger character (a single character) that has trigger code complete.
1304 /// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
1305 std::string triggerCharacter;
1306};
1307bool fromJSON(const llvm::json::Value &, CompletionContext &, llvm::json::Path);
1308
1311
1312 /// Max results to return, overriding global default. 0 means no limit.
1313 /// Clangd extension.
1314 std::optional<int> limit;
1315};
1316bool fromJSON(const llvm::json::Value &, CompletionParams &, llvm::json::Path);
1317
1322llvm::json::Value toJSON(const MarkupContent &MC);
1323bool fromJSON(const llvm::json::Value &, MarkupContent &, llvm::json::Path);
1324
1325struct Hover {
1326 /// The hover's content
1328
1329 /// An optional range is a range inside a text document
1330 /// that is used to visualize a hover, e.g. by changing the background color.
1331 std::optional<Range> range;
1332};
1333llvm::json::Value toJSON(const Hover &H);
1334
1335/// Defines whether the insert text in a completion item should be interpreted
1336/// as plain text or a snippet.
1339 /// The primary text to be inserted is treated as a plain string.
1341 /// The primary text to be inserted is treated as a snippet.
1342 ///
1343 /// A snippet can define tab stops and placeholders with `$1`, `$2`
1344 /// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end
1345 /// of the snippet. Placeholders with equal identifiers are linked, that is
1346 /// typing in one will update others too.
1347 ///
1348 /// See also:
1349 /// https://github.com/Microsoft/vscode/blob/main/src/vs/editor/contrib/snippet/snippet.md
1351};
1352
1354 /// The label of this completion item. By default also the text that is
1355 /// inserted when selecting this completion.
1356 std::string label;
1357
1358 /// The kind of this completion item. Based of the kind an icon is chosen by
1359 /// the editor.
1361
1362 /// A human-readable string with additional information about this item, like
1363 /// type or symbol information.
1364 std::string detail;
1365
1366 /// A human-readable string that represents a doc-comment.
1367 std::optional<MarkupContent> documentation;
1368
1369 /// A string that should be used when comparing this item with other items.
1370 /// When `falsy` the label is used.
1371 std::string sortText;
1372
1373 /// A string that should be used when filtering a set of completion items.
1374 /// When `falsy` the label is used.
1375 std::string filterText;
1376
1377 /// A string that should be inserted to a document when selecting this
1378 /// completion. When `falsy` the label is used.
1379 std::string insertText;
1380
1381 /// The format of the insert text. The format applies to both the `insertText`
1382 /// property and the `newText` property of a provided `textEdit`.
1384
1385 /// An edit which is applied to a document when selecting this completion.
1386 /// When an edit is provided `insertText` is ignored.
1387 ///
1388 /// Note: The range of the edit must be a single line range and it must
1389 /// contain the position at which completion has been requested.
1390 std::optional<TextEdit> textEdit;
1391
1392 /// An optional array of additional text edits that are applied when selecting
1393 /// this completion. Edits must not overlap with the main edit nor with
1394 /// themselves.
1395 std::vector<TextEdit> additionalTextEdits;
1396
1397 /// Indicates if this item is deprecated.
1398 bool deprecated = false;
1399
1400 /// The score that clangd calculates to rank the returned completions.
1401 /// This excludes the fuzzy-match between `filterText` and the partial word.
1402 /// This can be used to re-rank results as the user types, using client-side
1403 /// fuzzy-matching (that score should be multiplied with this one).
1404 /// This is a clangd extension.
1405 float score = 0.f;
1406
1407 // TODO: Add custom commitCharacters for some of the completion items. For
1408 // example, it makes sense to use () only for the functions.
1409 // TODO(krasimir): The following optional fields defined by the language
1410 // server protocol are unsupported:
1411 //
1412 // data?: any - A data entry field that is preserved on a completion item
1413 // between a completion and a completion resolve request.
1414 std::string data;
1415};
1416llvm::json::Value toJSON(const CompletionItem &);
1417bool fromJSON(const llvm::json::Value &, CompletionItem &, llvm::json::Path);
1418llvm::raw_ostream &operator<<(llvm::raw_ostream &, const CompletionItem &);
1419
1420bool operator<(const CompletionItem &, const CompletionItem &);
1421
1422/// Represents a collection of completion items to be presented in the editor.
1424 /// The list is not complete. Further typing should result in recomputing the
1425 /// list.
1426 bool isIncomplete = false;
1427
1428 /// The completion items.
1429 std::vector<CompletionItem> items;
1430};
1431llvm::json::Value toJSON(const CompletionList &);
1432
1433/// A single parameter of a particular signature.
1435
1436 /// The label of this parameter. Ignored when labelOffsets is set.
1437 std::string labelString;
1438
1439 /// Inclusive start and exclusive end offsets withing the containing signature
1440 /// label.
1441 /// Offsets are computed by lspLength(), which counts UTF-16 code units by
1442 /// default but that can be overriden, see its documentation for details.
1443 std::optional<std::pair<unsigned, unsigned>> labelOffsets;
1444
1445 /// The documentation of this parameter. Optional.
1446 std::string documentation;
1447};
1448llvm::json::Value toJSON(const ParameterInformation &);
1449
1450/// Represents the signature of something callable.
1452
1453 /// The label of this signature. Mandatory.
1454 std::string label;
1455
1456 /// The documentation of this signature. Optional.
1458
1459 /// The parameters of this signature.
1460 std::vector<ParameterInformation> parameters;
1461};
1462llvm::json::Value toJSON(const SignatureInformation &);
1463llvm::raw_ostream &operator<<(llvm::raw_ostream &,
1464 const SignatureInformation &);
1465
1466/// Represents the signature of a callable.
1468
1469 /// The resulting signatures.
1470 std::vector<SignatureInformation> signatures;
1471
1472 /// The active signature.
1474
1475 /// The active parameter of the active signature.
1477
1478 /// Position of the start of the argument list, including opening paren. e.g.
1479 /// foo("first arg", "second arg",
1480 /// ^-argListStart ^-cursor
1481 /// This is a clangd-specific extension, it is only available via C++ API and
1482 /// not currently serialized for the LSP.
1484};
1485llvm::json::Value toJSON(const SignatureHelp &);
1486
1488 /// The document that was opened.
1490
1491 /// The position at which this request was sent.
1493
1494 /// The new name of the symbol.
1495 std::string newName;
1496};
1497bool fromJSON(const llvm::json::Value &, RenameParams &, llvm::json::Path);
1498
1499enum class DocumentHighlightKind { Text = 1, Read = 2, Write = 3 };
1500
1501/// A document highlight is a range inside a text document which deserves
1502/// special attention. Usually a document highlight is visualized by changing
1503/// the background color of its range.
1504
1506 /// The range this highlight applies to.
1508
1509 /// The highlight kind, default is DocumentHighlightKind.Text.
1511
1512 friend bool operator<(const DocumentHighlight &LHS,
1513 const DocumentHighlight &RHS) {
1514 int LHSKind = static_cast<int>(LHS.kind);
1515 int RHSKind = static_cast<int>(RHS.kind);
1516 return std::tie(LHS.range, LHSKind) < std::tie(RHS.range, RHSKind);
1517 }
1518
1519 friend bool operator==(const DocumentHighlight &LHS,
1520 const DocumentHighlight &RHS) {
1521 return LHS.kind == RHS.kind && LHS.range == RHS.range;
1522 }
1523};
1524llvm::json::Value toJSON(const DocumentHighlight &DH);
1525llvm::raw_ostream &operator<<(llvm::raw_ostream &, const DocumentHighlight &);
1526
1527enum class TypeHierarchyDirection { Children = 0, Parents = 1, Both = 2 };
1528bool fromJSON(const llvm::json::Value &E, TypeHierarchyDirection &Out,
1529 llvm::json::Path);
1530
1531/// The type hierarchy params is an extension of the
1532/// `TextDocumentPositionsParams` with optional properties which can be used to
1533/// eagerly resolve the item when requesting from the server.
1535 /// The hierarchy levels to resolve. `0` indicates no level.
1536 /// This is a clangd extension.
1537 int resolve = 0;
1538
1539 /// The direction of the hierarchy levels to resolve.
1540 /// This is a clangd extension.
1542};
1543bool fromJSON(const llvm::json::Value &, TypeHierarchyPrepareParams &,
1544 llvm::json::Path);
1545
1547 /// The name of this item.
1548 std::string name;
1549
1550 /// The kind of this item.
1552
1553 /// More detail for this item, e.g. the signature of a function.
1554 std::optional<std::string> detail;
1555
1556 /// The resource identifier of this item.
1558
1559 /// The range enclosing this symbol not including leading/trailing whitespace
1560 /// but everything else, e.g. comments and code.
1562
1563 /// The range that should be selected and revealed when this symbol is being
1564 /// picked, e.g. the name of a function. Must be contained by the `range`.
1566
1567 /// Used to resolve a client provided item back.
1569 /// std::nullopt means parents aren't resolved and empty is no parents.
1570 std::optional<std::vector<ResolveParams>> parents;
1571 };
1572 /// A data entry field that is preserved between a type hierarchy prepare and
1573 /// supertypes or subtypes requests. It could also be used to identify the
1574 /// type hierarchy in the server, helping improve the performance on resolving
1575 /// supertypes and subtypes.
1577
1578 /// `true` if the hierarchy item is deprecated. Otherwise, `false`.
1579 /// This is a clangd exntesion.
1580 bool deprecated = false;
1581
1582 /// This is a clangd exntesion.
1583 std::optional<std::vector<TypeHierarchyItem>> parents;
1584
1585 /// If this type hierarchy item is resolved, it contains the direct children
1586 /// of the current item. Could be empty if the item does not have any
1587 /// descendants. If not defined, the children have not been resolved.
1588 /// This is a clangd exntesion.
1589 std::optional<std::vector<TypeHierarchyItem>> children;
1590};
1591llvm::json::Value toJSON(const TypeHierarchyItem::ResolveParams &);
1593llvm::json::Value toJSON(const TypeHierarchyItem &);
1594llvm::raw_ostream &operator<<(llvm::raw_ostream &, const TypeHierarchyItem &);
1595bool fromJSON(const llvm::json::Value &, TypeHierarchyItem &, llvm::json::Path);
1596
1597/// Parameters for the `typeHierarchy/resolve` request.
1599 /// The item to resolve.
1601
1602 /// The hierarchy levels to resolve. `0` indicates no level.
1604
1605 /// The direction of the hierarchy levels to resolve.
1607};
1608bool fromJSON(const llvm::json::Value &, ResolveTypeHierarchyItemParams &,
1609 llvm::json::Path);
1610
1611enum class SymbolTag { Deprecated = 1 };
1612llvm::json::Value toJSON(SymbolTag);
1613
1614/// The parameter of a `textDocument/prepareCallHierarchy` request.
1616
1617/// Represents programming constructs like functions or constructors
1618/// in the context of call hierarchy.
1620 /// The name of this item.
1621 std::string name;
1622
1623 /// The kind of this item.
1625
1626 /// Tags for this item.
1627 std::vector<SymbolTag> tags;
1628
1629 /// More detaill for this item, e.g. the signature of a function.
1630 std::string detail;
1631
1632 /// The resource identifier of this item.
1634
1635 /// The range enclosing this symbol not including leading / trailing
1636 /// whitespace but everything else, e.g. comments and code.
1638
1639 /// The range that should be selected and revealed when this symbol
1640 /// is being picked, e.g. the name of a function.
1641 /// Must be contained by `Rng`.
1643
1644 /// An optional 'data' field, which can be used to identify a call
1645 /// hierarchy item in an incomingCalls or outgoingCalls request.
1646 std::string data;
1647};
1648llvm::json::Value toJSON(const CallHierarchyItem &);
1649bool fromJSON(const llvm::json::Value &, CallHierarchyItem &, llvm::json::Path);
1650
1651/// The parameter of a `callHierarchy/incomingCalls` request.
1655bool fromJSON(const llvm::json::Value &, CallHierarchyIncomingCallsParams &,
1656 llvm::json::Path);
1657
1658/// Represents an incoming call, e.g. a caller of a method or constructor.
1660 /// The item that makes the call.
1662
1663 /// The range at which the calls appear.
1664 /// This is relative to the caller denoted by `From`.
1665 std::vector<Range> fromRanges;
1666};
1667llvm::json::Value toJSON(const CallHierarchyIncomingCall &);
1668
1669/// The parameter of a `callHierarchy/outgoingCalls` request.
1673bool fromJSON(const llvm::json::Value &, CallHierarchyOutgoingCallsParams &,
1674 llvm::json::Path);
1675
1676/// Represents an outgoing call, e.g. calling a getter from a method or
1677/// a method from a constructor etc.
1679 /// The item that is called.
1681
1682 /// The range at which this item is called.
1683 /// This is the range relative to the caller, and not `To`.
1684 std::vector<Range> fromRanges;
1685};
1686llvm::json::Value toJSON(const CallHierarchyOutgoingCall &);
1687
1688/// A parameter literal used in inlay hint requests.
1690 /// The text document.
1692
1693 /// The visible document range for which inlay hints should be computed.
1694 ///
1695 /// std::nullopt is a clangd extension, which hints for computing hints on the
1696 /// whole file.
1697 std::optional<Range> range;
1698};
1699bool fromJSON(const llvm::json::Value &, InlayHintsParams &, llvm::json::Path);
1700
1701/// Inlay hint kinds.
1702enum class InlayHintKind {
1703 /// An inlay hint that for a type annotation.
1704 ///
1705 /// An example of a type hint is a hint in this position:
1706 /// auto var ^ = expr;
1707 /// which shows the deduced type of the variable.
1708 Type = 1,
1709
1710 /// An inlay hint that is for a parameter.
1711 ///
1712 /// An example of a parameter hint is a hint in this position:
1713 /// func(^arg);
1714 /// which shows the name of the corresponding parameter.
1716
1717 /// A hint before an element of an aggregate braced initializer list,
1718 /// indicating what it is initializing.
1719 /// Pair{^1, ^2};
1720 /// Uses designator syntax, e.g. `.first:`.
1721 /// This is a clangd extension.
1723
1724 /// Other ideas for hints that are not currently implemented:
1725 ///
1726 /// * Chaining hints, showing the types of intermediate expressions
1727 /// in a chain of function calls.
1728 /// * Hints indicating implicit conversions or implicit constructor calls.
1729};
1730llvm::json::Value toJSON(const InlayHintKind &);
1731
1732/// Inlay hint information.
1734 /// The position of this hint.
1736
1737 /// The label of this hint. A human readable string or an array of
1738 /// InlayHintLabelPart label parts.
1739 ///
1740 /// *Note* that neither the string nor the label part can be empty.
1741 std::string label;
1742
1743 /// The kind of this hint. Can be omitted in which case the client should fall
1744 /// back to a reasonable default.
1746
1747 /// Render padding before the hint.
1748 ///
1749 /// Note: Padding should use the editor's background color, not the
1750 /// background color of the hint itself. That means padding can be used
1751 /// to visually align/separate an inlay hint.
1752 bool paddingLeft = false;
1753
1754 /// Render padding after the hint.
1755 ///
1756 /// Note: Padding should use the editor's background color, not the
1757 /// background color of the hint itself. That means padding can be used
1758 /// to visually align/separate an inlay hint.
1759 bool paddingRight = false;
1760
1761 /// The range of source code to which the hint applies.
1762 ///
1763 /// For example, a parameter hint may have the argument as its range.
1764 /// The range allows clients more flexibility of when/how to display the hint.
1765 /// This is an (unserialized) clangd extension.
1767};
1768llvm::json::Value toJSON(const InlayHint &);
1769bool operator==(const InlayHint &, const InlayHint &);
1770bool operator<(const InlayHint &, const InlayHint &);
1771llvm::raw_ostream &operator<<(llvm::raw_ostream &, InlayHintKind);
1772
1774 /// Include the declaration of the current symbol.
1776};
1777
1781bool fromJSON(const llvm::json::Value &, ReferenceParams &, llvm::json::Path);
1782
1783/// Clangd extension: indicates the current state of the file in clangd,
1784/// sent from server via the `textDocument/clangd.fileStatus` notification.
1786 /// The text document's URI.
1788 /// The human-readable string presents the current state of the file, can be
1789 /// shown in the UI (e.g. status bar).
1790 std::string state;
1791 // FIXME: add detail messages.
1792};
1793llvm::json::Value toJSON(const FileStatus &);
1794
1795/// Specifies a single semantic token in the document.
1796/// This struct is not part of LSP, which just encodes lists of tokens as
1797/// arrays of numbers directly.
1799 /// token line number, relative to the previous token
1800 unsigned deltaLine = 0;
1801 /// token start character, relative to the previous token
1802 /// (relative to 0 or the previous token's start if they are on the same line)
1803 unsigned deltaStart = 0;
1804 /// the length of the token. A token cannot be multiline
1805 unsigned length = 0;
1806 /// will be looked up in `SemanticTokensLegend.tokenTypes`
1807 unsigned tokenType = 0;
1808 /// each set bit will be looked up in `SemanticTokensLegend.tokenModifiers`
1809 unsigned tokenModifiers = 0;
1810};
1811bool operator==(const SemanticToken &, const SemanticToken &);
1812
1813/// A versioned set of tokens.
1815 // An optional result id. If provided and clients support delta updating
1816 // the client will include the result id in the next semantic token request.
1817 // A server can then instead of computing all semantic tokens again simply
1818 // send a delta.
1819 std::string resultId;
1820
1821 /// The actual tokens.
1822 std::vector<SemanticToken> tokens; // encoded as a flat integer array.
1823};
1824llvm::json::Value toJSON(const SemanticTokens &);
1825
1826/// Body of textDocument/semanticTokens/full request.
1828 /// The text document.
1830};
1831bool fromJSON(const llvm::json::Value &, SemanticTokensParams &,
1832 llvm::json::Path);
1833
1834/// Body of textDocument/semanticTokens/full/delta request.
1835/// Requests the changes in semantic tokens since a previous response.
1837 /// The text document.
1839 /// The previous result id.
1840 std::string previousResultId;
1841};
1842bool fromJSON(const llvm::json::Value &Params, SemanticTokensDeltaParams &R,
1843 llvm::json::Path);
1844
1845/// Describes a replacement of a contiguous range of semanticTokens.
1847 // LSP specifies `start` and `deleteCount` which are relative to the array
1848 // encoding of the previous tokens.
1849 // We use token counts instead, and translate when serializing this struct.
1850 unsigned startToken = 0;
1851 unsigned deleteTokens = 0;
1852 std::vector<SemanticToken> tokens; // encoded as a flat integer array
1853};
1854llvm::json::Value toJSON(const SemanticTokensEdit &);
1855
1856/// This models LSP SemanticTokensDelta | SemanticTokens, which is the result of
1857/// textDocument/semanticTokens/full/delta.
1859 std::string resultId;
1860 /// Set if we computed edits relative to a previous set of tokens.
1861 std::optional<std::vector<SemanticTokensEdit>> edits;
1862 /// Set if we computed a fresh set of tokens.
1863 std::optional<std::vector<SemanticToken>> tokens; // encoded as integer array
1864};
1865llvm::json::Value toJSON(const SemanticTokensOrDelta &);
1866
1867/// Parameters for the inactive regions (server-side) push notification.
1868/// This is a clangd extension.
1870 /// The textdocument these inactive regions belong to.
1872 /// The inactive regions that should be sent.
1873 std::vector<Range> InactiveRegions;
1874};
1875llvm::json::Value toJSON(const InactiveRegionsParams &InactiveRegions);
1876
1878 /// The text document.
1880
1881 /// The positions inside the text document.
1882 std::vector<Position> positions;
1883};
1884bool fromJSON(const llvm::json::Value &, SelectionRangeParams &,
1885 llvm::json::Path);
1886
1888 /**
1889 * The range of this selection range.
1890 */
1892 /**
1893 * The parent selection range containing this range. Therefore `parent.range`
1894 * must contain `this.range`.
1895 */
1896 std::unique_ptr<SelectionRange> parent;
1897};
1898llvm::json::Value toJSON(const SelectionRange &);
1899
1900/// Parameters for the document link request.
1902 /// The document to provide document links for.
1904};
1905bool fromJSON(const llvm::json::Value &, DocumentLinkParams &,
1906 llvm::json::Path);
1907
1908/// A range in a text document that links to an internal or external resource,
1909/// like another text document or a web site.
1911 /// The range this link applies to.
1913
1914 /// The uri this link points to. If missing a resolve request is sent later.
1916
1917 // TODO(forster): The following optional fields defined by the language
1918 // server protocol are unsupported:
1919 //
1920 // data?: any - A data entry field that is preserved on a document link
1921 // between a DocumentLinkRequest and a
1922 // DocumentLinkResolveRequest.
1923
1924 friend bool operator==(const DocumentLink &LHS, const DocumentLink &RHS) {
1925 return LHS.range == RHS.range && LHS.target == RHS.target;
1926 }
1927
1928 friend bool operator!=(const DocumentLink &LHS, const DocumentLink &RHS) {
1929 return !(LHS == RHS);
1930 }
1931};
1932llvm::json::Value toJSON(const DocumentLink &DocumentLink);
1933
1934// FIXME(kirillbobyrev): Add FoldingRangeClientCapabilities so we can support
1935// per-line-folding editors.
1939bool fromJSON(const llvm::json::Value &, FoldingRangeParams &,
1940 llvm::json::Path);
1941
1942/// Stores information about a region of code that can be folded.
1944 unsigned startLine = 0;
1946 unsigned endLine = 0;
1948
1949 const static llvm::StringLiteral REGION_KIND;
1950 const static llvm::StringLiteral COMMENT_KIND;
1951 const static llvm::StringLiteral IMPORT_KIND;
1952 std::string kind;
1953};
1954llvm::json::Value toJSON(const FoldingRange &Range);
1955
1956/// Keys starting with an underscore(_) represent leaves, e.g. _total or _self
1957/// for memory usage of whole subtree or only that specific node in bytes. All
1958/// other keys represents children. An example:
1959/// {
1960/// "_self": 0,
1961/// "_total": 8,
1962/// "child1": {
1963/// "_self": 4,
1964/// "_total": 4,
1965/// }
1966/// "child2": {
1967/// "_self": 2,
1968/// "_total": 4,
1969/// "child_deep": {
1970/// "_self": 2,
1971/// "_total": 2,
1972/// }
1973/// }
1974/// }
1975
1976/// Payload for textDocument/ast request.
1977/// This request is a clangd extension.
1979 /// The text document.
1981
1982 /// The position of the node to be dumped.
1983 /// The highest-level node that entirely contains the range will be returned.
1984 /// If no range is given, the root translation unit node will be returned.
1985 std::optional<Range> range;
1986};
1987bool fromJSON(const llvm::json::Value &, ASTParams &, llvm::json::Path);
1988
1989/// Simplified description of a clang AST node.
1990/// This is clangd's internal representation of C++ code.
1991struct ASTNode {
1992 /// The general kind of node, such as "expression"
1993 /// Corresponds to the base AST node type such as Expr.
1994 std::string role;
1995 /// The specific kind of node this is, such as "BinaryOperator".
1996 /// This is usually a concrete node class (with Expr etc suffix dropped).
1997 /// When there's no hierarchy (e.g. TemplateName), the variant (NameKind).
1998 std::string kind;
1999 /// Brief additional information, such as "||" for the particular operator.
2000 /// The information included depends on the node kind, and may be empty.
2001 std::string detail;
2002 /// A one-line dump of detailed information about the node.
2003 /// This includes role/kind/description information, but is rather cryptic.
2004 /// It is similar to the output from `clang -Xclang -ast-dump`.
2005 /// May be empty for certain types of nodes.
2006 std::string arcana;
2007 /// The range of the original source file covered by this node.
2008 /// May be missing for implicit nodes, or those created by macro expansion.
2009 std::optional<Range> range;
2010 /// Nodes nested within this one, such as the operands of a BinaryOperator.
2011 std::vector<ASTNode> children;
2012};
2013llvm::json::Value toJSON(const ASTNode &);
2014llvm::raw_ostream &operator<<(llvm::raw_ostream &, const ASTNode &);
2015
2016// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_configuration
2018
2019 // The scope to get the configuration section for.
2020 std::optional<URIForFile> scopeUri;
2021
2022 // The configuration section asked for.
2023 std::optional<std::string> section;
2024};
2025llvm::json::Value toJSON(const ConfigurationItem &);
2026
2028 std::vector<ConfigurationItem> items;
2029};
2030
2031llvm::json::Value toJSON(const ConfigurationParams &);
2032
2033} // namespace lspserver
2034namespace llvm {
2035template <> struct format_provider<lspserver::Position> {
2036 static void format(const lspserver::Position &Pos, raw_ostream &OS,
2037 StringRef Style) {
2038 assert(Style.empty() && "style modifiers for this type are not supported");
2039 OS << Pos;
2040 }
2041};
2042} // namespace llvm
An Event<T> allows events of type T to be broadcast to listeners.
Definition Function.h:17
LSPError(std::string Message, ErrorCode Code)
void log(llvm::raw_ostream &OS) const override
std::error_code convertToErrorCode() const override
std::string toString() const
Returns a string URI with all components percent-encoded.
Definition URI.cpp:158
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
Definition URI.cpp:235
Whether current platform treats paths case insensitively.
Definition Connection.h:11
std::bitset< SymbolKindMax+1 > SymbolKindBitset
bool fromJSON(const llvm::json::Value &, URIForFile &, llvm::json::Path)
std::variant< TextDocumentEdit, CreateFile, RenameFile, DeleteFile > DocumentChange
@ TriggerTriggerForIncompleteCompletions
Completion was re-triggered as the current completion list is incomplete.
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
llvm::json::Value toJSON(const URIForFile &U)
Serialize/deserialize URIForFile to/from a string URI.
@ None
Documents should not be synced at all.
@ Full
Documents are synced by always sending the full content of the document.
llvm::raw_ostream & operator<<(llvm::raw_ostream &, const Position &)
CompletionItemKind
The kind of a completion entry.
CompletionItemKind adjustKindToCapability(CompletionItemKind Kind, CompletionItemKindBitset &SupportedCompletionItemKinds)
bool operator==(const TextEdit &L, const TextEdit &R)
bool operator<(const CompletionItem &, const CompletionItem &)
static void format(const lspserver::Position &Pos, raw_ostream &OS, StringRef Style)
std::vector< ASTNode > children
Nodes nested within this one, such as the operands of a BinaryOperator.
TextDocumentIdentifier textDocument
The text document.
Represents an incoming call, e.g. a caller of a method or constructor.
CallHierarchyItem from
The item that makes the call.
The parameter of a callHierarchy/incomingCalls request.
URIForFile uri
The resource identifier of this item.
std::vector< SymbolTag > tags
Tags for this item.
std::string detail
More detaill for this item, e.g. the signature of a function.
The parameter of a callHierarchy/outgoingCalls request.
The parameter of a textDocument/prepareCallHierarchy request.
bool ChangeAnnotation
The client supports change annotations on text edits,.
bool DocumentChanges
The client supports versioned document changes for WorkspaceEdit.
std::optional< SymbolKindBitset > WorkspaceSymbolKinds
std::optional< CompletionItemKindBitset > CompletionItemKinds
std::optional< std::vector< OffsetEncoding > > offsetEncoding
Supported encodings for LSP character offsets. (clangd extension).
Range range
The range for which the command was invoked.
TextDocumentIdentifier textDocument
The document in which the command was invoked.
CodeActionContext context
Context carrying additional information.
std::string title
A short, human-readable, title for this code action.
static const llvm::StringLiteral REFACTOR_KIND
static const llvm::StringLiteral INFO_KIND
std::optional< WorkspaceEdit > edit
The workspace edit this code action performs.
static const llvm::StringLiteral REFACTOR_REWRITE_KIND
std::optional< llvm::json::Value > data
static const llvm::StringLiteral QUICKFIX_KIND
std::optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Structure to capture a description for an error code.
std::string href
An URI to open with more information about the diagnostic error.
CompletionTriggerKind triggerKind
How the completion was triggered.
bool deprecated
Indicates if this item is deprecated.
std::optional< MarkupContent > documentation
A human-readable string that represents a doc-comment.
Represents a collection of completion items to be presented in the editor.
std::vector< CompletionItem > items
The completion items.
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
std::optional< bool > overwrite
Overwrite existing file. Overwrite wins over ignoreIfExists.
std::optional< bool > ignoreIfExists
Ignore if exists.
std::optional< CreateFileOptions > options
Additional options.
std::optional< std::string > annotationId
An optional annotation identifier.
URIForFile uri
The resource to create.
std::optional< bool > ignoreIfNotExists
Ignore the operation if the file doesn't exist.
std::optional< bool > recursive
Delete the content recursively if a folder is denoted.
std::optional< DeleteFileOptions > options
Delete options.
std::optional< std::string > annotationId
An optional annotation identifier.
std::string message
The message of this related diagnostic information.
Location location
The location of this related diagnostic information.
std::optional< std::vector< CodeAction > > codeActions
llvm::SmallVector< DiagnosticTag, 1 > tags
Additional metadata about the diagnostic.
Range range
The range at which the message applies.
std::string message
The diagnostic's message.
std::optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
std::optional< CodeDescription > codeDescription
An optional property to describe the error code.
std::string code
The diagnostic's code. Can be omitted.
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
std::vector< FileEvent > changes
The actual file events.
TextDocumentIdentifier textDocument
The document that was closed.
TextDocumentItem textDocument
The document that was opened.
TextDocumentIdentifier textDocument
The document that was saved.
TextDocumentIdentifier textDocument
The document to format.
Range range
The range this highlight applies to.
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
friend bool operator<(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
friend bool operator==(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
Parameters for the document link request.
TextDocumentIdentifier textDocument
The document to provide document links for.
TextDocumentIdentifier textDocument
The document to format.
Position position
The position at which this request was sent.
std::string ch
The character that has been typed.
TextDocumentIdentifier textDocument
The document to format.
SymbolKind kind
The kind of this symbol.
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
std::string name
The name of this symbol.
bool deprecated
Indicates if this symbol is deprecated.
std::string detail
More detail for this symbol, e.g the signature of a function.
std::string command
The identifier of the actual command handler.
FileChangeType type
The change type.
URIForFile uri
The text document's URI.
Stores information about a region of code that can be folded.
static const llvm::StringLiteral IMPORT_KIND
static const llvm::StringLiteral COMMENT_KIND
static const llvm::StringLiteral REGION_KIND
MarkupContent contents
The hover's content.
TextDocumentIdentifier TextDocument
The textdocument these inactive regions belong to.
std::vector< Range > InactiveRegions
The inactive regions that should be sent.
bool FileStatus
Clients supports show file status for textDocument/clangd.fileStatus.
llvm::json::Object rawCapabilities
The same data as capabilities, but not parsed (to expose to modules).
InitializationOptions initializationOptions
User-provided initialization options.
std::optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool).
Position position
The position of this hint.
A parameter literal used in inlay hint requests.
TextDocumentIdentifier textDocument
The text document.
bool operator()(const Diagnostic &LHS, const Diagnostic &RHS) const
friend bool operator==(const Location &LHS, const Location &RHS)
friend bool operator<(const Location &LHS, const Location &RHS)
friend bool operator!=(const Location &LHS, const Location &RHS)
URIForFile uri
The text document's URI.
A single parameter of a particular signature.
std::string labelString
The label of this parameter. Ignored when labelOffsets is set.
std::optional< std::pair< unsigned, unsigned > > labelOffsets
std::string documentation
The documentation of this parameter. Optional.
int64_t line
Line position in a document (zero-based).
friend bool operator==(const Position &LHS, const Position &RHS)
friend bool operator!=(const Position &LHS, const Position &RHS)
friend bool operator<=(const Position &LHS, const Position &RHS)
friend bool operator<(const Position &LHS, const Position &RHS)
llvm::json::Value token
The progress token provided by the client or server.
URIForFile uri
The URI for which diagnostic information is reported.
std::optional< int64_t > version
The version number of the document the diagnostics are published for.
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
friend bool operator==(const Range &LHS, const Range &RHS)
bool overlap(const Range &RHS) const
friend bool operator<(const Range &LHS, const Range &RHS)
Position start
The range's start position.
Range operator/(const Range &RHS) const
Position end
The range's end position.
friend bool operator!=(const Range &LHS, const Range &RHS)
bool includeDeclaration
Include the declaration of the current symbol.
std::optional< bool > overwrite
Overwrite target if existing. Overwrite wins over ignoreIfExists.
std::optional< bool > ignoreIfExists
Ignores if target exists.
std::optional< RenameFileOptions > options
Rename options.
std::optional< std::string > annotationId
An optional annotation identifier.
URIForFile oldUri
The old (existing) location.
std::string newName
The new name of the symbol.
Position position
The position at which this request was sent.
TextDocumentIdentifier textDocument
The document that was opened.
Parameters for the typeHierarchy/resolve request.
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
int resolve
The hierarchy levels to resolve. 0 indicates no level.
TextDocumentIdentifier textDocument
The text document.
std::vector< Position > positions
The positions inside the text document.
std::unique_ptr< SelectionRange > parent
unsigned length
the length of the token. A token cannot be multiline
unsigned tokenType
will be looked up in SemanticTokensLegend.tokenTypes
unsigned deltaLine
token line number, relative to the previous token
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
TextDocumentIdentifier textDocument
The text document.
Describes a replacement of a contiguous range of semanticTokens.
std::optional< std::vector< SemanticTokensEdit > > edits
Set if we computed edits relative to a previous set of tokens.
Body of textDocument/semanticTokens/full request.
TextDocumentIdentifier textDocument
The text document.
URIForFile uri
The document URI to show (for file:// URIs).
bool success
A boolean indicating if the show was successful.
Represents the signature of a callable.
int activeParameter
The active parameter of the active signature.
std::vector< SignatureInformation > signatures
The resulting signatures.
Represents the signature of something callable.
std::vector< ParameterInformation > parameters
The parameters of this signature.
MarkupContent documentation
The documentation of this signature. Optional.
std::string label
The label of this signature. Mandatory.
std::string containerName
The name of the symbol containing this symbol.
Location location
The location of this symbol.
std::string text
The new text of the range/document.
std::optional< Range > range
The range of the document that changed.
std::optional< int > rangeLength
The length of the range that got replaced.
VersionedTextDocumentIdentifier textDocument
The text document to change.
std::string languageId
The text document's language identifier.
std::string text
The content of the opened text document.
Position position
The position inside the text document.
TextDocumentIdentifier textDocument
The text document.
ChangeAnnotationIdentifier annotationId
std::string tweakID
ID of the tweak that should be executed. Corresponds to Tweak::id().
URIForFile file
A file provided by the client on a textDocument/codeAction request.
Range selection
A selection provided by the client on a textDocument/codeAction request.
std::optional< std::vector< ResolveParams > > parents
std::nullopt means parents aren't resolved and empty is no parents.
std::optional< std::vector< TypeHierarchyItem > > children
std::optional< std::string > detail
More detail for this item, e.g. the signature of a function.
std::optional< std::vector< TypeHierarchyItem > > parents
This is a clangd exntesion.
URIForFile uri
The resource identifier of this item.
friend bool operator<(const URIForFile &LHS, const URIForFile &RHS)
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS)
friend bool operator==(const URIForFile &LHS, const URIForFile &RHS)
static llvm::Expected< URIForFile > fromURI(const URI &U, llvm::StringRef HintPath)
llvm::StringRef file() const
Retrieves absolute path to the file.
llvm::json::Value token
The token to be used to report progress.
Signals the end of progress reporting.
Reporting progress is done using the following payload.
std::optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
std::map< std::string, ChangeAnnotation > changeAnnotations
std::optional< std::vector< DocumentChange > > documentChanges
The parameters of a Workspace Symbol Request.