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