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