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