clang-tools  11.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/master/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 "clang/Index/IndexSymbol.h"
29 #include "llvm/ADT/Optional.h"
30 #include "llvm/Support/JSON.h"
31 #include "llvm/Support/raw_ostream.h"
32 #include <bitset>
33 #include <memory>
34 #include <string>
35 #include <vector>
36 
37 namespace clang {
38 namespace clangd {
39 
40 enum class ErrorCode {
41  // Defined by JSON RPC.
42  ParseError = -32700,
43  InvalidRequest = -32600,
44  MethodNotFound = -32601,
45  InvalidParams = -32602,
46  InternalError = -32603,
47 
48  ServerNotInitialized = -32002,
49  UnknownErrorCode = -32001,
50 
51  // Defined by the protocol.
52  RequestCancelled = -32800,
53  ContentModified = -32801,
54 };
55 // Models an LSP error as an llvm::Error.
56 class LSPError : public llvm::ErrorInfo<LSPError> {
57 public:
58  std::string Message;
60  static char ID;
61 
62  LSPError(std::string Message, ErrorCode Code)
63  : Message(std::move(Message)), Code(Code) {}
64 
65  void log(llvm::raw_ostream &OS) const override {
66  OS << int(Code) << ": " << Message;
67  }
68  std::error_code convertToErrorCode() const override {
69  return llvm::inconvertibleErrorCode();
70  }
71 };
72 
73 // URI in "file" scheme for a file.
74 struct URIForFile {
75  URIForFile() = default;
76 
77  /// Canonicalizes \p AbsPath via URI.
78  ///
79  /// File paths in URIForFile can come from index or local AST. Path from
80  /// index goes through URI transformation, and the final path is resolved by
81  /// URI scheme and could potentially be different from the original path.
82  /// Hence, we do the same transformation for all paths.
83  ///
84  /// Files can be referred to by several paths (e.g. in the presence of links).
85  /// Which one we prefer may depend on where we're coming from. \p TUPath is a
86  /// hint, and should usually be the main entrypoint file we're processing.
87  static URIForFile canonicalize(llvm::StringRef AbsPath,
88  llvm::StringRef TUPath);
89 
90  static llvm::Expected<URIForFile> fromURI(const URI &U,
91  llvm::StringRef HintPath);
92 
93  /// Retrieves absolute path to the file.
94  llvm::StringRef file() const { return File; }
95 
96  explicit operator bool() const { return !File.empty(); }
97  std::string uri() const { return URI::createFile(File).toString(); }
98 
99  friend bool operator==(const URIForFile &LHS, const URIForFile &RHS) {
100  return LHS.File == RHS.File;
101  }
102 
103  friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS) {
104  return !(LHS == RHS);
105  }
106 
107  friend bool operator<(const URIForFile &LHS, const URIForFile &RHS) {
108  return LHS.File < RHS.File;
109  }
110 
111 private:
112  explicit URIForFile(std::string &&File) : File(std::move(File)) {}
113 
114  std::string File;
115 };
116 
117 /// Serialize/deserialize \p URIForFile to/from a string URI.
118 llvm::json::Value toJSON(const URIForFile &U);
119 bool fromJSON(const llvm::json::Value &, URIForFile &);
120 
122  /// The text document's URI.
124 };
125 llvm::json::Value toJSON(const TextDocumentIdentifier &);
126 bool fromJSON(const llvm::json::Value &, TextDocumentIdentifier &);
127 
129  /// The version number of this document. If a versioned text document
130  /// identifier is sent from the server to the client and the file is not open
131  /// in the editor (the server has not received an open notification before)
132  /// the server can send `null` to indicate that the version is known and the
133  /// content on disk is the master (as speced with document content ownership).
134  ///
135  /// The version number of a document will increase after each change,
136  /// including undo/redo. The number doesn't need to be consecutive.
137  ///
138  /// clangd extension: versions are optional, and synthesized if missing.
139  llvm::Optional<std::int64_t> version;
140 };
141 llvm::json::Value toJSON(const VersionedTextDocumentIdentifier &);
142 bool fromJSON(const llvm::json::Value &, VersionedTextDocumentIdentifier &);
143 
144 struct Position {
145  /// Line position in a document (zero-based).
146  int line = 0;
147 
148  /// Character offset on a line in a document (zero-based).
149  /// WARNING: this is in UTF-16 codepoints, not bytes or characters!
150  /// Use the functions in SourceCode.h to construct/interpret Positions.
151  int character = 0;
152 
153  friend bool operator==(const Position &LHS, const Position &RHS) {
154  return std::tie(LHS.line, LHS.character) ==
155  std::tie(RHS.line, RHS.character);
156  }
157  friend bool operator!=(const Position &LHS, const Position &RHS) {
158  return !(LHS == RHS);
159  }
160  friend bool operator<(const Position &LHS, const Position &RHS) {
161  return std::tie(LHS.line, LHS.character) <
162  std::tie(RHS.line, RHS.character);
163  }
164  friend bool operator<=(const Position &LHS, const Position &RHS) {
165  return std::tie(LHS.line, LHS.character) <=
166  std::tie(RHS.line, RHS.character);
167  }
168 };
169 bool fromJSON(const llvm::json::Value &, Position &);
170 llvm::json::Value toJSON(const Position &);
171 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Position &);
172 
173 struct Range {
174  /// The range's start position.
176 
177  /// The range's end position.
179 
180  friend bool operator==(const Range &LHS, const Range &RHS) {
181  return std::tie(LHS.start, LHS.end) == std::tie(RHS.start, RHS.end);
182  }
183  friend bool operator!=(const Range &LHS, const Range &RHS) {
184  return !(LHS == RHS);
185  }
186  friend bool operator<(const Range &LHS, const Range &RHS) {
187  return std::tie(LHS.start, LHS.end) < std::tie(RHS.start, RHS.end);
188  }
189 
190  bool contains(Position Pos) const { return start <= Pos && Pos < end; }
191  bool contains(Range Rng) const {
192  return start <= Rng.start && Rng.end <= end;
193  }
194 };
195 bool fromJSON(const llvm::json::Value &, Range &);
196 llvm::json::Value toJSON(const Range &);
197 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Range &);
198 
199 struct Location {
200  /// The text document's URI.
203 
204  friend bool operator==(const Location &LHS, const Location &RHS) {
205  return LHS.uri == RHS.uri && LHS.range == RHS.range;
206  }
207 
208  friend bool operator!=(const Location &LHS, const Location &RHS) {
209  return !(LHS == RHS);
210  }
211 
212  friend bool operator<(const Location &LHS, const Location &RHS) {
213  return std::tie(LHS.uri, LHS.range) < std::tie(RHS.uri, RHS.range);
214  }
215 };
216 llvm::json::Value toJSON(const Location &);
217 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Location &);
218 
219 struct TextEdit {
220  /// The range of the text document to be manipulated. To insert
221  /// text into a document create a range where start === end.
223 
224  /// The string to be inserted. For delete operations use an
225  /// empty string.
226  std::string newText;
227 };
228 inline bool operator==(const TextEdit &L, const TextEdit &R) {
229  return std::tie(L.newText, L.range) == std::tie(R.newText, R.range);
230 }
231 bool fromJSON(const llvm::json::Value &, TextEdit &);
232 llvm::json::Value toJSON(const TextEdit &);
233 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const TextEdit &);
234 
236  /// The text document's URI.
238 
239  /// The text document's language identifier.
240  std::string languageId;
241 
242  /// The version number of this document (it will strictly increase after each
243  /// change, including undo/redo.
244  ///
245  /// clangd extension: versions are optional, and synthesized if missing.
246  llvm::Optional<int64_t> version;
247 
248  /// The content of the opened text document.
249  std::string text;
250 };
251 bool fromJSON(const llvm::json::Value &, TextDocumentItem &);
252 
253 enum class TraceLevel {
254  Off = 0,
255  Messages = 1,
256  Verbose = 2,
257 };
258 bool fromJSON(const llvm::json::Value &E, TraceLevel &Out);
259 
260 struct NoParams {};
261 inline bool fromJSON(const llvm::json::Value &, NoParams &) { return true; }
265 
266 /// Defines how the host (editor) should sync document changes to the language
267 /// server.
269  /// Documents should not be synced at all.
270  None = 0,
271 
272  /// Documents are synced by always sending the full content of the document.
273  Full = 1,
274 
275  /// Documents are synced by sending the full content on open. After that
276  /// only incremental updates to the document are send.
277  Incremental = 2,
278 };
279 
280 /// The kind of a completion entry.
281 enum class CompletionItemKind {
282  Missing = 0,
283  Text = 1,
284  Method = 2,
285  Function = 3,
286  Constructor = 4,
287  Field = 5,
288  Variable = 6,
289  Class = 7,
290  Interface = 8,
291  Module = 9,
292  Property = 10,
293  Unit = 11,
294  Value = 12,
295  Enum = 13,
296  Keyword = 14,
297  Snippet = 15,
298  Color = 16,
299  File = 17,
300  Reference = 18,
301  Folder = 19,
302  EnumMember = 20,
303  Constant = 21,
304  Struct = 22,
305  Event = 23,
306  Operator = 24,
307  TypeParameter = 25,
308 };
309 bool fromJSON(const llvm::json::Value &, CompletionItemKind &);
310 constexpr auto CompletionItemKindMin =
311  static_cast<size_t>(CompletionItemKind::Text);
312 constexpr auto CompletionItemKindMax =
313  static_cast<size_t>(CompletionItemKind::TypeParameter);
314 using CompletionItemKindBitset = std::bitset<CompletionItemKindMax + 1>;
315 bool fromJSON(const llvm::json::Value &, CompletionItemKindBitset &);
318  CompletionItemKindBitset &SupportedCompletionItemKinds);
319 
320 /// A symbol kind.
321 enum class SymbolKind {
322  File = 1,
323  Module = 2,
324  Namespace = 3,
325  Package = 4,
326  Class = 5,
327  Method = 6,
328  Property = 7,
329  Field = 8,
330  Constructor = 9,
331  Enum = 10,
332  Interface = 11,
333  Function = 12,
334  Variable = 13,
335  Constant = 14,
336  String = 15,
337  Number = 16,
338  Boolean = 17,
339  Array = 18,
340  Object = 19,
341  Key = 20,
342  Null = 21,
343  EnumMember = 22,
344  Struct = 23,
345  Event = 24,
346  Operator = 25,
347  TypeParameter = 26
348 };
349 bool fromJSON(const llvm::json::Value &, SymbolKind &);
350 constexpr auto SymbolKindMin = static_cast<size_t>(SymbolKind::File);
351 constexpr auto SymbolKindMax = static_cast<size_t>(SymbolKind::TypeParameter);
352 using SymbolKindBitset = std::bitset<SymbolKindMax + 1>;
353 bool fromJSON(const llvm::json::Value &, SymbolKindBitset &);
355  SymbolKindBitset &supportedSymbolKinds);
356 
357 // Convert a index::SymbolKind to clangd::SymbolKind (LSP)
358 // Note, some are not perfect matches and should be improved when this LSP
359 // issue is addressed:
360 // https://github.com/Microsoft/language-server-protocol/issues/344
362 
363 // Determines the encoding used to measure offsets and lengths of source in LSP.
364 enum class OffsetEncoding {
365  // Any string is legal on the wire. Unrecognized encodings parse as this.
367  // Length counts code units of UTF-16 encoded text. (Standard LSP behavior).
368  UTF16,
369  // Length counts bytes of UTF-8 encoded text. (Clangd extension).
370  UTF8,
371  // Length counts codepoints in unicode text. (Clangd extension).
372  UTF32,
373 };
374 llvm::json::Value toJSON(const OffsetEncoding &);
375 bool fromJSON(const llvm::json::Value &, OffsetEncoding &);
376 llvm::raw_ostream &operator<<(llvm::raw_ostream &, OffsetEncoding);
377 
378 // Describes the content type that a client supports in various result literals
379 // like `Hover`, `ParameterInfo` or `CompletionItem`.
380 enum class MarkupKind {
381  PlainText,
382  Markdown,
383 };
384 bool fromJSON(const llvm::json::Value &, MarkupKind &);
385 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, MarkupKind);
386 
387 // This struct doesn't mirror LSP!
388 // The protocol defines deeply nested structures for client capabilities.
389 // Instead of mapping them all, this just parses out the bits we care about.
391  /// The supported set of SymbolKinds for workspace/symbol.
392  /// workspace.symbol.symbolKind.valueSet
393  llvm::Optional<SymbolKindBitset> WorkspaceSymbolKinds;
394 
395  /// Whether the client accepts diagnostics with codeActions attached inline.
396  /// textDocument.publishDiagnostics.codeActionsInline.
397  bool DiagnosticFixes = false;
398 
399  /// Whether the client accepts diagnostics with related locations.
400  /// textDocument.publishDiagnostics.relatedInformation.
402 
403  /// Whether the client accepts diagnostics with category attached to it
404  /// using the "category" extension.
405  /// textDocument.publishDiagnostics.categorySupport
406  bool DiagnosticCategory = false;
407 
408  /// Client supports snippets as insert text.
409  /// textDocument.completion.completionItem.snippetSupport
410  bool CompletionSnippets = false;
411 
412  /// Client supports completions with additionalTextEdit near the cursor.
413  /// This is a clangd extension. (LSP says this is for unrelated text only).
414  /// textDocument.completion.editsNearCursor
415  bool CompletionFixes = false;
416 
417  /// Client supports hierarchical document symbols.
418  /// textDocument.documentSymbol.hierarchicalDocumentSymbolSupport
419  bool HierarchicalDocumentSymbol = false;
420 
421  /// Client supports signature help.
422  /// textDocument.signatureHelp
423  bool HasSignatureHelp = false;
424 
425  /// Client supports processing label offsets instead of a simple label string.
426  /// textDocument.signatureHelp.signatureInformation.parameterInformation.labelOffsetSupport
427  bool OffsetsInSignatureHelp = false;
428 
429  /// The supported set of CompletionItemKinds for textDocument/completion.
430  /// textDocument.completion.completionItemKind.valueSet
431  llvm::Optional<CompletionItemKindBitset> CompletionItemKinds;
432 
433  /// The documentation format that should be used for textDocument/completion.
434  /// textDocument.completion.completionItem.documentationFormat
435  MarkupKind CompletionDocumentationFormat = MarkupKind::PlainText;
436 
437  /// Client supports CodeAction return value for textDocument/codeAction.
438  /// textDocument.codeAction.codeActionLiteralSupport.
439  bool CodeActionStructure = false;
440 
441  /// Client advertises support for the semanticTokens feature.
442  /// We support the textDocument/semanticTokens request in any case.
443  /// textDocument.semanticTokens
444  bool SemanticTokens = false;
445  /// Client supports Theia semantic highlighting extension.
446  /// https://github.com/microsoft/vscode-languageserver-node/pull/367
447  /// This will be ignored if the client also supports semanticTokens.
448  /// textDocument.semanticHighlightingCapabilities.semanticHighlighting
449  /// FIXME: drop this support once clients support LSP 3.16 Semantic Tokens.
450  bool TheiaSemanticHighlighting = false;
451 
452  /// Supported encodings for LSP character offsets. (clangd extension).
453  llvm::Optional<std::vector<OffsetEncoding>> offsetEncoding;
454 
455  /// The content format that should be used for Hover requests.
456  /// textDocument.hover.contentEncoding
457  MarkupKind HoverContentFormat = MarkupKind::PlainText;
458 
459  /// The client supports testing for validity of rename operations
460  /// before execution.
461  bool RenamePrepareSupport = false;
462 
463  /// The client supports progress notifications.
464  /// window.workDoneProgress
465  bool WorkDoneProgress = false;
466 
467  /// The client supports implicit $/progress work-done progress streams,
468  /// without a preceding window/workDoneProgress/create.
469  /// This is a clangd extension.
470  /// window.implicitWorkDoneProgressCreate
471  bool ImplicitProgressCreation = false;
472 };
473 bool fromJSON(const llvm::json::Value &, ClientCapabilities &);
474 
475 /// Clangd extension that's used in the 'compilationDatabaseChanges' in
476 /// workspace/didChangeConfiguration to record updates to the in-memory
477 /// compilation database.
479  std::string workingDirectory;
480  std::vector<std::string> compilationCommand;
481 };
482 bool fromJSON(const llvm::json::Value &, ClangdCompileCommand &);
483 
484 /// Clangd extension: parameters configurable at any time, via the
485 /// `workspace/didChangeConfiguration` notification.
486 /// LSP defines this type as `any`.
488  // Changes to the in-memory compilation database.
489  // The key of the map is a file name.
490  std::map<std::string, ClangdCompileCommand> compilationDatabaseChanges;
491 };
492 bool fromJSON(const llvm::json::Value &, ConfigurationSettings &);
493 
494 /// Clangd extension: parameters configurable at `initialize` time.
495 /// LSP defines this type as `any`.
497  // What we can change throught the didChangeConfiguration request, we can
498  // also set through the initialize request (initializationOptions field).
500 
501  llvm::Optional<std::string> compilationDatabasePath;
502  // Additional flags to be included in the "fallback command" used when
503  // the compilation database doesn't describe an opened file.
504  // The command used will be approximately `clang $FILE $fallbackFlags`.
505  std::vector<std::string> fallbackFlags;
506 
507  /// Clients supports show file status for textDocument/clangd.fileStatus.
508  bool FileStatus = false;
509 };
510 bool fromJSON(const llvm::json::Value &, InitializationOptions &);
511 
513  /// The process Id of the parent process that started
514  /// the server. Is null if the process has not been started by another
515  /// process. If the parent process is not alive then the server should exit
516  /// (see exit notification) its process.
517  llvm::Optional<int> processId;
518 
519  /// The rootPath of the workspace. Is null
520  /// if no folder is open.
521  ///
522  /// @deprecated in favour of rootUri.
523  llvm::Optional<std::string> rootPath;
524 
525  /// The rootUri of the workspace. Is null if no
526  /// folder is open. If both `rootPath` and `rootUri` are set
527  /// `rootUri` wins.
528  llvm::Optional<URIForFile> rootUri;
529 
530  // User provided initialization options.
531  // initializationOptions?: any;
532 
533  /// The capabilities provided by the client (editor or tool)
535 
536  /// The initial trace setting. If omitted trace is disabled ('off').
537  llvm::Optional<TraceLevel> trace;
538 
539  /// User-provided initialization options.
541 };
542 bool fromJSON(const llvm::json::Value &, InitializeParams &);
543 
545  /// The token to be used to report progress.
546  llvm::json::Value token = nullptr;
547 };
548 llvm::json::Value toJSON(const WorkDoneProgressCreateParams &P);
549 
550 template <typename T> struct ProgressParams {
551  /// The progress token provided by the client or server.
552  llvm::json::Value token = nullptr;
553 
554  /// The progress data.
555  T value;
556 };
557 template <typename T> llvm::json::Value toJSON(const ProgressParams<T> &P) {
558  return llvm::json::Object{{"token", P.token}, {"value", P.value}};
559 }
560 /// To start progress reporting a $/progress notification with the following
561 /// payload must be sent.
563  /// Mandatory title of the progress operation. Used to briefly inform about
564  /// the kind of operation being performed.
565  ///
566  /// Examples: "Indexing" or "Linking dependencies".
567  std::string title;
568 
569  /// Controls if a cancel button should show to allow the user to cancel the
570  /// long-running operation. Clients that don't support cancellation are
571  /// allowed to ignore the setting.
572  bool cancellable = false;
573 
574  /// Optional progress percentage to display (value 100 is considered 100%).
575  /// If not provided infinite progress is assumed and clients are allowed
576  /// to ignore the `percentage` value in subsequent in report notifications.
577  ///
578  /// The value should be steadily rising. Clients are free to ignore values
579  /// that are not following this rule.
580  ///
581  /// Clangd implementation note: we only send nonzero percentages in
582  /// the WorkProgressReport. 'true' here means percentages will be used.
583  bool percentage = false;
584 };
585 llvm::json::Value toJSON(const WorkDoneProgressBegin &);
586 
587 /// Reporting progress is done using the following payload.
589  /// Mandatory title of the progress operation. Used to briefly inform about
590  /// the kind of operation being performed.
591  ///
592  /// Examples: "Indexing" or "Linking dependencies".
593  std::string title;
594 
595  /// Controls enablement state of a cancel button. This property is only valid
596  /// if a cancel button got requested in the `WorkDoneProgressStart` payload.
597  ///
598  /// Clients that don't support cancellation or don't support control
599  /// the button's enablement state are allowed to ignore the setting.
600  llvm::Optional<bool> cancellable;
601 
602  /// Optional, more detailed associated progress message. Contains
603  /// complementary information to the `title`.
604  ///
605  /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
606  /// If unset, the previous progress message (if any) is still valid.
607  llvm::Optional<std::string> message;
608 
609  /// Optional progress percentage to display (value 100 is considered 100%).
610  /// If not provided infinite progress is assumed and clients are allowed
611  /// to ignore the `percentage` value in subsequent in report notifications.
612  ///
613  /// The value should be steadily rising. Clients are free to ignore values
614  /// that are not following this rule.
615  llvm::Optional<double> percentage;
616 };
617 llvm::json::Value toJSON(const WorkDoneProgressReport &);
618 //
619 /// Signals the end of progress reporting.
621  /// Optional, a final message indicating to for example indicate the outcome
622  /// of the operation.
623  llvm::Optional<std::string> message;
624 };
625 llvm::json::Value toJSON(const WorkDoneProgressEnd &);
626 
627 enum class MessageType {
628  /// An error message.
629  Error = 1,
630  /// A warning message.
631  Warning = 2,
632  /// An information message.
633  Info = 3,
634  /// A log message.
635  Log = 4,
636 };
637 llvm::json::Value toJSON(const MessageType &);
638 
639 /// The show message notification is sent from a server to a client to ask the
640 /// client to display a particular message in the user interface.
642  /// The message type.
644  /// The actual message.
645  std::string message;
646 };
647 llvm::json::Value toJSON(const ShowMessageParams &);
648 
650  /// The document that was opened.
652 };
653 bool fromJSON(const llvm::json::Value &, DidOpenTextDocumentParams &);
654 
656  /// The document that was closed.
658 };
659 bool fromJSON(const llvm::json::Value &, DidCloseTextDocumentParams &);
660 
662  /// The document that was saved.
664 };
665 bool fromJSON(const llvm::json::Value &, DidSaveTextDocumentParams &);
666 
668  /// The range of the document that changed.
669  llvm::Optional<Range> range;
670 
671  /// The length of the range that got replaced.
672  llvm::Optional<int> rangeLength;
673 
674  /// The new text of the range/document.
675  std::string text;
676 };
677 bool fromJSON(const llvm::json::Value &, TextDocumentContentChangeEvent &);
678 
680  /// The document that did change. The version number points
681  /// to the version after all provided content changes have
682  /// been applied.
684 
685  /// The actual content changes.
686  std::vector<TextDocumentContentChangeEvent> contentChanges;
687 
688  /// Forces diagnostics to be generated, or to not be generated, for this
689  /// version of the file. If not set, diagnostics are eventually consistent:
690  /// either they will be provided for this version or some subsequent one.
691  /// This is a clangd extension.
692  llvm::Optional<bool> wantDiagnostics;
693 
694  /// Force a complete rebuild of the file, ignoring all cached state. Slow!
695  /// This is useful to defeat clangd's assumption that missing headers will
696  /// stay missing.
697  /// This is a clangd extension.
698  bool forceRebuild = false;
699 };
700 bool fromJSON(const llvm::json::Value &, DidChangeTextDocumentParams &);
701 
702 enum class FileChangeType {
703  /// The file got created.
704  Created = 1,
705  /// The file got changed.
706  Changed = 2,
707  /// The file got deleted.
708  Deleted = 3
709 };
710 bool fromJSON(const llvm::json::Value &E, FileChangeType &Out);
711 
712 struct FileEvent {
713  /// The file's URI.
715  /// The change type.
717 };
718 bool fromJSON(const llvm::json::Value &, FileEvent &);
719 
721  /// The actual file events.
722  std::vector<FileEvent> changes;
723 };
724 bool fromJSON(const llvm::json::Value &, DidChangeWatchedFilesParams &);
725 
728 };
729 bool fromJSON(const llvm::json::Value &, DidChangeConfigurationParams &);
730 
731 // Note: we do not parse FormattingOptions for *FormattingParams.
732 // In general, we use a clang-format style detected from common mechanisms
733 // (.clang-format files and the -fallback-style flag).
734 // It would be possible to override these with FormatOptions, but:
735 // - the protocol makes FormatOptions mandatory, so many clients set them to
736 // useless values, and we can't tell when to respect them
737 // - we also format in other places, where FormatOptions aren't available.
738 
740  /// The document to format.
742 
743  /// The range to format
745 };
746 bool fromJSON(const llvm::json::Value &, DocumentRangeFormattingParams &);
747 
749  /// The document to format.
751 
752  /// The position at which this request was sent.
754 
755  /// The character that has been typed.
756  std::string ch;
757 };
758 bool fromJSON(const llvm::json::Value &, DocumentOnTypeFormattingParams &);
759 
761  /// The document to format.
763 };
764 bool fromJSON(const llvm::json::Value &, DocumentFormattingParams &);
765 
767  // The text document to find symbols in.
769 };
770 bool fromJSON(const llvm::json::Value &, DocumentSymbolParams &);
771 
772 /// Represents a related message and source code location for a diagnostic.
773 /// This should be used to point to code locations that cause or related to a
774 /// diagnostics, e.g when duplicating a symbol in a scope.
776  /// The location of this related diagnostic information.
778  /// The message of this related diagnostic information.
779  std::string message;
780 };
781 llvm::json::Value toJSON(const DiagnosticRelatedInformation &);
782 
783 struct CodeAction;
784 struct Diagnostic {
785  /// The range at which the message applies.
787 
788  /// The diagnostic's severity. Can be omitted. If omitted it is up to the
789  /// client to interpret diagnostics as error, warning, info or hint.
790  int severity = 0;
791 
792  /// The diagnostic's code. Can be omitted.
793  std::string code;
794 
795  /// A human-readable string describing the source of this
796  /// diagnostic, e.g. 'typescript' or 'super lint'.
797  std::string source;
798 
799  /// The diagnostic's message.
800  std::string message;
801 
802  /// An array of related diagnostic information, e.g. when symbol-names within
803  /// a scope collide all definitions can be marked via this property.
804  llvm::Optional<std::vector<DiagnosticRelatedInformation>> relatedInformation;
805 
806  /// The diagnostic's category. Can be omitted.
807  /// An LSP extension that's used to send the name of the category over to the
808  /// client. The category typically describes the compilation stage during
809  /// which the issue was produced, e.g. "Semantic Issue" or "Parse Issue".
810  llvm::Optional<std::string> category;
811 
812  /// Clangd extension: code actions related to this diagnostic.
813  /// Only with capability textDocument.publishDiagnostics.codeActionsInline.
814  /// (These actions can also be obtained using textDocument/codeAction).
815  llvm::Optional<std::vector<CodeAction>> codeActions;
816 };
817 llvm::json::Value toJSON(const Diagnostic &);
818 
819 /// A LSP-specific comparator used to find diagnostic in a container like
820 /// std:map.
821 /// We only use the required fields of Diagnostic to do the comparison to avoid
822 /// any regression issues from LSP clients (e.g. VScode), see
823 /// https://git.io/vbr29
825  bool operator()(const Diagnostic &LHS, const Diagnostic &RHS) const {
826  return std::tie(LHS.range, LHS.message) < std::tie(RHS.range, RHS.message);
827  }
828 };
829 bool fromJSON(const llvm::json::Value &, Diagnostic &);
830 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Diagnostic &);
831 
833  /// The URI for which diagnostic information is reported.
835  /// An array of diagnostic information items.
836  std::vector<Diagnostic> diagnostics;
837  /// The version number of the document the diagnostics are published for.
838  llvm::Optional<int64_t> version;
839 };
840 llvm::json::Value toJSON(const PublishDiagnosticsParams &);
841 
843  /// An array of diagnostics.
844  std::vector<Diagnostic> diagnostics;
845 };
846 bool fromJSON(const llvm::json::Value &, CodeActionContext &);
847 
849  /// The document in which the command was invoked.
851 
852  /// The range for which the command was invoked.
854 
855  /// Context carrying additional information.
857 };
858 bool fromJSON(const llvm::json::Value &, CodeActionParams &);
859 
861  /// Holds changes to existing resources.
862  llvm::Optional<std::map<std::string, std::vector<TextEdit>>> changes;
863 
864  /// Note: "documentChanges" is not currently used because currently there is
865  /// no support for versioned edits.
866 };
867 bool fromJSON(const llvm::json::Value &, WorkspaceEdit &);
868 llvm::json::Value toJSON(const WorkspaceEdit &WE);
869 
870 /// Arguments for the 'applyTweak' command. The server sends these commands as a
871 /// response to the textDocument/codeAction request. The client can later send a
872 /// command back to the server if the user requests to execute a particular code
873 /// tweak.
874 struct TweakArgs {
875  /// A file provided by the client on a textDocument/codeAction request.
877  /// A selection provided by the client on a textDocument/codeAction request.
879  /// ID of the tweak that should be executed. Corresponds to Tweak::id().
880  std::string tweakID;
881 };
882 bool fromJSON(const llvm::json::Value &, TweakArgs &);
883 llvm::json::Value toJSON(const TweakArgs &A);
884 
885 /// Exact commands are not specified in the protocol so we define the
886 /// ones supported by Clangd here. The protocol specifies the command arguments
887 /// to be "any[]" but to make this safer and more manageable, each command we
888 /// handle maps to a certain llvm::Optional of some struct to contain its
889 /// arguments. Different commands could reuse the same llvm::Optional as
890 /// arguments but a command that needs different arguments would simply add a
891 /// new llvm::Optional and not use any other ones. In practice this means only
892 /// one argument type will be parsed and set.
894  // Command to apply fix-its. Uses WorkspaceEdit as argument.
895  const static llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND;
896  // Command to apply the code action. Uses TweakArgs as argument.
897  const static llvm::StringLiteral CLANGD_APPLY_TWEAK;
898 
899  /// The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND
900  std::string command;
901 
902  // Arguments
903  llvm::Optional<WorkspaceEdit> workspaceEdit;
904  llvm::Optional<TweakArgs> tweakArgs;
905 };
906 bool fromJSON(const llvm::json::Value &, ExecuteCommandParams &);
907 
908 struct Command : public ExecuteCommandParams {
909  std::string title;
910 };
911 llvm::json::Value toJSON(const Command &C);
912 
913 /// A code action represents a change that can be performed in code, e.g. to fix
914 /// a problem or to refactor code.
915 ///
916 /// A CodeAction must set either `edit` and/or a `command`. If both are
917 /// supplied, the `edit` is applied first, then the `command` is executed.
918 struct CodeAction {
919  /// A short, human-readable, title for this code action.
920  std::string title;
921 
922  /// The kind of the code action.
923  /// Used to filter code actions.
924  llvm::Optional<std::string> kind;
925  const static llvm::StringLiteral QUICKFIX_KIND;
926  const static llvm::StringLiteral REFACTOR_KIND;
927  const static llvm::StringLiteral INFO_KIND;
928 
929  /// The diagnostics that this code action resolves.
930  llvm::Optional<std::vector<Diagnostic>> diagnostics;
931 
932  /// The workspace edit this code action performs.
933  llvm::Optional<WorkspaceEdit> edit;
934 
935  /// A command this code action executes. If a code action provides an edit
936  /// and a command, first the edit is executed and then the command.
937  llvm::Optional<Command> command;
938 };
939 llvm::json::Value toJSON(const CodeAction &);
940 
941 /// Represents programming constructs like variables, classes, interfaces etc.
942 /// that appear in a document. Document symbols can be hierarchical and they
943 /// have two ranges: one that encloses its definition and one that points to its
944 /// most interesting range, e.g. the range of an identifier.
946  /// The name of this symbol.
947  std::string name;
948 
949  /// More detail for this symbol, e.g the signature of a function.
950  std::string detail;
951 
952  /// The kind of this symbol.
954 
955  /// Indicates if this symbol is deprecated.
957 
958  /// The range enclosing this symbol not including leading/trailing whitespace
959  /// but everything else like comments. This information is typically used to
960  /// determine if the clients cursor is inside the symbol to reveal in the
961  /// symbol in the UI.
963 
964  /// The range that should be selected and revealed when this symbol is being
965  /// picked, e.g the name of a function. Must be contained by the `range`.
967 
968  /// Children of this symbol, e.g. properties of a class.
969  std::vector<DocumentSymbol> children;
970 };
971 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S);
972 llvm::json::Value toJSON(const DocumentSymbol &S);
973 
974 /// Represents information about programming constructs like variables, classes,
975 /// interfaces etc.
977  /// The name of this symbol.
978  std::string name;
979 
980  /// The kind of this symbol.
982 
983  /// The location of this symbol.
985 
986  /// The name of the symbol containing this symbol.
987  std::string containerName;
988 };
989 llvm::json::Value toJSON(const SymbolInformation &);
990 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const SymbolInformation &);
991 
992 /// Represents information about identifier.
993 /// This is returned from textDocument/symbolInfo, which is a clangd extension.
995  std::string name;
996 
997  std::string containerName;
998 
999  /// Unified Symbol Resolution identifier
1000  /// This is an opaque string uniquely identifying a symbol.
1001  /// Unlike SymbolID, it is variable-length and somewhat human-readable.
1002  /// It is a common representation across several clang tools.
1003  /// (See USRGeneration.h)
1004  std::string USR;
1005 
1006  llvm::Optional<SymbolID> ID;
1007 };
1008 llvm::json::Value toJSON(const SymbolDetails &);
1009 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const SymbolDetails &);
1010 bool operator==(const SymbolDetails &, const SymbolDetails &);
1011 
1012 /// The parameters of a Workspace Symbol Request.
1014  /// A non-empty query string
1015  std::string query;
1016 };
1017 bool fromJSON(const llvm::json::Value &, WorkspaceSymbolParams &);
1018 
1021 };
1022 llvm::json::Value toJSON(const ApplyWorkspaceEditParams &);
1023 
1025  bool applied = true;
1026  llvm::Optional<std::string> failureReason;
1027 };
1028 bool fromJSON(const llvm::json::Value &, ApplyWorkspaceEditResponse &);
1029 
1031  /// The text document.
1033 
1034  /// The position inside the text document.
1036 };
1037 bool fromJSON(const llvm::json::Value &, TextDocumentPositionParams &);
1038 
1040  /// Completion was triggered by typing an identifier (24x7 code
1041  /// complete), manual invocation (e.g Ctrl+Space) or via API.
1042  Invoked = 1,
1043  /// Completion was triggered by a trigger character specified by
1044  /// the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
1045  TriggerCharacter = 2,
1046  /// Completion was re-triggered as the current completion list is incomplete.
1048 };
1049 
1051  /// How the completion was triggered.
1053  /// The trigger character (a single character) that has trigger code complete.
1054  /// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
1055  std::string triggerCharacter;
1056 };
1057 bool fromJSON(const llvm::json::Value &, CompletionContext &);
1058 
1061 };
1062 bool fromJSON(const llvm::json::Value &, CompletionParams &);
1063 
1066  std::string value;
1067 };
1068 llvm::json::Value toJSON(const MarkupContent &MC);
1069 
1070 struct Hover {
1071  /// The hover's content
1073 
1074  /// An optional range is a range inside a text document
1075  /// that is used to visualize a hover, e.g. by changing the background color.
1076  llvm::Optional<Range> range;
1077 };
1078 llvm::json::Value toJSON(const Hover &H);
1079 
1080 /// Defines whether the insert text in a completion item should be interpreted
1081 /// as plain text or a snippet.
1082 enum class InsertTextFormat {
1083  Missing = 0,
1084  /// The primary text to be inserted is treated as a plain string.
1085  PlainText = 1,
1086  /// The primary text to be inserted is treated as a snippet.
1087  ///
1088  /// A snippet can define tab stops and placeholders with `$1`, `$2`
1089  /// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end
1090  /// of the snippet. Placeholders with equal identifiers are linked, that is
1091  /// typing in one will update others too.
1092  ///
1093  /// See also:
1094  /// https//github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
1095  Snippet = 2,
1096 };
1097 
1099  /// The label of this completion item. By default also the text that is
1100  /// inserted when selecting this completion.
1101  std::string label;
1102 
1103  /// The kind of this completion item. Based of the kind an icon is chosen by
1104  /// the editor.
1106 
1107  /// A human-readable string with additional information about this item, like
1108  /// type or symbol information.
1109  std::string detail;
1110 
1111  /// A human-readable string that represents a doc-comment.
1112  llvm::Optional<MarkupContent> documentation;
1113 
1114  /// A string that should be used when comparing this item with other items.
1115  /// When `falsy` the label is used.
1116  std::string sortText;
1117 
1118  /// A string that should be used when filtering a set of completion items.
1119  /// When `falsy` the label is used.
1120  std::string filterText;
1121 
1122  /// A string that should be inserted to a document when selecting this
1123  /// completion. When `falsy` the label is used.
1124  std::string insertText;
1125 
1126  /// The format of the insert text. The format applies to both the `insertText`
1127  /// property and the `newText` property of a provided `textEdit`.
1129 
1130  /// An edit which is applied to a document when selecting this completion.
1131  /// When an edit is provided `insertText` is ignored.
1132  ///
1133  /// Note: The range of the edit must be a single line range and it must
1134  /// contain the position at which completion has been requested.
1135  llvm::Optional<TextEdit> textEdit;
1136 
1137  /// An optional array of additional text edits that are applied when selecting
1138  /// this completion. Edits must not overlap with the main edit nor with
1139  /// themselves.
1140  std::vector<TextEdit> additionalTextEdits;
1141 
1142  /// Indicates if this item is deprecated.
1143  bool deprecated = false;
1144 
1145  /// This is Clangd extension.
1146  /// The score that Clangd calculates to rank completion items. This score can
1147  /// be used to adjust the ranking on the client side.
1148  /// NOTE: This excludes fuzzy matching score which is typically calculated on
1149  /// the client side.
1150  float score = 0.f;
1151 
1152  // TODO: Add custom commitCharacters for some of the completion items. For
1153  // example, it makes sense to use () only for the functions.
1154  // TODO(krasimir): The following optional fields defined by the language
1155  // server protocol are unsupported:
1156  //
1157  // data?: any - A data entry field that is preserved on a completion item
1158  // between a completion and a completion resolve request.
1159 };
1160 llvm::json::Value toJSON(const CompletionItem &);
1161 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const CompletionItem &);
1162 
1163 bool operator<(const CompletionItem &, const CompletionItem &);
1164 
1165 /// Represents a collection of completion items to be presented in the editor.
1167  /// The list is not complete. Further typing should result in recomputing the
1168  /// list.
1169  bool isIncomplete = false;
1170 
1171  /// The completion items.
1172  std::vector<CompletionItem> items;
1173 };
1174 llvm::json::Value toJSON(const CompletionList &);
1175 
1176 /// A single parameter of a particular signature.
1178 
1179  /// The label of this parameter. Ignored when labelOffsets is set.
1180  std::string labelString;
1181 
1182  /// Inclusive start and exclusive end offsets withing the containing signature
1183  /// label.
1184  /// Offsets are computed by lspLength(), which counts UTF-16 code units by
1185  /// default but that can be overriden, see its documentation for details.
1186  llvm::Optional<std::pair<unsigned, unsigned>> labelOffsets;
1187 
1188  /// The documentation of this parameter. Optional.
1189  std::string documentation;
1190 };
1191 llvm::json::Value toJSON(const ParameterInformation &);
1192 
1193 /// Represents the signature of something callable.
1195 
1196  /// The label of this signature. Mandatory.
1197  std::string label;
1198 
1199  /// The documentation of this signature. Optional.
1200  std::string documentation;
1201 
1202  /// The parameters of this signature.
1203  std::vector<ParameterInformation> parameters;
1204 };
1205 llvm::json::Value toJSON(const SignatureInformation &);
1206 llvm::raw_ostream &operator<<(llvm::raw_ostream &,
1207  const SignatureInformation &);
1208 
1209 /// Represents the signature of a callable.
1211 
1212  /// The resulting signatures.
1213  std::vector<SignatureInformation> signatures;
1214 
1215  /// The active signature.
1216  int activeSignature = 0;
1217 
1218  /// The active parameter of the active signature.
1219  int activeParameter = 0;
1220 
1221  /// Position of the start of the argument list, including opening paren. e.g.
1222  /// foo("first arg", "second arg",
1223  /// ^-argListStart ^-cursor
1224  /// This is a clangd-specific extension, it is only available via C++ API and
1225  /// not currently serialized for the LSP.
1227 };
1228 llvm::json::Value toJSON(const SignatureHelp &);
1229 
1231  /// The document that was opened.
1233 
1234  /// The position at which this request was sent.
1236 
1237  /// The new name of the symbol.
1238  std::string newName;
1239 };
1240 bool fromJSON(const llvm::json::Value &, RenameParams &);
1241 
1242 enum class DocumentHighlightKind { Text = 1, Read = 2, Write = 3 };
1243 
1244 /// A document highlight is a range inside a text document which deserves
1245 /// special attention. Usually a document highlight is visualized by changing
1246 /// the background color of its range.
1247 
1249  /// The range this highlight applies to.
1251 
1252  /// The highlight kind, default is DocumentHighlightKind.Text.
1254 
1255  friend bool operator<(const DocumentHighlight &LHS,
1256  const DocumentHighlight &RHS) {
1257  int LHSKind = static_cast<int>(LHS.kind);
1258  int RHSKind = static_cast<int>(RHS.kind);
1259  return std::tie(LHS.range, LHSKind) < std::tie(RHS.range, RHSKind);
1260  }
1261 
1262  friend bool operator==(const DocumentHighlight &LHS,
1263  const DocumentHighlight &RHS) {
1264  return LHS.kind == RHS.kind && LHS.range == RHS.range;
1265  }
1266 };
1267 llvm::json::Value toJSON(const DocumentHighlight &DH);
1268 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const DocumentHighlight &);
1269 
1270 enum class TypeHierarchyDirection { Children = 0, Parents = 1, Both = 2 };
1271 bool fromJSON(const llvm::json::Value &E, TypeHierarchyDirection &Out);
1272 
1273 /// The type hierarchy params is an extension of the
1274 /// `TextDocumentPositionsParams` with optional properties which can be used to
1275 /// eagerly resolve the item when requesting from the server.
1277  /// The hierarchy levels to resolve. `0` indicates no level.
1278  int resolve = 0;
1279 
1280  /// The direction of the hierarchy levels to resolve.
1282 };
1283 bool fromJSON(const llvm::json::Value &, TypeHierarchyParams &);
1284 
1286  /// The human readable name of the hierarchy item.
1287  std::string name;
1288 
1289  /// Optional detail for the hierarchy item. It can be, for instance, the
1290  /// signature of a function or method.
1291  llvm::Optional<std::string> detail;
1292 
1293  /// The kind of the hierarchy item. For instance, class or interface.
1295 
1296  /// `true` if the hierarchy item is deprecated. Otherwise, `false`.
1297  bool deprecated = false;
1298 
1299  /// The URI of the text document where this type hierarchy item belongs to.
1301 
1302  /// The range enclosing this type hierarchy item not including
1303  /// leading/trailing whitespace but everything else like comments. This
1304  /// information is typically used to determine if the client's cursor is
1305  /// inside the type hierarch item to reveal in the symbol in the UI.
1307 
1308  /// The range that should be selected and revealed when this type hierarchy
1309  /// item is being picked, e.g. the name of a function. Must be contained by
1310  /// the `range`.
1312 
1313  /// If this type hierarchy item is resolved, it contains the direct parents.
1314  /// Could be empty if the item does not have direct parents. If not defined,
1315  /// the parents have not been resolved yet.
1316  llvm::Optional<std::vector<TypeHierarchyItem>> parents;
1317 
1318  /// If this type hierarchy item is resolved, it contains the direct children
1319  /// of the current item. Could be empty if the item does not have any
1320  /// descendants. If not defined, the children have not been resolved.
1321  llvm::Optional<std::vector<TypeHierarchyItem>> children;
1322 
1323  /// An optional 'data' filed, which can be used to identify a type hierarchy
1324  /// item in a resolve request.
1325  llvm::Optional<std::string> data;
1326 };
1327 llvm::json::Value toJSON(const TypeHierarchyItem &);
1328 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const TypeHierarchyItem &);
1329 bool fromJSON(const llvm::json::Value &, TypeHierarchyItem &);
1330 
1331 /// Parameters for the `typeHierarchy/resolve` request.
1333  /// The item to resolve.
1335 
1336  /// The hierarchy levels to resolve. `0` indicates no level.
1337  int resolve;
1338 
1339  /// The direction of the hierarchy levels to resolve.
1341 };
1342 bool fromJSON(const llvm::json::Value &, ResolveTypeHierarchyItemParams &);
1343 
1345  // For now, no options like context.includeDeclaration are supported.
1346 };
1347 bool fromJSON(const llvm::json::Value &, ReferenceParams &);
1348 
1349 /// Clangd extension: indicates the current state of the file in clangd,
1350 /// sent from server via the `textDocument/clangd.fileStatus` notification.
1351 struct FileStatus {
1352  /// The text document's URI.
1354  /// The human-readable string presents the current state of the file, can be
1355  /// shown in the UI (e.g. status bar).
1356  std::string state;
1357  // FIXME: add detail messages.
1358 };
1359 llvm::json::Value toJSON(const FileStatus &);
1360 
1361 /// Specifies a single semantic token in the document.
1362 /// This struct is not part of LSP, which just encodes lists of tokens as
1363 /// arrays of numbers directly.
1365  /// token line number, relative to the previous token
1366  unsigned deltaLine = 0;
1367  /// token start character, relative to the previous token
1368  /// (relative to 0 or the previous token's start if they are on the same line)
1369  unsigned deltaStart = 0;
1370  /// the length of the token. A token cannot be multiline
1371  unsigned length = 0;
1372  /// will be looked up in `SemanticTokensLegend.tokenTypes`
1373  unsigned tokenType = 0;
1374  /// each set bit will be looked up in `SemanticTokensLegend.tokenModifiers`
1375  unsigned tokenModifiers = 0;
1376 };
1377 bool operator==(const SemanticToken &, const SemanticToken &);
1378 
1379 /// A versioned set of tokens.
1381  // An optional result id. If provided and clients support delta updating
1382  // the client will include the result id in the next semantic token request.
1383  // A server can then instead of computing all semantic tokens again simply
1384  // send a delta.
1385  std::string resultId;
1386 
1387  /// The actual tokens. For a detailed description about how the data is
1388  /// structured pls see
1389  /// https://github.com/microsoft/vscode-extension-samples/blob/5ae1f7787122812dcc84e37427ca90af5ee09f14/semantic-tokens-sample/vscode.proposed.d.ts#L71
1390  std::vector<SemanticToken> tokens;
1391 };
1392 llvm::json::Value toJSON(const SemanticTokens &);
1393 
1395  /// The text document.
1397 };
1398 bool fromJSON(const llvm::json::Value &, SemanticTokensParams &);
1399 
1400 /// Requests the changes in semantic tokens since a previous response.
1402  /// The text document.
1404  /// The previous result id.
1405  std::string previousResultId;
1406 };
1407 bool fromJSON(const llvm::json::Value &Params, SemanticTokensEditsParams &R);
1408 
1409 /// Describes a a replacement of a contiguous range of semanticTokens.
1411  // LSP specifies `start` and `deleteCount` which are relative to the array
1412  // encoding of the previous tokens.
1413  // We use token counts instead, and translate when serializing this struct.
1414  unsigned startToken = 0;
1415  unsigned deleteTokens = 0;
1416  std::vector<SemanticToken> tokens;
1417 };
1418 llvm::json::Value toJSON(const SemanticTokensEdit &);
1419 
1420 /// This models LSP SemanticTokensEdits | SemanticTokens, which is the result of
1421 /// textDocument/semanticTokens/edits.
1423  std::string resultId;
1424  /// Set if we computed edits relative to a previous set of tokens.
1425  llvm::Optional<std::vector<SemanticTokensEdit>> edits;
1426  /// Set if we computed a fresh set of tokens.
1427  llvm::Optional<std::vector<SemanticToken>> tokens;
1428 };
1429 llvm::json::Value toJSON(const SemanticTokensOrEdits &);
1430 
1431 /// Represents a semantic highlighting information that has to be applied on a
1432 /// specific line of the text document.
1434  /// The line these highlightings belong to.
1435  int Line = 0;
1436  /// The base64 encoded string of highlighting tokens.
1437  std::string Tokens;
1438  /// Is the line in an inactive preprocessor branch?
1439  /// This is a clangd extension.
1440  /// An inactive line can still contain highlighting tokens as well;
1441  /// clients should combine line style and token style if possible.
1442  bool IsInactive = false;
1443 };
1446 llvm::json::Value
1447 toJSON(const TheiaSemanticHighlightingInformation &Highlighting);
1448 
1449 /// Parameters for the semantic highlighting (server-side) push notification.
1451  /// The textdocument these highlightings belong to.
1453  /// The lines of highlightings that should be sent.
1454  std::vector<TheiaSemanticHighlightingInformation> Lines;
1455 };
1456 llvm::json::Value toJSON(const TheiaSemanticHighlightingParams &Highlighting);
1457 
1459  /// The text document.
1461 
1462  /// The positions inside the text document.
1463  std::vector<Position> positions;
1464 };
1465 bool fromJSON(const llvm::json::Value &, SelectionRangeParams &);
1466 
1468  /**
1469  * The range of this selection range.
1470  */
1472  /**
1473  * The parent selection range containing this range. Therefore `parent.range`
1474  * must contain `this.range`.
1475  */
1476  std::unique_ptr<SelectionRange> parent;
1477 };
1478 llvm::json::Value toJSON(const SelectionRange &);
1479 
1480 /// Parameters for the document link request.
1482  /// The document to provide document links for.
1484 };
1485 bool fromJSON(const llvm::json::Value &, DocumentLinkParams &);
1486 
1487 /// A range in a text document that links to an internal or external resource,
1488 /// like another text document or a web site.
1490  /// The range this link applies to.
1492 
1493  /// The uri this link points to. If missing a resolve request is sent later.
1495 
1496  // TODO(forster): The following optional fields defined by the language
1497  // server protocol are unsupported:
1498  //
1499  // data?: any - A data entry field that is preserved on a document link
1500  // between a DocumentLinkRequest and a
1501  // DocumentLinkResolveRequest.
1502 
1503  friend bool operator==(const DocumentLink &LHS, const DocumentLink &RHS) {
1504  return LHS.range == RHS.range && LHS.target == RHS.target;
1505  }
1506 
1507  friend bool operator!=(const DocumentLink &LHS, const DocumentLink &RHS) {
1508  return !(LHS == RHS);
1509  }
1510 };
1511 llvm::json::Value toJSON(const DocumentLink &DocumentLink);
1512 
1513 } // namespace clangd
1514 } // namespace clang
1515 
1516 namespace llvm {
1517 template <> struct format_provider<clang::clangd::Position> {
1518  static void format(const clang::clangd::Position &Pos, raw_ostream &OS,
1519  StringRef Style) {
1520  assert(Style.empty() && "style modifiers for this type are not supported");
1521  OS << Pos;
1522  }
1523 };
1524 } // namespace llvm
1525 
1526 #endif
std::string insertText
A string that should be inserted to a document when selecting this completion.
Definition: Protocol.h:1124
Range range
The range to format.
Definition: Protocol.h:744
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol...
Definition: Protocol.h:1004
friend bool operator<(const Location &LHS, const Location &RHS)
Definition: Protocol.h:212
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:1321
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:762
URIForFile uri
The file&#39;s URI.
Definition: Protocol.h:714
std::string code
The diagnostic&#39;s code. Can be omitted.
Definition: Protocol.h:793
TextDocumentIdentifier textDocument
The document to provide document links for.
Definition: Protocol.h:1483
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
Definition: Index.cpp:48
Location location
The location of this symbol.
Definition: Protocol.h:984
friend bool operator==(const Location &LHS, const Location &RHS)
Definition: Protocol.h:204
TextDocumentIdentifier textDocument
The document that was saved.
Definition: Protocol.h:663
llvm::Optional< TextEdit > textEdit
An edit which is applied to a document when selecting this completion.
Definition: Protocol.h:1135
Exact commands are not specified in the protocol so we define the ones supported by Clangd here...
Definition: Protocol.h:893
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:750
llvm::Optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
Definition: Protocol.h:393
Some operations such as code completion produce a set of candidates.
llvm::Optional< URIForFile > rootUri
The rootUri of the workspace.
Definition: Protocol.h:528
Position start
The range&#39;s start position.
Definition: Protocol.h:175
friend bool operator==(const URIForFile &LHS, const URIForFile &RHS)
Definition: Protocol.h:99
Represents a collection of completion items to be presented in the editor.
Definition: Protocol.h:1166
Range range
The range this highlight applies to.
Definition: Protocol.h:1250
llvm::Optional< bool > wantDiagnostics
Forces diagnostics to be generated, or to not be generated, for this version of the file...
Definition: Protocol.h:692
friend bool operator<=(const Position &LHS, const Position &RHS)
Definition: Protocol.h:164
std::vector< std::string > compilationCommand
Definition: Protocol.h:480
Range range
The range for which the command was invoked.
Definition: Protocol.h:853
CodeActionContext context
Context carrying additional information.
Definition: Protocol.h:856
static const llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND
Definition: Protocol.h:895
Clangd extension: parameters configurable at initialize time.
Definition: Protocol.h:496
llvm::json::Value token
The progress token provided by the client or server.
Definition: Protocol.h:552
std::string labelString
The label of this parameter. Ignored when labelOffsets is set.
Definition: Protocol.h:1180
std::string ch
The character that has been typed.
Definition: Protocol.h:756
std::vector< CompletionItem > items
The completion items.
Definition: Protocol.h:1172
llvm::Optional< std::int64_t > version
The version number of this document.
Definition: Protocol.h:139
Documents are synced by always sending the full content of the document.
Documents are synced by sending the full content on open.
llvm::Optional< std::vector< CodeAction > > codeActions
Clangd extension: code actions related to this diagnostic.
Definition: Protocol.h:815
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
Definition: SymbolInfo.cpp:21
llvm::Optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
Definition: Protocol.h:862
llvm::Optional< std::string > kind
The kind of the code action.
Definition: Protocol.h:924
bool operator()(const Diagnostic &LHS, const Diagnostic &RHS) const
Definition: Protocol.h:825
std::string title
A short, human-readable, title for this code action.
Definition: Protocol.h:920
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
Definition: Protocol.h:836
Location location
The location of this related diagnostic information.
Definition: Protocol.h:777
CompiledFragmentImpl & Out
llvm::Optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover, e.g.
Definition: Protocol.h:1076
TextDocumentIdentifier textDocument
The document that was closed.
Definition: Protocol.h:657
std::vector< Position > positions
The positions inside the text document.
Definition: Protocol.h:1463
SymbolKind indexSymbolKindToSymbolKind(index::SymbolKind Kind)
Definition: Protocol.cpp:230
Represents a related message and source code location for a diagnostic.
Definition: Protocol.h:775
std::string tweakID
ID of the tweak that should be executed. Corresponds to Tweak::id().
Definition: Protocol.h:880
llvm::Optional< bool > cancellable
Controls enablement state of a cancel button.
Definition: Protocol.h:600
std::string label
The label of this signature. Mandatory.
Definition: Protocol.h:1197
std::string state
The human-readable string presents the current state of the file, can be shown in the UI (e...
Definition: Protocol.h:1356
An Event<T> allows events of type T to be broadcast to listeners.
Definition: Function.h:31
llvm::Optional< std::string > data
An optional &#39;data&#39; filed, which can be used to identify a type hierarchy item in a resolve request...
Definition: Protocol.h:1325
A code action represents a change that can be performed in code, e.g.
Definition: Protocol.h:918
A versioned set of tokens.
Definition: Protocol.h:1380
friend bool operator!=(const URIForFile &LHS, const URIForFile &RHS)
Definition: Protocol.h:103
URIForFile uri
The text document&#39;s URI.
Definition: Protocol.h:201
std::string text
The new text of the range/document.
Definition: Protocol.h:675
friend bool operator!=(const Position &LHS, const Position &RHS)
Definition: Protocol.h:157
llvm::Optional< WorkspaceEdit > edit
The workspace edit this code action performs.
Definition: Protocol.h:933
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
Definition: Protocol.h:966
Values in a Context are indexed by typed keys.
Definition: Context.h:40
constexpr auto SymbolKindMin
Definition: Protocol.h:350
The show message notification is sent from a server to a client to ask the client to display a partic...
Definition: Protocol.h:641
llvm::Optional< std::string > compilationDatabasePath
Definition: Protocol.h:501
std::string sortText
A string that should be used when comparing this item with other items.
Definition: Protocol.h:1116
constexpr auto CompletionItemKindMin
Definition: Protocol.h:310
std::string name
The human readable name of the hierarchy item.
Definition: Protocol.h:1287
std::string title
Definition: Protocol.h:909
friend bool operator!=(const Range &LHS, const Range &RHS)
Definition: Protocol.h:183
std::vector< ParameterInformation > parameters
The parameters of this signature.
Definition: Protocol.h:1203
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
Definition: Protocol.h:314
Documents should not be synced at all.
Range selectionRange
The range that should be selected and revealed when this type hierarchy item is being picked...
Definition: Protocol.h:1311
InsertTextFormat
Defines whether the insert text in a completion item should be interpreted as plain text or a snippet...
Definition: Protocol.h:1082
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
Definition: Protocol.h:962
URIForFile uri
The text document&#39;s URI.
Definition: Protocol.h:1353
std::vector< TextEdit > additionalTextEdits
An optional array of additional text edits that are applied when selecting this completion.
Definition: Protocol.h:1140
Signals the end of progress reporting.
Definition: Protocol.h:620
constexpr auto CompletionItemKindMax
Definition: Protocol.h:312
Represents programming constructs like variables, classes, interfaces etc.
Definition: Protocol.h:945
static const llvm::StringLiteral CLANGD_APPLY_TWEAK
Definition: Protocol.h:897
llvm::Optional< int > processId
The process Id of the parent process that started the server.
Definition: Protocol.h:517
Range range
The range enclosing this type hierarchy item not including leading/trailing whitespace but everything...
Definition: Protocol.h:1306
CompletionItemKind
The kind of a completion entry.
Definition: Protocol.h:281
ConfigurationSettings ConfigSettings
Definition: Protocol.h:499
std::string uri() const
Definition: Protocol.h:97
BindArgumentKind Kind
TextDocumentSyncKind
Defines how the host (editor) should sync document changes to the language server.
Definition: Protocol.h:268
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1460
MarkupContent contents
The hover&#39;s content.
Definition: Protocol.h:1072
std::error_code convertToErrorCode() const override
Definition: Protocol.h:68
A document highlight is a range inside a text document which deserves special attention.
Definition: Protocol.h:1248
URIForFile uri
The text document&#39;s URI.
Definition: Protocol.h:237
std::string detail
A human-readable string with additional information about this item, like type or symbol information...
Definition: Protocol.h:1109
Requests the changes in semantic tokens since a previous response.
Definition: Protocol.h:1401
std::vector< TheiaSemanticHighlightingInformation > Lines
The lines of highlightings that should be sent.
Definition: Protocol.h:1454
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1403
To start progress reporting a $/progress notification with the following payload must be sent...
Definition: Protocol.h:562
llvm::Optional< SymbolID > ID
Definition: Protocol.h:1006
llvm::Optional< int64_t > version
The version number of this document (it will strictly increase after each change, including undo/redo...
Definition: Protocol.h:246
std::string source
A human-readable string describing the source of this diagnostic, e.g.
Definition: Protocol.h:797
llvm::Optional< TweakArgs > tweakArgs
Definition: Protocol.h:904
LSPError(std::string Message, ErrorCode Code)
Definition: Protocol.h:62
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
Definition: URI.cpp:225
TextDocumentIdentifier textDocument
The document that was opened.
Definition: Protocol.h:1232
std::string newText
The string to be inserted.
Definition: Protocol.h:226
VersionedTextDocumentIdentifier TextDocument
The textdocument these highlightings belong to.
Definition: Protocol.h:1452
std::string newName
The new name of the symbol.
Definition: Protocol.h:1238
llvm::Optional< MarkupContent > documentation
A human-readable string that represents a doc-comment.
Definition: Protocol.h:1112
Represents the signature of something callable.
Definition: Protocol.h:1194
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Definition: Protocol.h:487
std::string command
The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND.
Definition: Protocol.h:900
InitializationOptions initializationOptions
User-provided initialization options.
Definition: Protocol.h:540
TextDocumentIdentifier textDocument
Definition: Protocol.h:768
std::string filterText
A string that should be used when filtering a set of completion items.
Definition: Protocol.h:1120
bool operator<(const Ref &L, const Ref &R)
Definition: Ref.h:93
friend bool operator<(const Position &LHS, const Position &RHS)
Definition: Protocol.h:160
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Definition: Protocol.h:850
Range range
The range of the text document to be manipulated.
Definition: Protocol.h:222
URIForFile uri
The URI for which diagnostic information is reported.
Definition: Protocol.h:834
This models LSP SemanticTokensEdits | SemanticTokens, which is the result of textDocument/semanticTok...
Definition: Protocol.h:1422
std::vector< std::string > fallbackFlags
Definition: Protocol.h:505
llvm::Optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
Definition: Protocol.h:1427
std::string Message
Definition: Protocol.h:58
friend bool operator<(const Range &LHS, const Range &RHS)
Definition: Protocol.h:186
llvm::Optional< Range > range
The range of the document that changed.
Definition: Protocol.h:669
Parameters for the semantic highlighting (server-side) push notification.
Definition: Protocol.h:1450
llvm::Optional< std::string > category
The diagnostic&#39;s category.
Definition: Protocol.h:810
llvm::raw_string_ostream OS
Definition: TraceTests.cpp:162
std::vector< SemanticToken > tokens
Definition: Protocol.h:1416
Position position
The position inside the text document.
Definition: Protocol.h:1035
URIForFile file
A file provided by the client on a textDocument/codeAction request.
Definition: Protocol.h:876
llvm::Optional< std::string > message
Optional, a final message indicating to for example indicate the outcome of the operation.
Definition: Protocol.h:623
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
Definition: Protocol.h:969
Position argListStart
Position of the start of the argument list, including opening paren.
Definition: Protocol.h:1226
std::string message
The message of this related diagnostic information.
Definition: Protocol.h:779
std::string documentation
The documentation of this parameter. Optional.
Definition: Protocol.h:1189
SymbolKind kind
The kind of this symbol.
Definition: Protocol.h:981
static const llvm::StringLiteral REFACTOR_KIND
Definition: Protocol.h:926
std::vector< SignatureInformation > signatures
The resulting signatures.
Definition: Protocol.h:1213
llvm::Optional< int > rangeLength
The length of the range that got replaced.
Definition: Protocol.h:672
Specifies a single semantic token in the document.
Definition: Protocol.h:1364
static llvm::SmallString< 128 > canonicalize(llvm::StringRef Path)
std::string name
The name of this symbol.
Definition: Protocol.h:947
Completion was triggered by typing an identifier (24x7 code complete), manual invocation (e...
Position Pos
Definition: SourceCode.cpp:649
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
Definition: Protocol.h:534
TextDocumentItem textDocument
The document that was opened.
Definition: Protocol.h:651
llvm::Optional< std::string > detail
Optional detail for the hierarchy item.
Definition: Protocol.h:1291
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
Definition: Protocol.h:490
std::string detail
More detail for this symbol, e.g the signature of a function.
Definition: Protocol.h:950
Completion was triggered by a trigger character specified by the triggerCharacters properties of the ...
std::vector< FileEvent > changes
The actual file events.
Definition: Protocol.h:722
An information message.
llvm::Optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
Definition: Protocol.h:431
std::string languageId
The text document&#39;s language identifier.
Definition: Protocol.h:240
llvm::Optional< std::string > message
Optional, more detailed associated progress message.
Definition: Protocol.h:607
llvm::Optional< std::string > rootPath
The rootPath of the workspace.
Definition: Protocol.h:523
std::string title
Mandatory title of the progress operation.
Definition: Protocol.h:593
Position position
The position at which this request was sent.
Definition: Protocol.h:753
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request)
Definition: Index.cpp:34
A single parameter of a particular signature.
Definition: Protocol.h:1177
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1396
A LSP-specific comparator used to find diagnostic in a container like std:map.
Definition: Protocol.h:824
int line
Line position in a document (zero-based).
Definition: Protocol.h:146
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
Definition: Protocol.h:686
friend bool operator<(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
Definition: Protocol.h:1255
int character
Character offset on a line in a document (zero-based).
Definition: Protocol.h:151
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition: Protocol.h:1340
CompletionContext context
Definition: Protocol.h:1060
bool contains(Position Pos) const
Definition: Protocol.h:190
Represents the signature of a callable.
Definition: Protocol.h:1210
std::string query
A non-empty query string.
Definition: Protocol.h:1015
SymbolKind kind
The kind of this symbol.
Definition: Protocol.h:953
std::string Tokens
The base64 encoded string of highlighting tokens.
Definition: Protocol.h:1437
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Describes a a replacement of a contiguous range of semanticTokens.
Definition: Protocol.h:1410
std::bitset< SymbolKindMax+1 > SymbolKindBitset
Definition: Protocol.h:352
SymbolKind
A symbol kind.
Definition: Protocol.h:321
std::string message
The diagnostic&#39;s message.
Definition: Protocol.h:800
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
Definition: Protocol.h:1055
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1032
static const llvm::StringLiteral INFO_KIND
Definition: Protocol.h:927
std::string label
The label of this completion item.
Definition: Protocol.h:1101
friend bool operator==(const DocumentHighlight &LHS, const DocumentHighlight &RHS)
Definition: Protocol.h:1262
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
Definition: Protocol.h:1276
Range range
The range of this selection range.
Definition: Protocol.h:1471
llvm::Optional< std::pair< unsigned, unsigned > > labelOffsets
Inclusive start and exclusive end offsets withing the containing signature label. ...
Definition: Protocol.h:1186
llvm::Optional< int64_t > version
The version number of the document the diagnostics are published for.
Definition: Protocol.h:838
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
Definition: Protocol.h:1253
Reporting progress is done using the following payload.
Definition: Protocol.h:588
T value
The progress data.
Definition: Protocol.h:555
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
Definition: Protocol.cpp:212
static const llvm::StringLiteral QUICKFIX_KIND
Definition: Protocol.h:925
bool contains(Range Rng) const
Definition: Protocol.h:191
VersionedTextDocumentIdentifier textDocument
The document that did change.
Definition: Protocol.h:683
A URI describes the location of a source file.
Definition: URI.h:28
Range selection
A selection provided by the client on a textDocument/codeAction request.
Definition: Protocol.h:878
std::vector< Diagnostic > diagnostics
An array of diagnostics.
Definition: Protocol.h:844
bool deprecated
Indicates if this symbol is deprecated.
Definition: Protocol.h:956
llvm::Optional< Command > command
A command this code action executes.
Definition: Protocol.h:937
std::string title
Mandatory title of the progress operation.
Definition: Protocol.h:567
The parameters of a Workspace Symbol Request.
Definition: Protocol.h:1013
llvm::Optional< std::vector< TypeHierarchyItem > > parents
If this type hierarchy item is resolved, it contains the direct parents.
Definition: Protocol.h:1316
Parameters for the typeHierarchy/resolve request.
Definition: Protocol.h:1332
std::string text
The content of the opened text document.
Definition: Protocol.h:249
const Expr * E
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
Definition: Protocol.h:1351
std::string containerName
The name of the symbol containing this symbol.
Definition: Protocol.h:987
llvm::Optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Definition: Protocol.h:930
SymbolKind kind
The kind of the hierarchy item. For instance, class or interface.
Definition: Protocol.h:1294
Position position
The position at which this request was sent.
Definition: Protocol.h:1235
URIForFile uri
The text document&#39;s URI.
Definition: Protocol.h:123
std::vector< SemanticToken > tokens
The actual tokens.
Definition: Protocol.h:1390
std::string message
The actual message.
Definition: Protocol.h:645
Parameters for the document link request.
Definition: Protocol.h:1481
friend bool operator!=(const Location &LHS, const Location &RHS)
Definition: Protocol.h:208
TypeHierarchyItem item
The item to resolve.
Definition: Protocol.h:1334
std::string previousResultId
The previous result id.
Definition: Protocol.h:1405
llvm::Optional< std::string > failureReason
Definition: Protocol.h:1026
Range range
The range at which the message applies.
Definition: Protocol.h:786
friend bool operator<(const URIForFile &LHS, const URIForFile &RHS)
Definition: Protocol.h:107
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:741
llvm::Optional< double > percentage
Optional progress percentage to display (value 100 is considered 100%).
Definition: Protocol.h:615
std::unique_ptr< SelectionRange > parent
The parent selection range containing this range.
Definition: Protocol.h:1476
Position end
The range&#39;s end position.
Definition: Protocol.h:178
llvm::Optional< WorkspaceEdit > workspaceEdit
Definition: Protocol.h:903
int resolve
The hierarchy levels to resolve. 0 indicates no level.
Definition: Protocol.h:1337
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
Represents a semantic highlighting information that has to be applied on a specific line of the text ...
Definition: Protocol.h:1433
URIForFile uri
The URI of the text document where this type hierarchy item belongs to.
Definition: Protocol.h:1300
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
Definition: Headers.cpp:273
std::string name
The name of this symbol.
Definition: Protocol.h:978
Completion was re-triggered as the current completion list is incomplete.
std::string toString() const
Returns a string URI with all components percent-encoded.
Definition: URI.cpp:146
Clangd extension that&#39;s used in the &#39;compilationDatabaseChanges&#39; in workspace/didChangeConfiguration ...
Definition: Protocol.h:478
friend bool operator==(const Position &LHS, const Position &RHS)
Definition: Protocol.h:153
Arguments for the &#39;applyTweak&#39; command.
Definition: Protocol.h:874
void log(llvm::raw_ostream &OS) const override
Definition: Protocol.h:65
llvm::Optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
An array of related diagnostic information, e.g.
Definition: Protocol.h:804
friend bool operator==(const Range &LHS, const Range &RHS)
Definition: Protocol.h:180
Represents information about identifier.
Definition: Protocol.h:994
constexpr auto SymbolKindMax
Definition: Protocol.h:351
llvm::Optional< std::vector< OffsetEncoding > > offsetEncoding
Supported encodings for LSP character offsets. (clangd extension).
Definition: Protocol.h:453
static void format(const clang::clangd::Position &Pos, raw_ostream &OS, StringRef Style)
Definition: Protocol.h:1518
llvm::Optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled (&#39;off&#39;).
Definition: Protocol.h:537
std::string documentation
The documentation of this signature. Optional.
Definition: Protocol.h:1200
llvm::Optional< std::vector< SemanticTokensEdit > > edits
Set if we computed edits relative to a previous set of tokens.
Definition: Protocol.h:1425
llvm::StringRef file() const
Retrieves absolute path to the file.
Definition: Protocol.h:94
Represents information about programming constructs like variables, classes, interfaces etc...
Definition: Protocol.h:976