clang-tools 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://github.com/Microsoft/language-server-protocol/blob/main/protocol.md
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_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOL_H
24#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOL_H
25
26#include "URI.h"
27#include "index/SymbolID.h"
28#include "support/MemoryTree.h"
29#include "clang/Index/IndexSymbol.h"
30#include "llvm/ADT/SmallVector.h"
31#include "llvm/Support/JSON.h"
32#include "llvm/Support/raw_ostream.h"
33#include <bitset>
34#include <memory>
35#include <optional>
36#include <string>
37#include <variant>
38#include <vector>
39
40// This file is using the LSP syntax for identifier names which is different
41// from the LLVM coding standard. To avoid the clang-tidy warnings, we're
42// disabling one check here.
43// NOLINTBEGIN(readability-identifier-naming)
44
45namespace clang {
46namespace clangd {
47
48enum class ErrorCode {
49 // Defined by JSON RPC.
50 ParseError = -32700,
53 InvalidParams = -32602,
54 InternalError = -32603,
55
58
59 // Defined by the protocol.
62};
63// Models an LSP error as an llvm::Error.
64class LSPError : public llvm::ErrorInfo<LSPError> {
65public:
66 std::string Message;
68 static char ID;
69
71 : Message(std::move(Message)), Code(Code) {}
72
73 void log(llvm::raw_ostream &OS) const override {
74 OS << int(Code) << ": " << Message;
75 }
76 std::error_code convertToErrorCode() const override {
77 return llvm::inconvertibleErrorCode();
78 }
79};
80
81bool fromJSON(const llvm::json::Value &, SymbolID &, llvm::json::Path);
82llvm::json::Value toJSON(const SymbolID &);
83
84// URI in "file" scheme for a file.
85struct URIForFile {
86 URIForFile() = default;
87
88 /// Canonicalizes \p AbsPath via URI.
89 ///
90 /// File paths in URIForFile can come from index or local AST. Path from
91 /// index goes through URI transformation, and the final path is resolved by
92 /// URI scheme and could potentially be different from the original path.
93 /// Hence, we do the same transformation for all paths.
94 ///
95 /// Files can be referred to by several paths (e.g. in the presence of links).
96 /// Which one we prefer may depend on where we're coming from. \p TUPath is a
97 /// hint, and should usually be the main entrypoint file we're processing.
98 static URIForFile canonicalize(llvm::StringRef AbsPath,
99 llvm::StringRef TUPath);
100
101 static llvm::Expected<URIForFile> fromURI(const URI &U,
102 llvm::StringRef HintPath);
103
104 /// Retrieves absolute path to the file.
105 llvm::StringRef file() const { return File; }
106
107 explicit operator bool() const { return !File.empty(); }
108 std::string uri() const { return URI::createFile(File).toString(); }
109
110 friend bool operator==(const URIForFile &LHS, const URIForFile &RHS) {
111 return LHS.File == RHS.File;
112 }
113
114 friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS) {
115 return !(LHS == RHS);
116 }
117
118 friend bool operator<(const URIForFile &LHS, const URIForFile &RHS) {
119 return LHS.File < RHS.File;
120 }
121
122private:
123 explicit URIForFile(std::string &&File) : File(std::move(File)) {}
124
125 std::string File;
126};
127
128/// Serialize/deserialize \p URIForFile to/from a string URI.
129llvm::json::Value toJSON(const URIForFile &U);
130bool fromJSON(const llvm::json::Value &, URIForFile &, llvm::json::Path);
131
133 /// The text document's URI.
135};
136llvm::json::Value toJSON(const TextDocumentIdentifier &);
137bool fromJSON(const llvm::json::Value &, TextDocumentIdentifier &,
138 llvm::json::Path);
139
141 /// The version number of this document. If a versioned text document
142 /// identifier is sent from the server to the client and the file is not open
143 /// in the editor (the server has not received an open notification before)
144 /// the server can send `null` to indicate that the version is known and the
145 /// content on disk is the master (as speced with document content ownership).
146 ///
147 /// The version number of a document will increase after each change,
148 /// including undo/redo. The number doesn't need to be consecutive.
149 ///
150 /// clangd extension: versions are optional, and synthesized if missing.
151 std::optional<std::int64_t> version;
152};
153llvm::json::Value toJSON(const VersionedTextDocumentIdentifier &);
154bool fromJSON(const llvm::json::Value &, VersionedTextDocumentIdentifier &,
155 llvm::json::Path);
156
157struct Position {
158 /// Line position in a document (zero-based).
159 int line = 0;
160
161 /// Character offset on a line in a document (zero-based).
162 /// WARNING: this is in UTF-16 codepoints, not bytes or characters!
163 /// Use the functions in SourceCode.h to construct/interpret Positions.
164 int character = 0;
165
166 friend bool operator==(const Position &LHS, const Position &RHS) {
167 return std::tie(LHS.line, LHS.character) ==
168 std::tie(RHS.line, RHS.character);
169 }
170 friend bool operator!=(const Position &LHS, const Position &RHS) {
171 return !(LHS == RHS);
172 }
173 friend bool operator<(const Position &LHS, const Position &RHS) {
174 return std::tie(LHS.line, LHS.character) <
175 std::tie(RHS.line, RHS.character);
176 }
177 friend bool operator<=(const Position &LHS, const Position &RHS) {
178 return std::tie(LHS.line, LHS.character) <=
179 std::tie(RHS.line, RHS.character);
180 }
181};
182bool fromJSON(const llvm::json::Value &, Position &, llvm::json::Path);
183llvm::json::Value toJSON(const Position &);
184llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Position &);
185
186struct Range {
187 /// The range's start position.
189
190 /// The range's end position.
192
193 friend bool operator==(const Range &LHS, const Range &RHS) {
194 return std::tie(LHS.start, LHS.end) == std::tie(RHS.start, RHS.end);
195 }
196 friend bool operator!=(const Range &LHS, const Range &RHS) {
197 return !(LHS == RHS);
198 }
199 friend bool operator<(const Range &LHS, const Range &RHS) {
200 return std::tie(LHS.start, LHS.end) < std::tie(RHS.start, RHS.end);
201 }
202
203 bool contains(Position Pos) const { return start <= Pos && Pos < end; }
204 bool contains(Range Rng) const {
205 return start <= Rng.start && Rng.end <= end;
206 }
207};
208bool fromJSON(const llvm::json::Value &, Range &, llvm::json::Path);
209llvm::json::Value toJSON(const Range &);
210llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Range &);
211
212struct Location {
213 /// The text document's URI.
216
217 friend bool operator==(const Location &LHS, const Location &RHS) {
218 return LHS.uri == RHS.uri && LHS.range == RHS.range;
219 }
220
221 friend bool operator!=(const Location &LHS, const Location &RHS) {
222 return !(LHS == RHS);
223 }
224
225 friend bool operator<(const Location &LHS, const Location &RHS) {
226 return std::tie(LHS.uri, LHS.range) < std::tie(RHS.uri, RHS.range);
227 }
228};
229llvm::json::Value toJSON(const Location &);
230llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Location &);
231
232/// Extends Locations returned by textDocument/references with extra info.
233/// This is a clangd extension: LSP uses `Location`.
235 /// clangd extension: contains the name of the function or class in which the
236 /// reference occurs
237 std::optional<std::string> containerName;
238};
239llvm::json::Value toJSON(const ReferenceLocation &);
240llvm::raw_ostream &operator<<(llvm::raw_ostream &, const ReferenceLocation &);
241
242using ChangeAnnotationIdentifier = std::string;
243// A combination of a LSP standard TextEdit and AnnotatedTextEdit.
244struct TextEdit {
245 /// The range of the text document to be manipulated. To insert
246 /// text into a document create a range where start === end.
248
249 /// The string to be inserted. For delete operations use an
250 /// empty string.
251 std::string newText;
252
253 /// The actual annotation identifier (optional)
254 /// If empty, then this field is nullopt.
256};
257inline bool operator==(const TextEdit &L, const TextEdit &R) {
258 return std::tie(L.newText, L.range, L.annotationId) ==
259 std::tie(R.newText, R.range, L.annotationId);
260}
261bool fromJSON(const llvm::json::Value &, TextEdit &, llvm::json::Path);
262llvm::json::Value toJSON(const TextEdit &);
263llvm::raw_ostream &operator<<(llvm::raw_ostream &, const TextEdit &);
264
266 /// The string to be inserted.
267 std::string newText;
268
269 /// The range if the insert is requested.
271
272 /// The range if the replace is requested.
274};
275llvm::json::Value toJSON(const InsertReplaceEdit &);
276
278 /// A human-readable string describing the actual change. The string
279 /// is rendered prominent in the user interface.
280 std::string label;
281
282 /// A flag which indicates that user confirmation is needed
283 /// before applying the change.
284 std::optional<bool> needsConfirmation;
285
286 /// A human-readable string which is rendered less prominent in
287 /// the user interface.
288 std::string description;
289};
290bool fromJSON(const llvm::json::Value &, ChangeAnnotation &, llvm::json::Path);
291llvm::json::Value toJSON(const ChangeAnnotation &);
292
294 /// The text document to change.
296
297 /// The edits to be applied.
298 /// FIXME: support the AnnotatedTextEdit variant.
299 std::vector<TextEdit> edits;
300};
301bool fromJSON(const llvm::json::Value &, TextDocumentEdit &, llvm::json::Path);
302llvm::json::Value toJSON(const TextDocumentEdit &);
303
305 /// The text document's URI.
307
308 /// The text document's language identifier.
309 std::string languageId;
310
311 /// The version number of this document (it will strictly increase after each
312 /// change, including undo/redo.
313 ///
314 /// clangd extension: versions are optional, and synthesized if missing.
315 std::optional<int64_t> version;
316
317 /// The content of the opened text document.
318 std::string text;
319};
320bool fromJSON(const llvm::json::Value &, TextDocumentItem &, llvm::json::Path);
321
322enum class TraceLevel {
323 Off = 0,
326};
327bool fromJSON(const llvm::json::Value &E, TraceLevel &Out, llvm::json::Path);
328
329struct NoParams {};
330inline llvm::json::Value toJSON(const NoParams &) { return nullptr; }
331inline bool fromJSON(const llvm::json::Value &, NoParams &, llvm::json::Path) {
332 return true;
333}
335
336/// Defines how the host (editor) should sync document changes to the language
337/// server.
339 /// Documents should not be synced at all.
340 None = 0,
341
342 /// Documents are synced by always sending the full content of the document.
343 Full = 1,
344
345 /// Documents are synced by sending the full content on open. After that
346 /// only incremental updates to the document are send.
348};
349
350/// The kind of a completion entry.
379bool fromJSON(const llvm::json::Value &, CompletionItemKind &,
380 llvm::json::Path);
381constexpr auto CompletionItemKindMin =
382 static_cast<size_t>(CompletionItemKind::Text);
383constexpr auto CompletionItemKindMax =
384 static_cast<size_t>(CompletionItemKind::TypeParameter);
385using CompletionItemKindBitset = std::bitset<CompletionItemKindMax + 1>;
386bool fromJSON(const llvm::json::Value &, CompletionItemKindBitset &,
387 llvm::json::Path);
390 CompletionItemKindBitset &SupportedCompletionItemKinds);
391
392/// A symbol kind.
421bool fromJSON(const llvm::json::Value &, SymbolKind &, llvm::json::Path);
422constexpr auto SymbolKindMin = static_cast<size_t>(SymbolKind::File);
423constexpr auto SymbolKindMax = static_cast<size_t>(SymbolKind::TypeParameter);
424using SymbolKindBitset = std::bitset<SymbolKindMax + 1>;
425bool fromJSON(const llvm::json::Value &, SymbolKindBitset &, llvm::json::Path);
427 SymbolKindBitset &supportedSymbolKinds);
428
429// Convert a index::SymbolKind to clangd::SymbolKind (LSP)
430// Note, some are not perfect matches and should be improved when this LSP
431// issue is addressed:
432// https://github.com/Microsoft/language-server-protocol/issues/344
433SymbolKind indexSymbolKindToSymbolKind(const index::SymbolInfo &Info);
434
435// Determines the encoding used to measure offsets and lengths of source in LSP.
436enum class OffsetEncoding {
437 // Any string is legal on the wire. Unrecognized encodings parse as this.
439 // Length counts code units of UTF-16 encoded text. (Standard LSP behavior).
441 // Length counts bytes of UTF-8 encoded text. (Clangd extension).
443 // Length counts codepoints in unicode text. (Clangd extension).
445};
446llvm::json::Value toJSON(const OffsetEncoding &);
447bool fromJSON(const llvm::json::Value &, OffsetEncoding &, llvm::json::Path);
448llvm::raw_ostream &operator<<(llvm::raw_ostream &, OffsetEncoding);
449
450// Describes the content type that a client supports in various result literals
451// like `Hover`, `ParameterInfo` or `CompletionItem`.
456bool fromJSON(const llvm::json::Value &, MarkupKind &, llvm::json::Path);
457llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, MarkupKind);
458
459// This struct doesn't mirror LSP!
460// The protocol defines deeply nested structures for client capabilities.
461// Instead of mapping them all, this just parses out the bits we care about.
463 /// The supported set of SymbolKinds for workspace/symbol.
464 /// workspace.symbol.symbolKind.valueSet
465 std::optional<SymbolKindBitset> WorkspaceSymbolKinds;
466
467 /// Whether the client accepts diagnostics with codeActions attached inline.
468 /// This is a clangd extension.
469 /// textDocument.publishDiagnostics.codeActionsInline.
470 bool DiagnosticFixes = false;
471
472 /// Whether the client accepts diagnostics with related locations.
473 /// textDocument.publishDiagnostics.relatedInformation.
475
476 /// Whether the client accepts diagnostics with category attached to it
477 /// using the "category" extension.
478 /// textDocument.publishDiagnostics.categorySupport
479 bool DiagnosticCategory = false;
480
481 /// Client supports snippets as insert text.
482 /// textDocument.completion.completionItem.snippetSupport
483 bool CompletionSnippets = false;
484
485 /// Client supports completions with additionalTextEdit near the cursor.
486 /// This is a clangd extension. (LSP says this is for unrelated text only).
487 /// textDocument.completion.editsNearCursor
488 bool CompletionFixes = false;
489
490 /// Client supports displaying a container string for results of
491 /// textDocument/reference (clangd extension)
492 /// textDocument.references.container
493 bool ReferenceContainer = false;
494
495 /// Client supports hierarchical document symbols.
496 /// textDocument.documentSymbol.hierarchicalDocumentSymbolSupport
498
499 /// Client supports signature help.
500 /// textDocument.signatureHelp
501 bool HasSignatureHelp = false;
502
503 /// Client signals that it only supports folding complete lines.
504 /// Client will ignore specified `startCharacter` and `endCharacter`
505 /// properties in a FoldingRange.
506 /// textDocument.foldingRange.lineFoldingOnly
507 bool LineFoldingOnly = false;
508
509 /// Client supports processing label offsets instead of a simple label string.
510 /// textDocument.signatureHelp.signatureInformation.parameterInformation.labelOffsetSupport
512
513 /// The documentation format that should be used for
514 /// textDocument/signatureHelp.
515 /// textDocument.signatureHelp.signatureInformation.documentationFormat
517
518 /// The supported set of CompletionItemKinds for textDocument/completion.
519 /// textDocument.completion.completionItemKind.valueSet
520 std::optional<CompletionItemKindBitset> CompletionItemKinds;
521
522 /// The documentation format that should be used for textDocument/completion.
523 /// textDocument.completion.completionItem.documentationFormat
525
526 /// Client supports insert replace edit to control different behavior if a
527 /// completion item is inserted in the text or should replace text.
528 bool InsertReplace = false;
529
530 /// The client has support for completion item label details.
531 /// textDocument.completion.completionItem.labelDetailsSupport.
533
534 /// Client supports CodeAction return value for textDocument/codeAction.
535 /// textDocument.codeAction.codeActionLiteralSupport.
537
538 /// Client advertises support for the semanticTokens feature.
539 /// We support the textDocument/semanticTokens request in any case.
540 /// textDocument.semanticTokens
541 bool SemanticTokens = false;
542 /// Client supports Theia semantic highlighting extension.
543 /// https://github.com/microsoft/vscode-languageserver-node/pull/367
544 /// clangd no longer supports this, we detect it just to log a warning.
545 /// textDocument.semanticHighlightingCapabilities.semanticHighlighting
547
548 /// Supported encodings for LSP character offsets.
549 /// general.positionEncodings
550 std::optional<std::vector<OffsetEncoding>> PositionEncodings;
551
552 /// The content format that should be used for Hover requests.
553 /// textDocument.hover.contentEncoding
555
556 /// The client supports testing for validity of rename operations
557 /// before execution.
559
560 /// The client supports progress notifications.
561 /// window.workDoneProgress
562 bool WorkDoneProgress = false;
563
564 /// The client supports implicit $/progress work-done progress streams,
565 /// without a preceding window/workDoneProgress/create.
566 /// This is a clangd extension.
567 /// window.implicitWorkDoneProgressCreate
569
570 /// Whether the client claims to cancel stale requests.
571 /// general.staleRequestSupport.cancel
573
574 /// Whether the client implementation supports a refresh request sent from the
575 /// server to the client.
577
578 /// The client supports versioned document changes for WorkspaceEdit.
579 bool DocumentChanges = false;
580
581 /// The client supports change annotations on text edits,
582 bool ChangeAnnotation = false;
583
584 /// Whether the client supports the textDocument/inactiveRegions
585 /// notification. This is a clangd extension.
586 /// textDocument.inactiveRegionsCapabilities.inactiveRegions
587 bool InactiveRegions = false;
588};
589bool fromJSON(const llvm::json::Value &, ClientCapabilities &,
590 llvm::json::Path);
591
592/// Clangd extension that's used in the 'compilationDatabaseChanges' in
593/// workspace/didChangeConfiguration to record updates to the in-memory
594/// compilation database.
596 std::string workingDirectory;
597 std::vector<std::string> compilationCommand;
598};
599bool fromJSON(const llvm::json::Value &, ClangdCompileCommand &,
600 llvm::json::Path);
601
602/// Clangd extension: parameters configurable at any time, via the
603/// `workspace/didChangeConfiguration` notification.
604/// LSP defines this type as `any`.
606 // Changes to the in-memory compilation database.
607 // The key of the map is a file name.
608 std::map<std::string, ClangdCompileCommand> compilationDatabaseChanges;
609};
610bool fromJSON(const llvm::json::Value &, ConfigurationSettings &,
611 llvm::json::Path);
612
613/// Clangd extension: parameters configurable at `initialize` time.
614/// LSP defines this type as `any`.
616 // What we can change through the didChangeConfiguration request, we can
617 // also set through the initialize request (initializationOptions field).
619
620 std::optional<std::string> compilationDatabasePath;
621 // Additional flags to be included in the "fallback command" used when
622 // the compilation database doesn't describe an opened file.
623 // The command used will be approximately `clang $FILE $fallbackFlags`.
624 std::vector<std::string> fallbackFlags;
625
626 /// Clients supports show file status for textDocument/clangd.fileStatus.
627 bool FileStatus = false;
628};
629bool fromJSON(const llvm::json::Value &, InitializationOptions &,
630 llvm::json::Path);
631
633 /// The process Id of the parent process that started
634 /// the server. Is null if the process has not been started by another
635 /// process. If the parent process is not alive then the server should exit
636 /// (see exit notification) its process.
637 std::optional<int> processId;
638
639 /// The rootPath of the workspace. Is null
640 /// if no folder is open.
641 ///
642 /// @deprecated in favour of rootUri.
643 std::optional<std::string> rootPath;
644
645 /// The rootUri of the workspace. Is null if no
646 /// folder is open. If both `rootPath` and `rootUri` are set
647 /// `rootUri` wins.
648 std::optional<URIForFile> rootUri;
649
650 // User provided initialization options.
651 // initializationOptions?: any;
652
653 /// The capabilities provided by the client (editor or tool)
655 /// The same data as capabilities, but not parsed (to expose to modules).
656 llvm::json::Object rawCapabilities;
657
658 /// The initial trace setting. If omitted trace is disabled ('off').
659 std::optional<TraceLevel> trace;
660
661 /// User-provided initialization options.
663};
664bool fromJSON(const llvm::json::Value &, InitializeParams &, llvm::json::Path);
665
667 /// The token to be used to report progress.
668 llvm::json::Value token = nullptr;
669};
670llvm::json::Value toJSON(const WorkDoneProgressCreateParams &P);
671
672template <typename T> struct ProgressParams {
673 /// The progress token provided by the client or server.
674 llvm::json::Value token = nullptr;
675
676 /// The progress data.
678};
679template <typename T> llvm::json::Value toJSON(const ProgressParams<T> &P) {
680 return llvm::json::Object{{"token", P.token}, {"value", P.value}};
681}
682/// To start progress reporting a $/progress notification with the following
683/// payload must be sent.
685 /// Mandatory title of the progress operation. Used to briefly inform about
686 /// the kind of operation being performed.
687 ///
688 /// Examples: "Indexing" or "Linking dependencies".
689 std::string title;
690
691 /// Controls if a cancel button should show to allow the user to cancel the
692 /// long-running operation. Clients that don't support cancellation are
693 /// allowed to ignore the setting.
694 bool cancellable = false;
695
696 /// Optional progress percentage to display (value 100 is considered 100%).
697 /// If not provided infinite progress is assumed and clients are allowed
698 /// to ignore the `percentage` value in subsequent in report notifications.
699 ///
700 /// The value should be steadily rising. Clients are free to ignore values
701 /// that are not following this rule.
702 ///
703 /// Clangd implementation note: we only send nonzero percentages in
704 /// the WorkProgressReport. 'true' here means percentages will be used.
705 bool percentage = false;
706};
707llvm::json::Value toJSON(const WorkDoneProgressBegin &);
708
709/// Reporting progress is done using the following payload.
711 /// Mandatory title of the progress operation. Used to briefly inform about
712 /// the kind of operation being performed.
713 ///
714 /// Examples: "Indexing" or "Linking dependencies".
715 std::string title;
716
717 /// Controls enablement state of a cancel button. This property is only valid
718 /// if a cancel button got requested in the `WorkDoneProgressStart` payload.
719 ///
720 /// Clients that don't support cancellation or don't support control
721 /// the button's enablement state are allowed to ignore the setting.
722 std::optional<bool> cancellable;
723
724 /// Optional, more detailed associated progress message. Contains
725 /// complementary information to the `title`.
726 ///
727 /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
728 /// If unset, the previous progress message (if any) is still valid.
729 std::optional<std::string> message;
730
731 /// Optional progress percentage to display (value 100 is considered 100%).
732 /// If not provided infinite progress is assumed and clients are allowed
733 /// to ignore the `percentage` value in subsequent in report notifications.
734 ///
735 /// The value should be steadily rising. Clients are free to ignore values
736 /// that are not following this rule.
737 std::optional<unsigned> percentage;
738};
739llvm::json::Value toJSON(const WorkDoneProgressReport &);
740//
741/// Signals the end of progress reporting.
743 /// Optional, a final message indicating to for example indicate the outcome
744 /// of the operation.
745 std::optional<std::string> message;
746};
747llvm::json::Value toJSON(const WorkDoneProgressEnd &);
748
749enum class MessageType {
750 /// An error message.
751 Error = 1,
752 /// A warning message.
754 /// An information message.
755 Info = 3,
756 /// A log message.
757 Log = 4,
758};
759llvm::json::Value toJSON(const MessageType &);
760
761/// The show message notification is sent from a server to a client to ask the
762/// client to display a particular message in the user interface.
764 /// The message type.
766 /// The actual message.
767 std::string message;
768};
769llvm::json::Value toJSON(const ShowMessageParams &);
770
772 /// The document that was opened.
774};
775bool fromJSON(const llvm::json::Value &, DidOpenTextDocumentParams &,
776 llvm::json::Path);
777
779 /// The document that was closed.
781};
782bool fromJSON(const llvm::json::Value &, DidCloseTextDocumentParams &,
783 llvm::json::Path);
784
786 /// The document that was saved.
788};
789bool fromJSON(const llvm::json::Value &, DidSaveTextDocumentParams &,
790 llvm::json::Path);
791
793 /// The range of the document that changed.
794 std::optional<Range> range;
795
796 /// The length of the range that got replaced.
797 std::optional<int> rangeLength;
798
799 /// The new text of the range/document.
800 std::string text;
801};
802bool fromJSON(const llvm::json::Value &, TextDocumentContentChangeEvent &,
803 llvm::json::Path);
804
806 /// The document that did change. The version number points
807 /// to the version after all provided content changes have
808 /// been applied.
810
811 /// The actual content changes.
812 std::vector<TextDocumentContentChangeEvent> contentChanges;
813
814 /// Forces diagnostics to be generated, or to not be generated, for this
815 /// version of the file. If not set, diagnostics are eventually consistent:
816 /// either they will be provided for this version or some subsequent one.
817 /// This is a clangd extension.
818 std::optional<bool> wantDiagnostics;
819
820 /// Force a complete rebuild of the file, ignoring all cached state. Slow!
821 /// This is useful to defeat clangd's assumption that missing headers will
822 /// stay missing.
823 /// This is a clangd extension.
824 bool forceRebuild = false;
825};
826bool fromJSON(const llvm::json::Value &, DidChangeTextDocumentParams &,
827 llvm::json::Path);
828
829enum class FileChangeType {
830 /// The file got created.
832 /// The file got changed.
834 /// The file got deleted.
836};
837bool fromJSON(const llvm::json::Value &E, FileChangeType &Out,
838 llvm::json::Path);
839
840struct FileEvent {
841 /// The file's URI.
843 /// The change type.
845};
846bool fromJSON(const llvm::json::Value &, FileEvent &, llvm::json::Path);
847
849 /// The actual file events.
850 std::vector<FileEvent> changes;
851};
852bool fromJSON(const llvm::json::Value &, DidChangeWatchedFilesParams &,
853 llvm::json::Path);
854
858bool fromJSON(const llvm::json::Value &, DidChangeConfigurationParams &,
859 llvm::json::Path);
860
861// Note: we do not parse FormattingOptions for *FormattingParams.
862// In general, we use a clang-format style detected from common mechanisms
863// (.clang-format files and the -fallback-style flag).
864// It would be possible to override these with FormatOptions, but:
865// - the protocol makes FormatOptions mandatory, so many clients set them to
866// useless values, and we can't tell when to respect them
867// - we also format in other places, where FormatOptions aren't available.
868
870 /// The document to format.
872
873 /// The range to format
875};
876bool fromJSON(const llvm::json::Value &, DocumentRangeFormattingParams &,
877 llvm::json::Path);
878
880 /// The document to format.
882
883 /// The list of ranges to format
884 std::vector<Range> ranges;
885};
886bool fromJSON(const llvm::json::Value &, DocumentRangesFormattingParams &,
887 llvm::json::Path);
888
890 /// The document to format.
892
893 /// The position at which this request was sent.
895
896 /// The character that has been typed.
897 std::string ch;
898};
899bool fromJSON(const llvm::json::Value &, DocumentOnTypeFormattingParams &,
900 llvm::json::Path);
901
903 /// The document to format.
905};
906bool fromJSON(const llvm::json::Value &, DocumentFormattingParams &,
907 llvm::json::Path);
908
910 // The text document to find symbols in.
912};
913bool fromJSON(const llvm::json::Value &, DocumentSymbolParams &,
914 llvm::json::Path);
915
916/// Represents a related message and source code location for a diagnostic.
917/// This should be used to point to code locations that cause or related to a
918/// diagnostics, e.g when duplicating a symbol in a scope.
920 /// The location of this related diagnostic information.
922 /// The message of this related diagnostic information.
923 std::string message;
924};
925llvm::json::Value toJSON(const DiagnosticRelatedInformation &);
926
928 /// Unused or unnecessary code.
929 ///
930 /// Clients are allowed to render diagnostics with this tag faded out instead
931 /// of having an error squiggle.
933 /// Deprecated or obsolete code.
934 ///
935 /// Clients are allowed to rendered diagnostics with this tag strike through.
937};
938llvm::json::Value toJSON(DiagnosticTag Tag);
939
940/// Structure to capture a description for an error code.
942 /// An URI to open with more information about the diagnostic error.
943 std::string href;
944};
945llvm::json::Value toJSON(const CodeDescription &);
946
947struct CodeAction;
949 /// The range at which the message applies.
951
952 /// The diagnostic's severity. Can be omitted. If omitted it is up to the
953 /// client to interpret diagnostics as error, warning, info or hint.
954 int severity = 0;
955
956 /// The diagnostic's code. Can be omitted.
957 std::string code;
958
959 /// An optional property to describe the error code.
960 std::optional<CodeDescription> codeDescription;
961
962 /// A human-readable string describing the source of this
963 /// diagnostic, e.g. 'typescript' or 'super lint'.
964 std::string source;
965
966 /// The diagnostic's message.
967 std::string message;
968
969 /// Additional metadata about the diagnostic.
970 llvm::SmallVector<DiagnosticTag, 1> tags;
971
972 /// An array of related diagnostic information, e.g. when symbol-names within
973 /// a scope collide all definitions can be marked via this property.
974 std::optional<std::vector<DiagnosticRelatedInformation>> relatedInformation;
975
976 /// The diagnostic's category. Can be omitted.
977 /// An LSP extension that's used to send the name of the category over to the
978 /// client. The category typically describes the compilation stage during
979 /// which the issue was produced, e.g. "Semantic Issue" or "Parse Issue".
980 std::optional<std::string> category;
981
982 /// Clangd extension: code actions related to this diagnostic.
983 /// Only with capability textDocument.publishDiagnostics.codeActionsInline.
984 /// (These actions can also be obtained using textDocument/codeAction).
985 std::optional<std::vector<CodeAction>> codeActions;
986
987 /// A data entry field that is preserved between a
988 /// `textDocument/publishDiagnostics` notification
989 /// and `textDocument/codeAction` request.
990 /// Mutating users should associate their data with a unique key they can use
991 /// to retrieve later on.
992 llvm::json::Object data;
993};
994llvm::json::Value toJSON(const Diagnostic &);
995
996bool fromJSON(const llvm::json::Value &, Diagnostic &, llvm::json::Path);
997llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Diagnostic &);
998
1000 /// The URI for which diagnostic information is reported.
1002 /// An array of diagnostic information items.
1003 std::vector<Diagnostic> diagnostics;
1004 /// The version number of the document the diagnostics are published for.
1005 std::optional<int64_t> version;
1006};
1007llvm::json::Value toJSON(const PublishDiagnosticsParams &);
1008
1010 /// An array of diagnostics known on the client side overlapping the range
1011 /// provided to the `textDocument/codeAction` request. They are provided so
1012 /// that the server knows which errors are currently presented to the user for
1013 /// the given range. There is no guarantee that these accurately reflect the
1014 /// error state of the resource. The primary parameter to compute code actions
1015 /// is the provided range.
1016 std::vector<Diagnostic> diagnostics;
1017
1018 /// Requested kind of actions to return.
1019 ///
1020 /// Actions not of this kind are filtered out by the client before being
1021 /// shown. So servers can omit computing them.
1022 std::vector<std::string> only;
1023};
1024bool fromJSON(const llvm::json::Value &, CodeActionContext &, llvm::json::Path);
1025
1027 /// The document in which the command was invoked.
1029
1030 /// The range for which the command was invoked.
1032
1033 /// Context carrying additional information.
1035};
1036bool fromJSON(const llvm::json::Value &, CodeActionParams &, llvm::json::Path);
1037
1038/// The edit should either provide changes or documentChanges. If the client
1039/// can handle versioned document edits and if documentChanges are present,
1040/// the latter are preferred over changes.
1042 /// Holds changes to existing resources.
1043 std::optional<std::map<std::string, std::vector<TextEdit>>> changes;
1044 /// Versioned document edits.
1045 ///
1046 /// If a client neither supports `documentChanges` nor
1047 /// `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s
1048 /// using the `changes` property are supported.
1049 std::optional<std::vector<TextDocumentEdit>> documentChanges;
1050
1051 /// A map of change annotations that can be referenced in
1052 /// AnnotatedTextEdit.
1053 std::map<std::string, ChangeAnnotation> changeAnnotations;
1054};
1055bool fromJSON(const llvm::json::Value &, WorkspaceEdit &, llvm::json::Path);
1056llvm::json::Value toJSON(const WorkspaceEdit &WE);
1057
1058/// Arguments for the 'applyTweak' command. The server sends these commands as a
1059/// response to the textDocument/codeAction request. The client can later send a
1060/// command back to the server if the user requests to execute a particular code
1061/// tweak.
1063 /// A file provided by the client on a textDocument/codeAction request.
1065 /// A selection provided by the client on a textDocument/codeAction request.
1067 /// ID of the tweak that should be executed. Corresponds to Tweak::id().
1068 std::string tweakID;
1069};
1070bool fromJSON(const llvm::json::Value &, TweakArgs &, llvm::json::Path);
1071llvm::json::Value toJSON(const TweakArgs &A);
1072
1074 /// The identifier of the actual command handler.
1075 std::string command;
1076
1077 // This is `arguments?: []any` in LSP.
1078 // All clangd's commands accept a single argument (or none => null).
1079 llvm::json::Value argument = nullptr;
1080};
1081bool fromJSON(const llvm::json::Value &, ExecuteCommandParams &,
1082 llvm::json::Path);
1083
1084struct Command : public ExecuteCommandParams {
1085 std::string title;
1086};
1087llvm::json::Value toJSON(const Command &C);
1088
1089/// A code action represents a change that can be performed in code, e.g. to fix
1090/// a problem or to refactor code.
1091///
1092/// A CodeAction must set either `edit` and/or a `command`. If both are
1093/// supplied, the `edit` is applied first, then the `command` is executed.
1095 /// A short, human-readable, title for this code action.
1096 std::string title;
1097
1098 /// The kind of the code action.
1099 /// Used to filter code actions.
1100 std::optional<std::string> kind;
1101 const static llvm::StringLiteral QUICKFIX_KIND;
1102 const static llvm::StringLiteral REFACTOR_KIND;
1103 const static llvm::StringLiteral INFO_KIND;
1104
1105 /// The diagnostics that this code action resolves.
1106 std::optional<std::vector<Diagnostic>> diagnostics;
1107
1108 /// Marks this as a preferred action. Preferred actions are used by the
1109 /// `auto fix` command and can be targeted by keybindings.
1110 /// A quick fix should be marked preferred if it properly addresses the
1111 /// underlying error. A refactoring should be marked preferred if it is the
1112 /// most reasonable choice of actions to take.
1113 bool isPreferred = false;
1114
1115 /// The workspace edit this code action performs.
1116 std::optional<WorkspaceEdit> edit;
1117
1118 /// A command this code action executes. If a code action provides an edit
1119 /// and a command, first the edit is executed and then the command.
1120 std::optional<Command> command;
1121};
1122llvm::json::Value toJSON(const CodeAction &);
1123
1124/// Symbol tags are extra annotations that can be attached to a symbol.
1125/// \see https://github.com/microsoft/language-server-protocol/pull/2003
1152llvm::json::Value toJSON(SymbolTag);
1153/// Represents programming constructs like variables, classes, interfaces etc.
1154/// that appear in a document. Document symbols can be hierarchical and they
1155/// have two ranges: one that encloses its definition and one that points to its
1156/// most interesting range, e.g. the range of an identifier.
1158 /// The name of this symbol.
1159 std::string name;
1160
1161 /// More detail for this symbol, e.g the signature of a function.
1162 std::string detail;
1163
1164 /// The kind of this symbol.
1166
1167 /// Indicates if this symbol is deprecated.
1168 bool deprecated = false;
1169
1170 /// The tags for this symbol.
1171 std::vector<SymbolTag> tags;
1172
1173 /// The range enclosing this symbol not including leading/trailing whitespace
1174 /// but everything else like comments. This information is typically used to
1175 /// determine if the clients cursor is inside the symbol to reveal in the
1176 /// symbol in the UI.
1178
1179 /// The range that should be selected and revealed when this symbol is being
1180 /// picked, e.g the name of a function. Must be contained by the `range`.
1182
1183 /// Children of this symbol, e.g. properties of a class.
1184 std::vector<DocumentSymbol> children;
1185};
1186llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S);
1187llvm::json::Value toJSON(const DocumentSymbol &S);
1188
1189/// Represents information about programming constructs like variables, classes,
1190/// interfaces etc.
1192 /// The name of this symbol.
1193 std::string name;
1194
1195 /// The kind of this symbol.
1197
1198 /// Tags for this symbol, e.g public, private, static, const etc.
1199 std::vector<SymbolTag> tags;
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/// Represents information about identifier.
1219/// This is returned from textDocument/symbolInfo, which is a clangd extension.
1221 std::string name;
1222
1223 std::string containerName;
1224
1225 /// Unified Symbol Resolution identifier
1226 /// This is an opaque string uniquely identifying a symbol.
1227 /// Unlike SymbolID, it is variable-length and somewhat human-readable.
1228 /// It is a common representation across several clang tools.
1229 /// (See USRGeneration.h)
1230 std::string USR;
1231
1233
1234 std::optional<Location> declarationRange;
1235
1236 std::optional<Location> definitionRange;
1237};
1238llvm::json::Value toJSON(const SymbolDetails &);
1239llvm::raw_ostream &operator<<(llvm::raw_ostream &, const SymbolDetails &);
1240bool operator==(const SymbolDetails &, const SymbolDetails &);
1241
1242/// The parameters of a Workspace Symbol Request.
1244 /// A query string to filter symbols by.
1245 /// Clients may send an empty string here to request all the symbols.
1246 std::string query;
1247
1248 /// Max results to return, overriding global default. 0 means no limit.
1249 /// Clangd extension.
1250 std::optional<int> limit;
1251};
1252bool fromJSON(const llvm::json::Value &, WorkspaceSymbolParams &,
1253 llvm::json::Path);
1254
1258llvm::json::Value toJSON(const ApplyWorkspaceEditParams &);
1259
1261 bool applied = true;
1262 std::optional<std::string> failureReason;
1263};
1264bool fromJSON(const llvm::json::Value &, ApplyWorkspaceEditResponse &,
1265 llvm::json::Path);
1266
1268 /// The text document.
1270
1271 /// The position inside the text document.
1273};
1274bool fromJSON(const llvm::json::Value &, TextDocumentPositionParams &,
1275 llvm::json::Path);
1276
1278 /// Completion was triggered by typing an identifier (24x7 code
1279 /// complete), manual invocation (e.g Ctrl+Space) or via API.
1281 /// Completion was triggered by a trigger character specified by
1282 /// the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
1284 /// Completion was re-triggered as the current completion list is incomplete.
1286};
1287
1289 /// How the completion was triggered.
1291 /// The trigger character (a single character) that has trigger code complete.
1292 /// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
1293 std::string triggerCharacter;
1294};
1295bool fromJSON(const llvm::json::Value &, CompletionContext &, llvm::json::Path);
1296
1299
1300 /// Max results to return, overriding global default. 0 means no limit.
1301 /// Clangd extension.
1302 std::optional<int> limit;
1303};
1304bool fromJSON(const llvm::json::Value &, CompletionParams &, llvm::json::Path);
1305
1310llvm::json::Value toJSON(const MarkupContent &MC);
1311
1312struct Hover {
1313 /// The hover's content
1315
1316 /// An optional range is a range inside a text document
1317 /// that is used to visualize a hover, e.g. by changing the background color.
1318 std::optional<Range> range;
1319};
1320llvm::json::Value toJSON(const Hover &H);
1321
1322/// Defines whether the insert text in a completion item should be interpreted
1323/// as plain text or a snippet.
1326 /// The primary text to be inserted is treated as a plain string.
1328 /// The primary text to be inserted is treated as a snippet.
1329 ///
1330 /// A snippet can define tab stops and placeholders with `$1`, `$2`
1331 /// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end
1332 /// of the snippet. Placeholders with equal identifiers are linked, that is
1333 /// typing in one will update others too.
1334 ///
1335 /// See also:
1336 /// https://github.com/Microsoft/vscode/blob/main/src/vs/editor/contrib/snippet/snippet.md
1338};
1339
1340/// Additional details for a completion item label.
1342 /// An optional string which is rendered less prominently directly after label
1343 /// without any spacing. Should be used for function signatures or type
1344 /// annotations.
1345 std::string detail;
1346
1347 /// An optional string which is rendered less prominently after
1348 /// CompletionItemLabelDetails.detail. Should be used for fully qualified
1349 /// names or file path.
1350 std::string description;
1351};
1352llvm::json::Value toJSON(const CompletionItemLabelDetails &);
1353
1355 /// The label of this completion item. By default also the text that is
1356 /// inserted when selecting this completion.
1357 std::string label;
1358
1359 /// Additional details for the label.
1360 std::optional<CompletionItemLabelDetails> labelDetails;
1361
1362 /// The kind of this completion item. Based of the kind an icon is chosen by
1363 /// the editor.
1365
1366 /// A human-readable string with additional information about this item, like
1367 /// type or symbol information.
1368 std::string detail;
1369
1370 /// A human-readable string that represents a doc-comment.
1371 std::optional<MarkupContent> documentation;
1372
1373 /// A string that should be used when comparing this item with other items.
1374 /// When `falsy` the label is used.
1375 std::string sortText;
1376
1377 /// A string that should be used when filtering a set of completion items.
1378 /// When `falsy` the label is used.
1379 std::string filterText;
1380
1381 /// A string that should be inserted to a document when selecting this
1382 /// completion. When `falsy` the label is used.
1383 std::string insertText;
1384
1385 /// The format of the insert text. The format applies to both the `insertText`
1386 /// property and the `newText` property of a provided `textEdit`.
1388
1389 /// An edit which is applied to a document when selecting this completion.
1390 /// When an edit is provided `insertText` is ignored.
1391 ///
1392 /// Note 1: The text edit's range as well as both ranges from an insert
1393 /// replace edit must be a single line range and must contain the position
1394 /// at which completion has been requested.
1395 /// Note 2: If an `InsertReplaceEdit` is returned, the edit's insert range
1396 /// must be a prefix of the edit's replace range, meaning it must be
1397 /// contained in and starting at the same position.
1398 std::optional<std::variant<TextEdit, InsertReplaceEdit>> textEdit;
1399
1400 /// An optional array of additional text edits that are applied when selecting
1401 /// this completion. Edits must not overlap with the main edit nor with
1402 /// themselves.
1403 std::vector<TextEdit> additionalTextEdits;
1404
1405 /// Indicates if this item is deprecated.
1406 bool deprecated = false;
1407
1408 /// The score that clangd calculates to rank the returned completions.
1409 /// This excludes the fuzzy-match between `filterText` and the partial word.
1410 /// This can be used to re-rank results as the user types, using client-side
1411 /// fuzzy-matching (that score should be multiplied with this one).
1412 /// This is a clangd extension.
1413 float score = 0.f;
1414
1415 // TODO: Add custom commitCharacters for some of the completion items. For
1416 // example, it makes sense to use () only for the functions.
1417 // TODO(krasimir): The following optional fields defined by the language
1418 // server protocol are unsupported:
1419 //
1420 // data?: any - A data entry field that is preserved on a completion item
1421 // between a completion and a completion resolve request.
1422};
1423llvm::json::Value toJSON(const CompletionItem &);
1424llvm::raw_ostream &operator<<(llvm::raw_ostream &, const CompletionItem &);
1425
1426/// Remove the labelDetails field (for clients that don't support it).
1427/// Places the information into other fields of the completion item.
1429
1430bool operator<(const CompletionItem &, const CompletionItem &);
1431
1432/// Represents a collection of completion items to be presented in the editor.
1434 /// The list is not complete. Further typing should result in recomputing the
1435 /// list.
1436 bool isIncomplete = false;
1437
1438 /// The completion items.
1439 std::vector<CompletionItem> items;
1440};
1441llvm::json::Value toJSON(const CompletionList &);
1442
1443/// A single parameter of a particular signature.
1445
1446 /// The label of this parameter. Ignored when labelOffsets is set.
1447 std::string labelString;
1448
1449 /// Inclusive start and exclusive end offsets withing the containing signature
1450 /// label.
1451 /// Offsets are computed by lspLength(), which counts UTF-16 code units by
1452 /// default but that can be overriden, see its documentation for details.
1453 std::optional<std::pair<unsigned, unsigned>> labelOffsets;
1454
1455 /// The documentation of this parameter. Optional.
1456 std::string documentation;
1457};
1458llvm::json::Value toJSON(const ParameterInformation &);
1459
1460/// Represents the signature of something callable.
1462
1463 /// The label of this signature. Mandatory.
1464 std::string label;
1465
1466 /// The documentation of this signature. Optional.
1468
1469 /// The parameters of this signature.
1470 std::vector<ParameterInformation> parameters;
1471};
1472llvm::json::Value toJSON(const SignatureInformation &);
1473llvm::raw_ostream &operator<<(llvm::raw_ostream &,
1474 const SignatureInformation &);
1475
1476/// Represents the signature of a callable.
1478
1479 /// The resulting signatures.
1480 std::vector<SignatureInformation> signatures;
1481
1482 /// The active signature.
1484
1485 /// The active parameter of the active signature.
1487
1488 /// Position of the start of the argument list, including opening paren. e.g.
1489 /// foo("first arg", "second arg",
1490 /// ^-argListStart ^-cursor
1491 /// This is a clangd-specific extension, it is only available via C++ API and
1492 /// not currently serialized for the LSP.
1494};
1495llvm::json::Value toJSON(const SignatureHelp &);
1496
1498 /// The document that was opened.
1500
1501 /// The position at which this request was sent.
1503
1504 /// The new name of the symbol.
1505 std::string newName;
1506};
1507bool fromJSON(const llvm::json::Value &, RenameParams &, llvm::json::Path);
1508llvm::json::Value toJSON(const RenameParams &);
1509
1511 /// Range of the string to rename.
1513 /// Placeholder text to use in the editor if non-empty.
1514 std::string placeholder;
1515};
1516llvm::json::Value toJSON(const PrepareRenameResult &PRR);
1517
1518enum class DocumentHighlightKind { Text = 1, Read = 2, Write = 3 };
1519
1520/// A document highlight is a range inside a text document which deserves
1521/// special attention. Usually a document highlight is visualized by changing
1522/// the background color of its range.
1523
1525 /// The range this highlight applies to.
1527
1528 /// The highlight kind, default is DocumentHighlightKind.Text.
1530
1531 friend bool operator<(const DocumentHighlight &LHS,
1532 const DocumentHighlight &RHS) {
1533 int LHSKind = static_cast<int>(LHS.kind);
1534 int RHSKind = static_cast<int>(RHS.kind);
1535 return std::tie(LHS.range, LHSKind) < std::tie(RHS.range, RHSKind);
1536 }
1537
1538 friend bool operator==(const DocumentHighlight &LHS,
1539 const DocumentHighlight &RHS) {
1540 return LHS.kind == RHS.kind && LHS.range == RHS.range;
1541 }
1542};
1543llvm::json::Value toJSON(const DocumentHighlight &DH);
1544llvm::raw_ostream &operator<<(llvm::raw_ostream &, const DocumentHighlight &);
1545
1546enum class TypeHierarchyDirection { Children = 0, Parents = 1, Both = 2 };
1547bool fromJSON(const llvm::json::Value &E, TypeHierarchyDirection &Out,
1548 llvm::json::Path);
1549
1550/// The type hierarchy params is an extension of the
1551/// `TextDocumentPositionsParams` with optional properties which can be used to
1552/// eagerly resolve the item when requesting from the server.
1554 /// The hierarchy levels to resolve. `0` indicates no level.
1555 /// This is a clangd extension.
1556 int resolve = 0;
1557
1558 /// The direction of the hierarchy levels to resolve.
1559 /// This is a clangd extension.
1561};
1562bool fromJSON(const llvm::json::Value &, TypeHierarchyPrepareParams &,
1563 llvm::json::Path);
1564
1566 /// The name of this item.
1567 std::string name;
1568
1569 /// The kind of this item.
1571
1572 /// More detail for this item, e.g. the signature of a function.
1573 std::optional<std::string> detail;
1574
1575 /// The resource identifier of this item.
1577
1578 /// The range enclosing this symbol not including leading/trailing whitespace
1579 /// but everything else, e.g. comments and code.
1581
1582 /// The range that should be selected and revealed when this symbol is being
1583 /// picked, e.g. the name of a function. Must be contained by the `range`.
1585
1586 /// Used to resolve a client provided item back.
1589 /// std::nullopt means parents aren't resolved and empty is no parents.
1590 std::optional<std::vector<ResolveParams>> parents;
1591 };
1592 /// A data entry field that is preserved between a type hierarchy prepare and
1593 /// supertypes or subtypes requests. It could also be used to identify the
1594 /// type hierarchy in the server, helping improve the performance on resolving
1595 /// supertypes and subtypes.
1597
1598 /// `true` if the hierarchy item is deprecated. Otherwise, `false`.
1599 /// This is a clangd exntesion.
1600 bool deprecated = false;
1601
1602 /// This is a clangd exntesion.
1603 std::optional<std::vector<TypeHierarchyItem>> parents;
1604
1605 /// If this type hierarchy item is resolved, it contains the direct children
1606 /// of the current item. Could be empty if the item does not have any
1607 /// descendants. If not defined, the children have not been resolved.
1608 /// This is a clangd exntesion.
1609 std::optional<std::vector<TypeHierarchyItem>> children;
1610};
1611llvm::json::Value toJSON(const TypeHierarchyItem::ResolveParams &);
1613llvm::json::Value toJSON(const TypeHierarchyItem &);
1614llvm::raw_ostream &operator<<(llvm::raw_ostream &, const TypeHierarchyItem &);
1615bool fromJSON(const llvm::json::Value &, TypeHierarchyItem &, llvm::json::Path);
1616
1617/// Parameters for the `typeHierarchy/resolve` request.
1619 /// The item to resolve.
1621
1622 /// The hierarchy levels to resolve. `0` indicates no level.
1624
1625 /// The direction of the hierarchy levels to resolve.
1627};
1628bool fromJSON(const llvm::json::Value &, ResolveTypeHierarchyItemParams &,
1629 llvm::json::Path);
1630
1631/// The parameter of a `textDocument/prepareCallHierarchy` request.
1633
1634/// Represents programming constructs like functions or constructors
1635/// in the context of call hierarchy.
1637 /// The name of this item.
1638 std::string name;
1639
1640 /// The kind of this item.
1642
1643 /// Tags for this item.
1644 std::vector<SymbolTag> tags;
1645
1646 /// More detaill for this item, e.g. the signature of a function.
1647 std::string detail;
1648
1649 /// The resource identifier of this item.
1651
1652 /// The range enclosing this symbol not including leading / trailing
1653 /// whitespace but everything else, e.g. comments and code.
1655
1656 /// The range that should be selected and revealed when this symbol
1657 /// is being picked, e.g. the name of a function.
1658 /// Must be contained by `Rng`.
1660
1661 /// An optional 'data' field, which can be used to identify a call
1662 /// hierarchy item in an incomingCalls or outgoingCalls request.
1663 std::string data;
1664};
1665llvm::json::Value toJSON(const CallHierarchyItem &);
1666bool fromJSON(const llvm::json::Value &, CallHierarchyItem &, llvm::json::Path);
1667
1668/// The parameter of a `callHierarchy/incomingCalls` request.
1672bool fromJSON(const llvm::json::Value &, CallHierarchyIncomingCallsParams &,
1673 llvm::json::Path);
1674
1675/// Represents an incoming call, e.g. a caller of a method or constructor.
1677 /// The item that makes the call.
1679
1680 /// The range at which the calls appear.
1681 /// This is relative to the caller denoted by `From`.
1682 std::vector<Range> fromRanges;
1683
1684 /// For the case of being a virtual function we also return calls
1685 /// to the base function. This caller might be a false positive.
1686 /// We currently have no way of discerning this.
1687 /// This is a clangd extension.
1688 bool mightNeverCall = false;
1689};
1690llvm::json::Value toJSON(const CallHierarchyIncomingCall &);
1691
1692/// The parameter of a `callHierarchy/outgoingCalls` request.
1696bool fromJSON(const llvm::json::Value &, CallHierarchyOutgoingCallsParams &,
1697 llvm::json::Path);
1698
1699/// Represents an outgoing call, e.g. calling a getter from a method or
1700/// a method from a constructor etc.
1702 /// The item that is called.
1704
1705 /// The range at which this item is called.
1706 /// This is the range relative to the caller, and not `To`.
1707 std::vector<Range> fromRanges;
1708};
1709llvm::json::Value toJSON(const CallHierarchyOutgoingCall &);
1710
1711/// A parameter literal used in inlay hint requests.
1713 /// The text document.
1715
1716 /// The visible document range for which inlay hints should be computed.
1717 ///
1718 /// std::nullopt is a clangd extension, which hints for computing hints on the
1719 /// whole file.
1720 std::optional<Range> range;
1721};
1722bool fromJSON(const llvm::json::Value &, InlayHintsParams &, llvm::json::Path);
1723
1724/// Inlay hint kinds.
1725enum class InlayHintKind {
1726 /// An inlay hint that for a type annotation.
1727 ///
1728 /// An example of a type hint is a hint in this position:
1729 /// auto var ^ = expr;
1730 /// which shows the deduced type of the variable.
1731 Type = 1,
1732
1733 /// An inlay hint that is for a parameter.
1734 ///
1735 /// An example of a parameter hint is a hint in this position:
1736 /// func(^arg);
1737 /// which shows the name of the corresponding parameter.
1739
1740 /// A hint before an element of an aggregate braced initializer list,
1741 /// indicating what it is initializing.
1742 /// Pair{^1, ^2};
1743 /// Uses designator syntax, e.g. `.first:`.
1744 /// This is a clangd extension.
1746
1747 /// A hint after function, type or namespace definition, indicating the
1748 /// defined symbol name of the definition.
1749 ///
1750 /// An example of a decl name hint in this position:
1751 /// void func() {
1752 /// } ^
1753 /// Uses comment-like syntax like "// func".
1754 /// This is a clangd extension.
1756
1757 /// An inlay hint that is for a default argument.
1758 ///
1759 /// An example of a parameter hint for a default argument:
1760 /// void foo(bool A = true);
1761 /// foo(^);
1762 /// Adds an inlay hint "A: true".
1763 /// This is a clangd extension.
1765
1766 /// Other ideas for hints that are not currently implemented:
1767 ///
1768 /// * Chaining hints, showing the types of intermediate expressions
1769 /// in a chain of function calls.
1770 /// * Hints indicating implicit conversions or implicit constructor calls.
1771};
1772llvm::json::Value toJSON(const InlayHintKind &);
1773
1774/// An inlay hint label part allows for interactive and composite labels
1775/// of inlay hints.
1777
1779
1781 std::optional<Location> location = std::nullopt)
1782 : value(std::move(value)), location(std::move(location)) {}
1783
1784 /// The value of this label part.
1785 std::string value;
1786
1787 /// The tooltip text when you hover over this label part. Depending on
1788 /// the client capability `inlayHint.resolveSupport`, clients might resolve
1789 /// this property late using the resolve request.
1790 std::optional<MarkupContent> tooltip;
1791
1792 /// An optional source code location that represents this
1793 /// label part.
1794 ///
1795 /// The editor will use this location for the hover and for code navigation
1796 /// features: This part will become a clickable link that resolves to the
1797 /// definition of the symbol at the given location (not necessarily the
1798 /// location itself), it shows the hover that shows at the given location,
1799 /// and it shows a context menu with further code navigation commands.
1800 ///
1801 /// Depending on the client capability `inlayHint.resolveSupport` clients
1802 /// might resolve this property late using the resolve request.
1803 std::optional<Location> location;
1804
1805 /// An optional command for this label part.
1806 ///
1807 /// Depending on the client capability `inlayHint.resolveSupport` clients
1808 /// might resolve this property late using the resolve request.
1809 std::optional<Command> command;
1810};
1811llvm::json::Value toJSON(const InlayHintLabelPart &);
1812bool operator==(const InlayHintLabelPart &, const InlayHintLabelPart &);
1813bool operator<(const InlayHintLabelPart &, const InlayHintLabelPart &);
1814llvm::raw_ostream &operator<<(llvm::raw_ostream &, const InlayHintLabelPart &);
1815
1816/// Inlay hint information.
1818 /// The position of this hint.
1820
1821 /// The label of this hint. A human readable string or an array of
1822 /// InlayHintLabelPart label parts.
1823 ///
1824 /// *Note* that neither the string nor the label part can be empty.
1825 std::vector<InlayHintLabelPart> label;
1826
1827 /// The kind of this hint. Can be omitted in which case the client should fall
1828 /// back to a reasonable default.
1830
1831 /// Render padding before the hint.
1832 ///
1833 /// Note: Padding should use the editor's background color, not the
1834 /// background color of the hint itself. That means padding can be used
1835 /// to visually align/separate an inlay hint.
1836 bool paddingLeft = false;
1837
1838 /// Render padding after the hint.
1839 ///
1840 /// Note: Padding should use the editor's background color, not the
1841 /// background color of the hint itself. That means padding can be used
1842 /// to visually align/separate an inlay hint.
1843 bool paddingRight = false;
1844
1845 /// The range of source code to which the hint applies.
1846 ///
1847 /// For example, a parameter hint may have the argument as its range.
1848 /// The range allows clients more flexibility of when/how to display the hint.
1849 /// This is an (unserialized) clangd extension.
1851
1852 /// Join the label[].value together.
1853 std::string joinLabels() const;
1854};
1855llvm::json::Value toJSON(const InlayHint &);
1856bool operator==(const InlayHint &, const InlayHint &);
1857bool operator<(const InlayHint &, const InlayHint &);
1858llvm::raw_ostream &operator<<(llvm::raw_ostream &, InlayHintKind);
1859
1861 /// Include the declaration of the current symbol.
1863};
1864
1868bool fromJSON(const llvm::json::Value &, ReferenceParams &, llvm::json::Path);
1869
1870/// Clangd extension: indicates the current state of the file in clangd,
1871/// sent from server via the `textDocument/clangd.fileStatus` notification.
1873 /// The text document's URI.
1875 /// The human-readable string presents the current state of the file, can be
1876 /// shown in the UI (e.g. status bar).
1877 std::string state;
1878 // FIXME: add detail messages.
1879};
1880llvm::json::Value toJSON(const FileStatus &);
1881
1882/// Specifies a single semantic token in the document.
1883/// This struct is not part of LSP, which just encodes lists of tokens as
1884/// arrays of numbers directly.
1886 /// token line number, relative to the previous token
1887 unsigned deltaLine = 0;
1888 /// token start character, relative to the previous token
1889 /// (relative to 0 or the previous token's start if they are on the same line)
1890 unsigned deltaStart = 0;
1891 /// the length of the token. A token cannot be multiline
1892 unsigned length = 0;
1893 /// will be looked up in `SemanticTokensLegend.tokenTypes`
1894 unsigned tokenType = 0;
1895 /// each set bit will be looked up in `SemanticTokensLegend.tokenModifiers`
1896 unsigned tokenModifiers = 0;
1897};
1898bool operator==(const SemanticToken &, const SemanticToken &);
1899
1900/// A versioned set of tokens.
1902 // An optional result id. If provided and clients support delta updating
1903 // the client will include the result id in the next semantic token request.
1904 // A server can then instead of computing all semantic tokens again simply
1905 // send a delta.
1906 std::string resultId;
1907
1908 /// The actual tokens.
1909 std::vector<SemanticToken> tokens; // encoded as a flat integer array.
1910};
1911llvm::json::Value toJSON(const SemanticTokens &);
1912
1913/// Body of textDocument/semanticTokens/full request.
1915 /// The text document.
1917};
1918bool fromJSON(const llvm::json::Value &, SemanticTokensParams &,
1919 llvm::json::Path);
1920
1921/// Body of textDocument/semanticTokens/full/delta request.
1922/// Requests the changes in semantic tokens since a previous response.
1924 /// The text document.
1926 /// The previous result id.
1927 std::string previousResultId;
1928};
1929bool fromJSON(const llvm::json::Value &Params, SemanticTokensDeltaParams &R,
1930 llvm::json::Path);
1931
1932/// Describes a replacement of a contiguous range of semanticTokens.
1934 // LSP specifies `start` and `deleteCount` which are relative to the array
1935 // encoding of the previous tokens.
1936 // We use token counts instead, and translate when serializing this struct.
1937 unsigned startToken = 0;
1938 unsigned deleteTokens = 0;
1939 std::vector<SemanticToken> tokens; // encoded as a flat integer array
1940};
1941llvm::json::Value toJSON(const SemanticTokensEdit &);
1942
1943/// This models LSP SemanticTokensDelta | SemanticTokens, which is the result of
1944/// textDocument/semanticTokens/full/delta.
1946 std::string resultId;
1947 /// Set if we computed edits relative to a previous set of tokens.
1948 std::optional<std::vector<SemanticTokensEdit>> edits;
1949 /// Set if we computed a fresh set of tokens.
1950 std::optional<std::vector<SemanticToken>> tokens; // encoded as integer array
1951};
1952llvm::json::Value toJSON(const SemanticTokensOrDelta &);
1953
1954/// Parameters for the inactive regions (server-side) push notification.
1955/// This is a clangd extension.
1957 /// The textdocument these inactive regions belong to.
1959 /// The inactive regions that should be sent.
1960 std::vector<Range> InactiveRegions;
1961};
1962llvm::json::Value toJSON(const InactiveRegionsParams &InactiveRegions);
1963
1965 /// The text document.
1967
1968 /// The positions inside the text document.
1969 std::vector<Position> positions;
1970};
1971bool fromJSON(const llvm::json::Value &, SelectionRangeParams &,
1972 llvm::json::Path);
1973
1975 /**
1976 * The range of this selection range.
1977 */
1979 /**
1980 * The parent selection range containing this range. Therefore `parent.range`
1981 * must contain `this.range`.
1982 */
1983 std::unique_ptr<SelectionRange> parent;
1984};
1985llvm::json::Value toJSON(const SelectionRange &);
1986
1987/// Parameters for the document link request.
1989 /// The document to provide document links for.
1991};
1992bool fromJSON(const llvm::json::Value &, DocumentLinkParams &,
1993 llvm::json::Path);
1994
1995/// A range in a text document that links to an internal or external resource,
1996/// like another text document or a web site.
1998 /// The range this link applies to.
2000
2001 /// The uri this link points to. If missing a resolve request is sent later.
2003
2004 // TODO(forster): The following optional fields defined by the language
2005 // server protocol are unsupported:
2006 //
2007 // data?: any - A data entry field that is preserved on a document link
2008 // between a DocumentLinkRequest and a
2009 // DocumentLinkResolveRequest.
2010
2011 friend bool operator==(const DocumentLink &LHS, const DocumentLink &RHS) {
2012 return LHS.range == RHS.range && LHS.target == RHS.target;
2013 }
2014
2015 friend bool operator!=(const DocumentLink &LHS, const DocumentLink &RHS) {
2016 return !(LHS == RHS);
2017 }
2018};
2019llvm::json::Value toJSON(const DocumentLink &DocumentLink);
2020
2021// FIXME(kirillbobyrev): Add FoldingRangeClientCapabilities so we can support
2022// per-line-folding editors.
2026bool fromJSON(const llvm::json::Value &, FoldingRangeParams &,
2027 llvm::json::Path);
2028
2029/// Stores information about a region of code that can be folded.
2031 unsigned startLine = 0;
2033 unsigned endLine = 0;
2035
2036 const static llvm::StringLiteral REGION_KIND;
2037 const static llvm::StringLiteral COMMENT_KIND;
2038 const static llvm::StringLiteral IMPORT_KIND;
2039 std::string kind;
2040};
2041llvm::json::Value toJSON(const FoldingRange &Range);
2042
2043/// Keys starting with an underscore(_) represent leaves, e.g. _total or _self
2044/// for memory usage of whole subtree or only that specific node in bytes. All
2045/// other keys represents children. An example:
2046/// {
2047/// "_self": 0,
2048/// "_total": 8,
2049/// "child1": {
2050/// "_self": 4,
2051/// "_total": 4,
2052/// }
2053/// "child2": {
2054/// "_self": 2,
2055/// "_total": 4,
2056/// "child_deep": {
2057/// "_self": 2,
2058/// "_total": 2,
2059/// }
2060/// }
2061/// }
2062llvm::json::Value toJSON(const MemoryTree &MT);
2063
2064/// Payload for textDocument/ast request.
2065/// This request is a clangd extension.
2067 /// The text document.
2069
2070 /// The position of the node to be dumped.
2071 /// The highest-level node that entirely contains the range will be returned.
2072 /// If no range is given, the root translation unit node will be returned.
2073 std::optional<Range> range;
2074};
2075bool fromJSON(const llvm::json::Value &, ASTParams &, llvm::json::Path);
2076
2077/// Simplified description of a clang AST node.
2078/// This is clangd's internal representation of C++ code.
2079struct ASTNode {
2080 /// The general kind of node, such as "expression"
2081 /// Corresponds to the base AST node type such as Expr.
2082 std::string role;
2083 /// The specific kind of node this is, such as "BinaryOperator".
2084 /// This is usually a concrete node class (with Expr etc suffix dropped).
2085 /// When there's no hierarchy (e.g. TemplateName), the variant (NameKind).
2086 std::string kind;
2087 /// Brief additional information, such as "||" for the particular operator.
2088 /// The information included depends on the node kind, and may be empty.
2089 std::string detail;
2090 /// A one-line dump of detailed information about the node.
2091 /// This includes role/kind/description information, but is rather cryptic.
2092 /// It is similar to the output from `clang -Xclang -ast-dump`.
2093 /// May be empty for certain types of nodes.
2094 std::string arcana;
2095 /// The range of the original source file covered by this node.
2096 /// May be missing for implicit nodes, or those created by macro expansion.
2097 std::optional<Range> range;
2098 /// Nodes nested within this one, such as the operands of a BinaryOperator.
2099 std::vector<ASTNode> children;
2100};
2101llvm::json::Value toJSON(const ASTNode &);
2102llvm::raw_ostream &operator<<(llvm::raw_ostream &, const ASTNode &);
2103
2104} // namespace clangd
2105} // namespace clang
2106
2107namespace llvm {
2108
2109template <> struct DenseMapInfo<clang::clangd::Range> {
2111 static inline Range getEmptyKey() {
2112 static clang::clangd::Position Tomb{-1, -1};
2113 static Range R{Tomb, Tomb};
2114 return R;
2115 }
2116 static inline Range getTombstoneKey() {
2117 static clang::clangd::Position Tomb{-2, -2};
2118 static Range R{Tomb, Tomb};
2119 return R;
2120 }
2121 static unsigned getHashValue(const Range &Val) {
2122 return llvm::hash_combine(Val.start.line, Val.start.character, Val.end.line,
2123 Val.end.character);
2124 }
2125 static bool isEqual(const Range &LHS, const Range &RHS) {
2126 return std::tie(LHS.start, LHS.end) == std::tie(RHS.start, RHS.end);
2127 }
2128};
2129
2130template <> struct format_provider<clang::clangd::Position> {
2131 static void format(const clang::clangd::Position &Pos, raw_ostream &OS,
2132 StringRef Style) {
2133 assert(Style.empty() && "style modifiers for this type are not supported");
2134 OS << Pos;
2135 }
2136};
2137} // namespace llvm
2138
2139// NOLINTEND(readability-identifier-naming)
2140
2141#endif
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
An Event<T> allows events of type T to be broadcast to listeners.
Definition Function.h:31
Values in a Context are indexed by typed keys.
Definition Context.h:40
LSPError(std::string Message, ErrorCode Code)
Definition Protocol.h:70
std::error_code convertToErrorCode() const override
Definition Protocol.h:76
void log(llvm::raw_ostream &OS) const override
Definition Protocol.h:73
std::string Message
Definition Protocol.h:66
A URI describes the location of a source file.
Definition URI.h:28
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
Definition URI.cpp:237
std::string toString() const
Returns a string URI with all components percent-encoded.
Definition URI.cpp:160
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
Definition AST.cpp:44
@ Created
The file got created.
Definition Protocol.h:831
@ Deleted
The file got deleted.
Definition Protocol.h:835
@ Changed
The file got changed.
Definition Protocol.h:833
constexpr auto CompletionItemKindMax
Definition Protocol.h:383
@ Warning
A warning message.
Definition Protocol.h:753
@ Info
An information message.
Definition Protocol.h:755
@ Error
An error message.
Definition Protocol.h:751
@ Log
A log message.
Definition Protocol.h:757
constexpr auto CompletionItemKindMin
Definition Protocol.h:381
SymbolTag
Symbol tags are extra annotations that can be attached to a symbol.
Definition Protocol.h:1126
constexpr auto SymbolKindMin
Definition Protocol.h:422
CompletionItemKind
The kind of a completion entry.
Definition Protocol.h:351
@ Invoked
Completion was triggered by typing an identifier (24x7 code complete), manual invocation (e....
Definition Protocol.h:1280
@ TriggerTriggerForIncompleteCompletions
Completion was re-triggered as the current completion list is incomplete.
Definition Protocol.h:1285
@ TriggerCharacter
Completion was triggered by a trigger character specified by the triggerCharacters properties of the ...
Definition Protocol.h:1283
std::string ChangeAnnotationIdentifier
Definition Protocol.h:242
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
Definition Headers.cpp:356
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
std::bitset< SymbolKindMax+1 > SymbolKindBitset
Definition Protocol.h:424
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
Definition Index.cpp:45
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
Definition Protocol.cpp:288
void removeCompletionLabelDetails(CompletionItem &C)
Remove the labelDetails field (for clients that don't support it).
NoParams InitializedParams
Definition Protocol.h:334
bool operator<(const Ref &L, const Ref &R)
Definition Ref.h:98
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
Definition Protocol.h:385
InlayHintKind
Inlay hint kinds.
Definition Protocol.h:1725
@ BlockEnd
A hint after function, type or namespace definition, indicating the defined symbol name of the defini...
Definition Protocol.h:1755
@ DefaultArgument
An inlay hint that is for a default argument.
Definition Protocol.h:1764
@ Parameter
An inlay hint that is for a parameter.
Definition Protocol.h:1738
@ Type
An inlay hint that for a type annotation.
Definition Protocol.h:1731
@ Designator
A hint before an element of an aggregate braced initializer list, indicating what it is initializing.
Definition Protocol.h:1745
constexpr auto SymbolKindMax
Definition Protocol.h:423
@ Deprecated
Deprecated or obsolete code.
Definition Protocol.h:936
@ Unnecessary
Unused or unnecessary code.
Definition Protocol.h:932
SymbolKind indexSymbolKindToSymbolKind(const index::SymbolInfo &Info)
Definition Protocol.cpp:306
TextDocumentSyncKind
Defines how the host (editor) should sync document changes to the language server.
Definition Protocol.h:338
@ Incremental
Documents are synced by sending the full content on open.
Definition Protocol.h:347
@ Full
Documents are synced by always sending the full content of the document.
Definition Protocol.h:343
InsertTextFormat
Defines whether the insert text in a completion item should be interpreted as plain text or a snippet...
Definition Protocol.h:1324
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request, llvm::json::Path P)
Definition Index.cpp:30
SymbolKind
A symbol kind.
Definition Protocol.h:393
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Some operations such as code completion produce a set of candidates.
Definition Generators.h:150
Simplified description of a clang AST node.
Definition Protocol.h:2079
std::optional< Range > range
The range of the original source file covered by this node.
Definition Protocol.h:2097
std::vector< ASTNode > children
Nodes nested within this one, such as the operands of a BinaryOperator.
Definition Protocol.h:2099
std::string role
The general kind of node, such as "expression" Corresponds to the base AST node type such as Expr.
Definition Protocol.h:2082
std::string kind
The specific kind of node this is, such as "BinaryOperator".
Definition Protocol.h:2086
std::string detail
Brief additional information, such as "||" for the particular operator.
Definition Protocol.h:2089
std::string arcana
A one-line dump of detailed information about the node.
Definition Protocol.h:2094
Payload for textDocument/ast request.
Definition Protocol.h:2066
std::optional< Range > range
The position of the node to be dumped.
Definition Protocol.h:2073
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:2068
std::optional< std::string > failureReason
Definition Protocol.h:1262
Represents an incoming call, e.g. a caller of a method or constructor.
Definition Protocol.h:1676
CallHierarchyItem from
The item that makes the call.
Definition Protocol.h:1678
bool mightNeverCall
For the case of being a virtual function we also return calls to the base function.
Definition Protocol.h:1688
std::vector< Range > fromRanges
The range at which the calls appear.
Definition Protocol.h:1682
The parameter of a callHierarchy/incomingCalls request.
Definition Protocol.h:1669
Represents programming constructs like functions or constructors in the context of call hierarchy.
Definition Protocol.h:1636
std::string name
The name of this item.
Definition Protocol.h:1638
URIForFile uri
The resource identifier of this item.
Definition Protocol.h:1650
Range range
The range enclosing this symbol not including leading / trailing whitespace but everything else,...
Definition Protocol.h:1654
SymbolKind kind
The kind of this item.
Definition Protocol.h:1641
std::vector< SymbolTag > tags
Tags for this item.
Definition Protocol.h:1644
std::string data
An optional 'data' field, which can be used to identify a call hierarchy item in an incomingCalls or ...
Definition Protocol.h:1663
std::string detail
More detaill for this item, e.g. the signature of a function.
Definition Protocol.h:1647
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition Protocol.h:1659
Represents an outgoing call, e.g.
Definition Protocol.h:1701
std::vector< Range > fromRanges
The range at which this item is called.
Definition Protocol.h:1707
CallHierarchyItem to
The item that is called.
Definition Protocol.h:1703
The parameter of a callHierarchy/outgoingCalls request.
Definition Protocol.h:1693
The parameter of a textDocument/prepareCallHierarchy request.
Definition Protocol.h:1632
std::string description
A human-readable string which is rendered less prominent in the user interface.
Definition Protocol.h:288
std::string label
A human-readable string describing the actual change.
Definition Protocol.h:280
std::optional< bool > needsConfirmation
A flag which indicates that user confirmation is needed before applying the change.
Definition Protocol.h:284
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
Definition Protocol.h:595
std::vector< std::string > compilationCommand
Definition Protocol.h:597
bool HierarchicalDocumentSymbol
Client supports hierarchical document symbols.
Definition Protocol.h:497
bool WorkDoneProgress
The client supports progress notifications.
Definition Protocol.h:562
bool DiagnosticCategory
Whether the client accepts diagnostics with category attached to it using the "category" extension.
Definition Protocol.h:479
bool CompletionLabelDetail
The client has support for completion item label details.
Definition Protocol.h:532
MarkupKind HoverContentFormat
The content format that should be used for Hover requests.
Definition Protocol.h:554
bool CodeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
Definition Protocol.h:536
bool OffsetsInSignatureHelp
Client supports processing label offsets instead of a simple label string.
Definition Protocol.h:511
bool DiagnosticFixes
Whether the client accepts diagnostics with codeActions attached inline.
Definition Protocol.h:470
bool HasSignatureHelp
Client supports signature help.
Definition Protocol.h:501
bool TheiaSemanticHighlighting
Client supports Theia semantic highlighting extension.
Definition Protocol.h:546
bool SemanticTokenRefreshSupport
Whether the client implementation supports a refresh request sent from the server to the client.
Definition Protocol.h:576
bool DocumentChanges
The client supports versioned document changes for WorkspaceEdit.
Definition Protocol.h:579
bool ImplicitProgressCreation
The client supports implicit $/progress work-done progress streams, without a preceding window/workDo...
Definition Protocol.h:568
MarkupKind SignatureHelpDocumentationFormat
The documentation format that should be used for textDocument/signatureHelp.
Definition Protocol.h:516
bool DiagnosticRelatedInformation
Whether the client accepts diagnostics with related locations.
Definition Protocol.h:474
bool CompletionFixes
Client supports completions with additionalTextEdit near the cursor.
Definition Protocol.h:488
bool RenamePrepareSupport
The client supports testing for validity of rename operations before execution.
Definition Protocol.h:558
bool InsertReplace
Client supports insert replace edit to control different behavior if a completion item is inserted in...
Definition Protocol.h:528
std::optional< std::vector< OffsetEncoding > > PositionEncodings
Supported encodings for LSP character offsets.
Definition Protocol.h:550
bool CancelsStaleRequests
Whether the client claims to cancel stale requests.
Definition Protocol.h:572
std::optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
Definition Protocol.h:520
bool CompletionSnippets
Client supports snippets as insert text.
Definition Protocol.h:483
MarkupKind CompletionDocumentationFormat
The documentation format that should be used for textDocument/completion.
Definition Protocol.h:524
bool SemanticTokens
Client advertises support for the semanticTokens feature.
Definition Protocol.h:541
bool ChangeAnnotation
The client supports change annotations on text edits,.
Definition Protocol.h:582
bool LineFoldingOnly
Client signals that it only supports folding complete lines.
Definition Protocol.h:507
bool InactiveRegions
Whether the client supports the textDocument/inactiveRegions notification.
Definition Protocol.h:587
std::optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
Definition Protocol.h:465
bool ReferenceContainer
Client supports displaying a container string for results of textDocument/reference (clangd extension...
Definition Protocol.h:493
std::vector< Diagnostic > diagnostics
An array of diagnostics known on the client side overlapping the range provided to the textDocument/c...
Definition Protocol.h:1016
std::vector< std::string > only
Requested kind of actions to return.
Definition Protocol.h:1022
CodeActionContext context
Context carrying additional information.
Definition Protocol.h:1034
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Definition Protocol.h:1028
Range range
The range for which the command was invoked.
Definition Protocol.h:1031
A code action represents a change that can be performed in code, e.g.
Definition Protocol.h:1094
static const llvm::StringLiteral INFO_KIND
Definition Protocol.h:1103
bool isPreferred
Marks this as a preferred action.
Definition Protocol.h:1113
static const llvm::StringLiteral REFACTOR_KIND
Definition Protocol.h:1102
std::optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Definition Protocol.h:1106
static const llvm::StringLiteral QUICKFIX_KIND
Definition Protocol.h:1101
std::optional< WorkspaceEdit > edit
The workspace edit this code action performs.
Definition Protocol.h:1116
std::optional< Command > command
A command this code action executes.
Definition Protocol.h:1120
std::optional< std::string > kind
The kind of the code action.
Definition Protocol.h:1100
std::string title
A short, human-readable, title for this code action.
Definition Protocol.h:1096
Structure to capture a description for an error code.
Definition Protocol.h:941
std::string href
An URI to open with more information about the diagnostic error.
Definition Protocol.h:943
CompletionTriggerKind triggerKind
How the completion was triggered.
Definition Protocol.h:1290
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
Definition Protocol.h:1293
Additional details for a completion item label.
Definition Protocol.h:1341
std::string detail
An optional string which is rendered less prominently directly after label without any spacing.
Definition Protocol.h:1345
std::string description
An optional string which is rendered less prominently after CompletionItemLabelDetails....
Definition Protocol.h:1350
std::string sortText
A string that should be used when comparing this item with other items.
Definition Protocol.h:1375
std::string filterText
A string that should be used when filtering a set of completion items.
Definition Protocol.h:1379
std::string detail
A human-readable string with additional information about this item, like type or symbol information.
Definition Protocol.h:1368
InsertTextFormat insertTextFormat
The format of the insert text.
Definition Protocol.h:1387
CompletionItemKind kind
The kind of this completion item.
Definition Protocol.h:1364
std::vector< TextEdit > additionalTextEdits
An optional array of additional text edits that are applied when selecting this completion.
Definition Protocol.h:1403
std::optional< MarkupContent > documentation
A human-readable string that represents a doc-comment.
Definition Protocol.h:1371
std::string insertText
A string that should be inserted to a document when selecting this completion.
Definition Protocol.h:1383
bool deprecated
Indicates if this item is deprecated.
Definition Protocol.h:1406
std::optional< CompletionItemLabelDetails > labelDetails
Additional details for the label.
Definition Protocol.h:1360
std::optional< std::variant< TextEdit, InsertReplaceEdit > > textEdit
An edit which is applied to a document when selecting this completion.
Definition Protocol.h:1398
float score
The score that clangd calculates to rank the returned completions.
Definition Protocol.h:1413
std::string label
The label of this completion item.
Definition Protocol.h:1357
Represents a collection of completion items to be presented in the editor.
Definition Protocol.h:1433
std::vector< CompletionItem > items
The completion items.
Definition Protocol.h:1439
bool isIncomplete
The list is not complete.
Definition Protocol.h:1436
std::optional< int > limit
Max results to return, overriding global default.
Definition Protocol.h:1302
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Definition Protocol.h:605
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
Definition Protocol.h:608
Represents a related message and source code location for a diagnostic.
Definition Protocol.h:919
std::string message
The message of this related diagnostic information.
Definition Protocol.h:923
Location location
The location of this related diagnostic information.
Definition Protocol.h:921
std::optional< CodeDescription > codeDescription
An optional property to describe the error code.
Definition Protocol.h:960
llvm::json::Object data
A data entry field that is preserved between a textDocument/publishDiagnostics notification and textD...
Definition Protocol.h:992
std::optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
An array of related diagnostic information, e.g.
Definition Protocol.h:974
std::string code
The diagnostic's code. Can be omitted.
Definition Protocol.h:957
std::optional< std::vector< CodeAction > > codeActions
Clangd extension: code actions related to this diagnostic.
Definition Protocol.h:985
Range range
The range at which the message applies.
Definition Protocol.h:950
std::string source
A human-readable string describing the source of this diagnostic, e.g.
Definition Protocol.h:964
std::string message
The diagnostic's message.
Definition Protocol.h:967
int severity
The diagnostic's severity.
Definition Protocol.h:954
std::optional< std::string > category
The diagnostic's category.
Definition Protocol.h:980
llvm::SmallVector< DiagnosticTag, 1 > tags
Additional metadata about the diagnostic.
Definition Protocol.h:970
bool forceRebuild
Force a complete rebuild of the file, ignoring all cached state.
Definition Protocol.h:824
VersionedTextDocumentIdentifier textDocument
The document that did change.
Definition Protocol.h:809
std::optional< bool > wantDiagnostics
Forces diagnostics to be generated, or to not be generated, for this version of the file.
Definition Protocol.h:818
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
Definition Protocol.h:812
std::vector< FileEvent > changes
The actual file events.
Definition Protocol.h:850
TextDocumentIdentifier textDocument
The document that was closed.
Definition Protocol.h:780
TextDocumentItem textDocument
The document that was opened.
Definition Protocol.h:773
TextDocumentIdentifier textDocument
The document that was saved.
Definition Protocol.h:787
TextDocumentIdentifier textDocument
The document to format.
Definition Protocol.h:904
A document highlight is a range inside a text document which deserves special attention.
Definition Protocol.h:1524
Range range
The range this highlight applies to.
Definition Protocol.h:1526
friend bool operator<(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
Definition Protocol.h:1531
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
Definition Protocol.h:1529
friend bool operator==(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
Definition Protocol.h:1538
Parameters for the document link request.
Definition Protocol.h:1988
TextDocumentIdentifier textDocument
The document to provide document links for.
Definition Protocol.h:1990
Position position
The position at which this request was sent.
Definition Protocol.h:894
std::string ch
The character that has been typed.
Definition Protocol.h:897
TextDocumentIdentifier textDocument
The document to format.
Definition Protocol.h:891
TextDocumentIdentifier textDocument
The document to format.
Definition Protocol.h:871
TextDocumentIdentifier textDocument
The document to format.
Definition Protocol.h:881
std::vector< Range > ranges
The list of ranges to format.
Definition Protocol.h:884
TextDocumentIdentifier textDocument
Definition Protocol.h:911
Represents programming constructs like variables, classes, interfaces etc.
Definition Protocol.h:1157
std::vector< SymbolTag > tags
The tags for this symbol.
Definition Protocol.h:1171
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition Protocol.h:1181
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
Definition Protocol.h:1184
std::string detail
More detail for this symbol, e.g the signature of a function.
Definition Protocol.h:1162
std::string name
The name of this symbol.
Definition Protocol.h:1159
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
Definition Protocol.h:1177
bool deprecated
Indicates if this symbol is deprecated.
Definition Protocol.h:1168
SymbolKind kind
The kind of this symbol.
Definition Protocol.h:1165
std::string command
The identifier of the actual command handler.
Definition Protocol.h:1075
FileChangeType type
The change type.
Definition Protocol.h:844
URIForFile uri
The file's URI.
Definition Protocol.h:842
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
Definition Protocol.h:1872
URIForFile uri
The text document's URI.
Definition Protocol.h:1874
std::string state
The human-readable string presents the current state of the file, can be shown in the UI (e....
Definition Protocol.h:1877
TextDocumentIdentifier textDocument
Definition Protocol.h:2024
Stores information about a region of code that can be folded.
Definition Protocol.h:2030
static const llvm::StringLiteral REGION_KIND
Definition Protocol.h:2036
static const llvm::StringLiteral COMMENT_KIND
Definition Protocol.h:2037
static const llvm::StringLiteral IMPORT_KIND
Definition Protocol.h:2038
std::optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover,...
Definition Protocol.h:1318
MarkupContent contents
The hover's content.
Definition Protocol.h:1314
Parameters for the inactive regions (server-side) push notification.
Definition Protocol.h:1956
TextDocumentIdentifier TextDocument
The textdocument these inactive regions belong to.
Definition Protocol.h:1958
std::vector< Range > InactiveRegions
The inactive regions that should be sent.
Definition Protocol.h:1960
Clangd extension: parameters configurable at initialize time.
Definition Protocol.h:615
std::optional< std::string > compilationDatabasePath
Definition Protocol.h:620
bool FileStatus
Clients supports show file status for textDocument/clangd.fileStatus.
Definition Protocol.h:627
std::vector< std::string > fallbackFlags
Definition Protocol.h:624
ConfigurationSettings ConfigSettings
Definition Protocol.h:618
llvm::json::Object rawCapabilities
The same data as capabilities, but not parsed (to expose to modules).
Definition Protocol.h:656
InitializationOptions initializationOptions
User-provided initialization options.
Definition Protocol.h:662
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
Definition Protocol.h:654
std::optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
Definition Protocol.h:659
std::optional< int > processId
The process Id of the parent process that started the server.
Definition Protocol.h:637
std::optional< std::string > rootPath
The rootPath of the workspace.
Definition Protocol.h:643
std::optional< URIForFile > rootUri
The rootUri of the workspace.
Definition Protocol.h:648
An inlay hint label part allows for interactive and composite labels of inlay hints.
Definition Protocol.h:1776
std::optional< Location > location
An optional source code location that represents this label part.
Definition Protocol.h:1803
std::optional< MarkupContent > tooltip
The tooltip text when you hover over this label part.
Definition Protocol.h:1790
InlayHintLabelPart(std::string value, std::optional< Location > location=std::nullopt)
Definition Protocol.h:1780
std::optional< Command > command
An optional command for this label part.
Definition Protocol.h:1809
std::string value
The value of this label part.
Definition Protocol.h:1785
Inlay hint information.
Definition Protocol.h:1817
InlayHintKind kind
The kind of this hint.
Definition Protocol.h:1829
std::string joinLabels() const
Join the label[].value together.
bool paddingRight
Render padding after the hint.
Definition Protocol.h:1843
bool paddingLeft
Render padding before the hint.
Definition Protocol.h:1836
Position position
The position of this hint.
Definition Protocol.h:1819
std::vector< InlayHintLabelPart > label
The label of this hint.
Definition Protocol.h:1825
Range range
The range of source code to which the hint applies.
Definition Protocol.h:1850
A parameter literal used in inlay hint requests.
Definition Protocol.h:1712
std::optional< Range > range
The visible document range for which inlay hints should be computed.
Definition Protocol.h:1720
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1714
std::string newText
The string to be inserted.
Definition Protocol.h:267
Range replace
The range if the replace is requested.
Definition Protocol.h:273
Range insert
The range if the insert is requested.
Definition Protocol.h:270
URIForFile uri
The text document's URI.
Definition Protocol.h:214
friend bool operator==(const Location &LHS, const Location &RHS)
Definition Protocol.h:217
friend bool operator<(const Location &LHS, const Location &RHS)
Definition Protocol.h:225
friend bool operator!=(const Location &LHS, const Location &RHS)
Definition Protocol.h:221
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
Definition MemoryTree.h:30
A single parameter of a particular signature.
Definition Protocol.h:1444
std::string labelString
The label of this parameter. Ignored when labelOffsets is set.
Definition Protocol.h:1447
std::string documentation
The documentation of this parameter. Optional.
Definition Protocol.h:1456
std::optional< std::pair< unsigned, unsigned > > labelOffsets
Inclusive start and exclusive end offsets withing the containing signature label.
Definition Protocol.h:1453
friend bool operator==(const Position &LHS, const Position &RHS)
Definition Protocol.h:166
friend bool operator!=(const Position &LHS, const Position &RHS)
Definition Protocol.h:170
friend bool operator<=(const Position &LHS, const Position &RHS)
Definition Protocol.h:177
int line
Line position in a document (zero-based).
Definition Protocol.h:159
int character
Character offset on a line in a document (zero-based).
Definition Protocol.h:164
friend bool operator<(const Position &LHS, const Position &RHS)
Definition Protocol.h:173
std::string placeholder
Placeholder text to use in the editor if non-empty.
Definition Protocol.h:1514
Range range
Range of the string to rename.
Definition Protocol.h:1512
T value
The progress data.
Definition Protocol.h:677
llvm::json::Value token
The progress token provided by the client or server.
Definition Protocol.h:674
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
Definition Protocol.h:1003
std::optional< int64_t > version
The version number of the document the diagnostics are published for.
Definition Protocol.h:1005
URIForFile uri
The URI for which diagnostic information is reported.
Definition Protocol.h:1001
Position start
The range's start position.
Definition Protocol.h:188
Position end
The range's end position.
Definition Protocol.h:191
friend bool operator==(const Range &LHS, const Range &RHS)
Definition Protocol.h:193
friend bool operator<(const Range &LHS, const Range &RHS)
Definition Protocol.h:199
bool contains(Position Pos) const
Definition Protocol.h:203
bool contains(Range Rng) const
Definition Protocol.h:204
friend bool operator!=(const Range &LHS, const Range &RHS)
Definition Protocol.h:196
bool includeDeclaration
Include the declaration of the current symbol.
Definition Protocol.h:1862
Extends Locations returned by textDocument/references with extra info.
Definition Protocol.h:234
std::optional< std::string > containerName
clangd extension: contains the name of the function or class in which the reference occurs
Definition Protocol.h:237
TextDocumentIdentifier textDocument
The document that was opened.
Definition Protocol.h:1499
Position position
The position at which this request was sent.
Definition Protocol.h:1502
std::string newName
The new name of the symbol.
Definition Protocol.h:1505
Parameters for the typeHierarchy/resolve request.
Definition Protocol.h:1618
TypeHierarchyItem item
The item to resolve.
Definition Protocol.h:1620
int resolve
The hierarchy levels to resolve. 0 indicates no level.
Definition Protocol.h:1623
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition Protocol.h:1626
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1966
std::vector< Position > positions
The positions inside the text document.
Definition Protocol.h:1969
std::unique_ptr< SelectionRange > parent
The parent selection range containing this range.
Definition Protocol.h:1983
Range range
The range of this selection range.
Definition Protocol.h:1978
Specifies a single semantic token in the document.
Definition Protocol.h:1885
unsigned length
the length of the token. A token cannot be multiline
Definition Protocol.h:1892
unsigned deltaStart
token start character, relative to the previous token (relative to 0 or the previous token's start if...
Definition Protocol.h:1890
unsigned deltaLine
token line number, relative to the previous token
Definition Protocol.h:1887
unsigned tokenType
will be looked up in SemanticTokensLegend.tokenTypes
Definition Protocol.h:1894
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
Definition Protocol.h:1896
Body of textDocument/semanticTokens/full/delta request.
Definition Protocol.h:1923
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1925
std::string previousResultId
The previous result id.
Definition Protocol.h:1927
Describes a replacement of a contiguous range of semanticTokens.
Definition Protocol.h:1933
std::vector< SemanticToken > tokens
Definition Protocol.h:1939
This models LSP SemanticTokensDelta | SemanticTokens, which is the result of textDocument/semanticTok...
Definition Protocol.h:1945
std::optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
Definition Protocol.h:1950
std::optional< std::vector< SemanticTokensEdit > > edits
Set if we computed edits relative to a previous set of tokens.
Definition Protocol.h:1948
Body of textDocument/semanticTokens/full request.
Definition Protocol.h:1914
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1916
A versioned set of tokens.
Definition Protocol.h:1901
std::vector< SemanticToken > tokens
The actual tokens.
Definition Protocol.h:1909
The show message notification is sent from a server to a client to ask the client to display a partic...
Definition Protocol.h:763
MessageType type
The message type.
Definition Protocol.h:765
std::string message
The actual message.
Definition Protocol.h:767
Represents the signature of a callable.
Definition Protocol.h:1477
int activeSignature
The active signature.
Definition Protocol.h:1483
std::vector< SignatureInformation > signatures
The resulting signatures.
Definition Protocol.h:1480
Position argListStart
Position of the start of the argument list, including opening paren.
Definition Protocol.h:1493
int activeParameter
The active parameter of the active signature.
Definition Protocol.h:1486
Represents the signature of something callable.
Definition Protocol.h:1461
MarkupContent documentation
The documentation of this signature. Optional.
Definition Protocol.h:1467
std::vector< ParameterInformation > parameters
The parameters of this signature.
Definition Protocol.h:1470
std::string label
The label of this signature. Mandatory.
Definition Protocol.h:1464
Represents information about identifier.
Definition Protocol.h:1220
std::optional< Location > definitionRange
Definition Protocol.h:1236
std::optional< Location > declarationRange
Definition Protocol.h:1234
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol.
Definition Protocol.h:1230
Represents information about programming constructs like variables, classes, interfaces etc.
Definition Protocol.h:1191
std::vector< SymbolTag > tags
Tags for this symbol, e.g public, private, static, const etc.
Definition Protocol.h:1199
std::string containerName
The name of the symbol containing this symbol.
Definition Protocol.h:1205
Location location
The location of this symbol.
Definition Protocol.h:1202
SymbolKind kind
The kind of this symbol.
Definition Protocol.h:1196
std::optional< float > score
The score that clangd calculates to rank the returned symbols.
Definition Protocol.h:1213
std::string name
The name of this symbol.
Definition Protocol.h:1193
std::optional< Range > range
The range of the document that changed.
Definition Protocol.h:794
std::string text
The new text of the range/document.
Definition Protocol.h:800
std::optional< int > rangeLength
The length of the range that got replaced.
Definition Protocol.h:797
VersionedTextDocumentIdentifier textDocument
The text document to change.
Definition Protocol.h:295
std::vector< TextEdit > edits
The edits to be applied.
Definition Protocol.h:299
URIForFile uri
The text document's URI.
Definition Protocol.h:134
std::string languageId
The text document's language identifier.
Definition Protocol.h:309
std::optional< int64_t > version
The version number of this document (it will strictly increase after each change, including undo/redo...
Definition Protocol.h:315
URIForFile uri
The text document's URI.
Definition Protocol.h:306
std::string text
The content of the opened text document.
Definition Protocol.h:318
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1269
Position position
The position inside the text document.
Definition Protocol.h:1272
std::string newText
The string to be inserted.
Definition Protocol.h:251
ChangeAnnotationIdentifier annotationId
The actual annotation identifier (optional) If empty, then this field is nullopt.
Definition Protocol.h:255
Range range
The range of the text document to be manipulated.
Definition Protocol.h:247
Arguments for the 'applyTweak' command.
Definition Protocol.h:1062
Range selection
A selection provided by the client on a textDocument/codeAction request.
Definition Protocol.h:1066
URIForFile file
A file provided by the client on a textDocument/codeAction request.
Definition Protocol.h:1064
std::string tweakID
ID of the tweak that should be executed. Corresponds to Tweak::id().
Definition Protocol.h:1068
Used to resolve a client provided item back.
Definition Protocol.h:1587
std::optional< std::vector< ResolveParams > > parents
std::nullopt means parents aren't resolved and empty is no parents.
Definition Protocol.h:1590
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else,...
Definition Protocol.h:1580
URIForFile uri
The resource identifier of this item.
Definition Protocol.h:1576
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition Protocol.h:1584
SymbolKind kind
The kind of this item.
Definition Protocol.h:1570
std::optional< std::vector< TypeHierarchyItem > > children
If this type hierarchy item is resolved, it contains the direct children of the current item.
Definition Protocol.h:1609
std::optional< std::vector< TypeHierarchyItem > > parents
This is a clangd exntesion.
Definition Protocol.h:1603
bool deprecated
true if the hierarchy item is deprecated.
Definition Protocol.h:1600
std::optional< std::string > detail
More detail for this item, e.g. the signature of a function.
Definition Protocol.h:1573
ResolveParams data
A data entry field that is preserved between a type hierarchy prepare and supertypes or subtypes requ...
Definition Protocol.h:1596
std::string name
The name of this item.
Definition Protocol.h:1567
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
Definition Protocol.h:1553
int resolve
The hierarchy levels to resolve.
Definition Protocol.h:1556
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition Protocol.h:1560
std::string uri() const
Definition Protocol.h:108
friend bool operator<(const URIForFile &LHS, const URIForFile &RHS)
Definition Protocol.h:118
static llvm::Expected< URIForFile > fromURI(const URI &U, llvm::StringRef HintPath)
Definition Protocol.cpp:59
friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS)
Definition Protocol.h:114
friend bool operator==(const URIForFile &LHS, const URIForFile &RHS)
Definition Protocol.h:110
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
Canonicalizes AbsPath via URI.
Definition Protocol.cpp:46
llvm::StringRef file() const
Retrieves absolute path to the file.
Definition Protocol.h:105
std::optional< std::int64_t > version
The version number of this document.
Definition Protocol.h:151
To start progress reporting a $/progress notification with the following payload must be sent.
Definition Protocol.h:684
bool percentage
Optional progress percentage to display (value 100 is considered 100%).
Definition Protocol.h:705
bool cancellable
Controls if a cancel button should show to allow the user to cancel the long-running operation.
Definition Protocol.h:694
std::string title
Mandatory title of the progress operation.
Definition Protocol.h:689
llvm::json::Value token
The token to be used to report progress.
Definition Protocol.h:668
Signals the end of progress reporting.
Definition Protocol.h:742
std::optional< std::string > message
Optional, a final message indicating to for example indicate the outcome of the operation.
Definition Protocol.h:745
Reporting progress is done using the following payload.
Definition Protocol.h:710
std::string title
Mandatory title of the progress operation.
Definition Protocol.h:715
std::optional< unsigned > percentage
Optional progress percentage to display (value 100 is considered 100%).
Definition Protocol.h:737
std::optional< bool > cancellable
Controls enablement state of a cancel button.
Definition Protocol.h:722
std::optional< std::string > message
Optional, more detailed associated progress message.
Definition Protocol.h:729
The edit should either provide changes or documentChanges.
Definition Protocol.h:1041
std::optional< std::vector< TextDocumentEdit > > documentChanges
Versioned document edits.
Definition Protocol.h:1049
std::map< std::string, ChangeAnnotation > changeAnnotations
A map of change annotations that can be referenced in AnnotatedTextEdit.
Definition Protocol.h:1053
std::optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
Definition Protocol.h:1043
The parameters of a Workspace Symbol Request.
Definition Protocol.h:1243
std::string query
A query string to filter symbols by.
Definition Protocol.h:1246
std::optional< int > limit
Max results to return, overriding global default.
Definition Protocol.h:1250
static bool isEqual(const Range &LHS, const Range &RHS)
Definition Protocol.h:2125
static unsigned getHashValue(const Range &Val)
Definition Protocol.h:2121
static void format(const clang::clangd::Position &Pos, raw_ostream &OS, StringRef Style)
Definition Protocol.h:2131