clang-tools  11.0.0
Protocol.cpp
Go to the documentation of this file.
1 //===--- Protocol.cpp - Language Server Protocol Implementation -----------===//
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 the serialization code for the LSP structs.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "Protocol.h"
14 #include "URI.h"
15 #include "support/Logger.h"
16 #include "clang/Basic/LLVM.h"
17 #include "clang/Index/IndexSymbol.h"
18 #include "llvm/ADT/Hashing.h"
19 #include "llvm/ADT/SmallString.h"
20 #include "llvm/ADT/StringSwitch.h"
21 #include "llvm/Support/ErrorHandling.h"
22 #include "llvm/Support/Format.h"
23 #include "llvm/Support/FormatVariadic.h"
24 #include "llvm/Support/JSON.h"
25 #include "llvm/Support/Path.h"
26 #include "llvm/Support/raw_ostream.h"
27 
28 namespace clang {
29 namespace clangd {
30 
31 char LSPError::ID;
32 
33 URIForFile URIForFile::canonicalize(llvm::StringRef AbsPath,
34  llvm::StringRef TUPath) {
35  assert(llvm::sys::path::is_absolute(AbsPath) && "the path is relative");
36  auto Resolved = URI::resolvePath(AbsPath, TUPath);
37  if (!Resolved) {
38  elog("URIForFile: failed to resolve path {0} with TU path {1}: "
39  "{2}.\nUsing unresolved path.",
40  AbsPath, TUPath, Resolved.takeError());
41  return URIForFile(std::string(AbsPath));
42  }
43  return URIForFile(std::move(*Resolved));
44 }
45 
46 llvm::Expected<URIForFile> URIForFile::fromURI(const URI &U,
47  llvm::StringRef HintPath) {
48  auto Resolved = URI::resolve(U, HintPath);
49  if (!Resolved)
50  return Resolved.takeError();
51  return URIForFile(std::move(*Resolved));
52 }
53 
54 bool fromJSON(const llvm::json::Value &E, URIForFile &R) {
55  if (auto S = E.getAsString()) {
56  auto Parsed = URI::parse(*S);
57  if (!Parsed) {
58  elog("Failed to parse URI {0}: {1}", *S, Parsed.takeError());
59  return false;
60  }
61  if (Parsed->scheme() != "file" && Parsed->scheme() != "test") {
62  elog("Clangd only supports 'file' URI scheme for workspace files: {0}",
63  *S);
64  return false;
65  }
66  // "file" and "test" schemes do not require hint path.
67  auto U = URIForFile::fromURI(*Parsed, /*HintPath=*/"");
68  if (!U) {
69  elog("{0}", U.takeError());
70  return false;
71  }
72  R = std::move(*U);
73  return true;
74  }
75  return false;
76 }
77 
78 llvm::json::Value toJSON(const URIForFile &U) { return U.uri(); }
79 
80 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URIForFile &U) {
81  return OS << U.uri();
82 }
83 
84 llvm::json::Value toJSON(const TextDocumentIdentifier &R) {
85  return llvm::json::Object{{"uri", R.uri}};
86 }
87 
88 bool fromJSON(const llvm::json::Value &Params, TextDocumentIdentifier &R) {
89  llvm::json::ObjectMapper O(Params);
90  return O && O.map("uri", R.uri);
91 }
92 
93 llvm::json::Value toJSON(const VersionedTextDocumentIdentifier &R) {
94  auto Result = toJSON(static_cast<const TextDocumentIdentifier &>(R));
95  Result.getAsObject()->try_emplace("version", R.version);
96  return Result;
97 }
98 
99 bool fromJSON(const llvm::json::Value &Params,
101  llvm::json::ObjectMapper O(Params);
102  return fromJSON(Params, static_cast<TextDocumentIdentifier &>(R)) && O &&
103  O.map("version", R.version);
104 }
105 
106 bool fromJSON(const llvm::json::Value &Params, Position &R) {
107  llvm::json::ObjectMapper O(Params);
108  return O && O.map("line", R.line) && O.map("character", R.character);
109 }
110 
111 llvm::json::Value toJSON(const Position &P) {
112  return llvm::json::Object{
113  {"line", P.line},
114  {"character", P.character},
115  };
116 }
117 
118 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Position &P) {
119  return OS << P.line << ':' << P.character;
120 }
121 
122 bool fromJSON(const llvm::json::Value &Params, Range &R) {
123  llvm::json::ObjectMapper O(Params);
124  return O && O.map("start", R.start) && O.map("end", R.end);
125 }
126 
127 llvm::json::Value toJSON(const Range &P) {
128  return llvm::json::Object{
129  {"start", P.start},
130  {"end", P.end},
131  };
132 }
133 
134 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Range &R) {
135  return OS << R.start << '-' << R.end;
136 }
137 
138 llvm::json::Value toJSON(const Location &P) {
139  return llvm::json::Object{
140  {"uri", P.uri},
141  {"range", P.range},
142  };
143 }
144 
145 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Location &L) {
146  return OS << L.range << '@' << L.uri;
147 }
148 
149 bool fromJSON(const llvm::json::Value &Params, TextDocumentItem &R) {
150  llvm::json::ObjectMapper O(Params);
151  return O && O.map("uri", R.uri) && O.map("languageId", R.languageId) &&
152  O.map("version", R.version) && O.map("text", R.text);
153 }
154 
155 bool fromJSON(const llvm::json::Value &Params, TextEdit &R) {
156  llvm::json::ObjectMapper O(Params);
157  return O && O.map("range", R.range) && O.map("newText", R.newText);
158 }
159 
160 llvm::json::Value toJSON(const TextEdit &P) {
161  return llvm::json::Object{
162  {"range", P.range},
163  {"newText", P.newText},
164  };
165 }
166 
167 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TextEdit &TE) {
168  OS << TE.range << " => \"";
169  llvm::printEscapedString(TE.newText, OS);
170  return OS << '"';
171 }
172 
173 bool fromJSON(const llvm::json::Value &E, TraceLevel &Out) {
174  if (auto S = E.getAsString()) {
175  if (*S == "off") {
177  return true;
178  } else if (*S == "messages") {
180  return true;
181  } else if (*S == "verbose") {
183  return true;
184  }
185  }
186  return false;
187 }
188 
189 bool fromJSON(const llvm::json::Value &E, SymbolKind &Out) {
190  if (auto T = E.getAsInteger()) {
191  if (*T < static_cast<int>(SymbolKind::File) ||
192  *T > static_cast<int>(SymbolKind::TypeParameter))
193  return false;
194  Out = static_cast<SymbolKind>(*T);
195  return true;
196  }
197  return false;
198 }
199 
200 bool fromJSON(const llvm::json::Value &E, SymbolKindBitset &Out) {
201  if (auto *A = E.getAsArray()) {
202  for (size_t I = 0; I < A->size(); ++I) {
203  SymbolKind KindOut;
204  if (fromJSON((*A)[I], KindOut))
205  Out.set(size_t(KindOut));
206  }
207  return true;
208  }
209  return false;
210 }
211 
213  SymbolKindBitset &SupportedSymbolKinds) {
214  auto KindVal = static_cast<size_t>(Kind);
215  if (KindVal >= SymbolKindMin && KindVal <= SupportedSymbolKinds.size() &&
216  SupportedSymbolKinds[KindVal])
217  return Kind;
218 
219  switch (Kind) {
220  // Provide some fall backs for common kinds that are close enough.
221  case SymbolKind::Struct:
222  return SymbolKind::Class;
224  return SymbolKind::Enum;
225  default:
226  return SymbolKind::String;
227  }
228 }
229 
231  switch (Kind) {
232  case index::SymbolKind::Unknown:
233  return SymbolKind::Variable;
234  case index::SymbolKind::Module:
235  return SymbolKind::Module;
236  case index::SymbolKind::Namespace:
237  return SymbolKind::Namespace;
238  case index::SymbolKind::NamespaceAlias:
239  return SymbolKind::Namespace;
240  case index::SymbolKind::Macro:
241  return SymbolKind::String;
242  case index::SymbolKind::Enum:
243  return SymbolKind::Enum;
244  case index::SymbolKind::Struct:
245  return SymbolKind::Struct;
246  case index::SymbolKind::Class:
247  return SymbolKind::Class;
248  case index::SymbolKind::Protocol:
249  return SymbolKind::Interface;
250  case index::SymbolKind::Extension:
251  return SymbolKind::Interface;
252  case index::SymbolKind::Union:
253  return SymbolKind::Class;
254  case index::SymbolKind::TypeAlias:
255  return SymbolKind::Class;
256  case index::SymbolKind::Function:
257  return SymbolKind::Function;
258  case index::SymbolKind::Variable:
259  return SymbolKind::Variable;
260  case index::SymbolKind::Field:
261  return SymbolKind::Field;
262  case index::SymbolKind::EnumConstant:
263  return SymbolKind::EnumMember;
264  case index::SymbolKind::InstanceMethod:
265  case index::SymbolKind::ClassMethod:
266  case index::SymbolKind::StaticMethod:
267  return SymbolKind::Method;
268  case index::SymbolKind::InstanceProperty:
269  case index::SymbolKind::ClassProperty:
270  case index::SymbolKind::StaticProperty:
271  return SymbolKind::Property;
272  case index::SymbolKind::Constructor:
273  case index::SymbolKind::Destructor:
275  case index::SymbolKind::ConversionFunction:
276  return SymbolKind::Function;
277  case index::SymbolKind::Parameter:
278  case index::SymbolKind::NonTypeTemplateParm:
279  return SymbolKind::Variable;
280  case index::SymbolKind::Using:
281  return SymbolKind::Namespace;
282  case index::SymbolKind::TemplateTemplateParm:
283  case index::SymbolKind::TemplateTypeParm:
285  }
286  llvm_unreachable("invalid symbol kind");
287 }
288 
289 bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R) {
290  const llvm::json::Object *O = Params.getAsObject();
291  if (!O)
292  return false;
293  if (auto *TextDocument = O->getObject("textDocument")) {
294  if (auto *SemanticHighlighting =
295  TextDocument->getObject("semanticHighlightingCapabilities")) {
296  if (auto SemanticHighlightingSupport =
297  SemanticHighlighting->getBoolean("semanticHighlighting"))
298  R.TheiaSemanticHighlighting = *SemanticHighlightingSupport;
299  }
300  if (TextDocument->getObject("semanticTokens"))
301  R.SemanticTokens = true;
302  if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
303  if (auto CategorySupport = Diagnostics->getBoolean("categorySupport"))
304  R.DiagnosticCategory = *CategorySupport;
305  if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline"))
306  R.DiagnosticFixes = *CodeActions;
307  if (auto RelatedInfo = Diagnostics->getBoolean("relatedInformation"))
308  R.DiagnosticRelatedInformation = *RelatedInfo;
309  }
310  if (auto *Completion = TextDocument->getObject("completion")) {
311  if (auto *Item = Completion->getObject("completionItem")) {
312  if (auto SnippetSupport = Item->getBoolean("snippetSupport"))
313  R.CompletionSnippets = *SnippetSupport;
314  if (auto DocumentationFormat = Item->getArray("documentationFormat")) {
315  for (const auto &Format : *DocumentationFormat) {
317  break;
318  }
319  }
320  }
321  if (auto *ItemKind = Completion->getObject("completionItemKind")) {
322  if (auto *ValueSet = ItemKind->get("valueSet")) {
323  R.CompletionItemKinds.emplace();
324  if (!fromJSON(*ValueSet, *R.CompletionItemKinds))
325  return false;
326  }
327  }
328  if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
329  R.CompletionFixes = *EditsNearCursor;
330  }
331  if (auto *CodeAction = TextDocument->getObject("codeAction")) {
332  if (CodeAction->getObject("codeActionLiteralSupport"))
333  R.CodeActionStructure = true;
334  }
335  if (auto *DocumentSymbol = TextDocument->getObject("documentSymbol")) {
336  if (auto HierarchicalSupport =
337  DocumentSymbol->getBoolean("hierarchicalDocumentSymbolSupport"))
338  R.HierarchicalDocumentSymbol = *HierarchicalSupport;
339  }
340  if (auto *Hover = TextDocument->getObject("hover")) {
341  if (auto *ContentFormat = Hover->getArray("contentFormat")) {
342  for (const auto &Format : *ContentFormat) {
343  if (fromJSON(Format, R.HoverContentFormat))
344  break;
345  }
346  }
347  }
348  if (auto *Help = TextDocument->getObject("signatureHelp")) {
349  R.HasSignatureHelp = true;
350  if (auto *Info = Help->getObject("signatureInformation")) {
351  if (auto *Parameter = Info->getObject("parameterInformation")) {
352  if (auto OffsetSupport = Parameter->getBoolean("labelOffsetSupport"))
353  R.OffsetsInSignatureHelp = *OffsetSupport;
354  }
355  }
356  }
357  if (auto *Rename = TextDocument->getObject("rename")) {
358  if (auto RenameSupport = Rename->getBoolean("prepareSupport"))
359  R.RenamePrepareSupport = *RenameSupport;
360  }
361  }
362  if (auto *Workspace = O->getObject("workspace")) {
363  if (auto *Symbol = Workspace->getObject("symbol")) {
364  if (auto *SymbolKind = Symbol->getObject("symbolKind")) {
365  if (auto *ValueSet = SymbolKind->get("valueSet")) {
366  R.WorkspaceSymbolKinds.emplace();
367  if (!fromJSON(*ValueSet, *R.WorkspaceSymbolKinds))
368  return false;
369  }
370  }
371  }
372  }
373  if (auto *Window = O->getObject("window")) {
374  if (auto WorkDoneProgress = Window->getBoolean("workDoneProgress"))
375  R.WorkDoneProgress = *WorkDoneProgress;
376  if (auto Implicit = Window->getBoolean("implicitWorkDoneProgressCreate"))
377  R.ImplicitProgressCreation = *Implicit;
378  }
379  if (auto *OffsetEncoding = O->get("offsetEncoding")) {
380  R.offsetEncoding.emplace();
382  return false;
383  }
384  return true;
385 }
386 
387 bool fromJSON(const llvm::json::Value &Params, InitializeParams &R) {
388  llvm::json::ObjectMapper O(Params);
389  if (!O)
390  return false;
391  // We deliberately don't fail if we can't parse individual fields.
392  // Failing to handle a slightly malformed initialize would be a disaster.
393  O.map("processId", R.processId);
394  O.map("rootUri", R.rootUri);
395  O.map("rootPath", R.rootPath);
396  O.map("capabilities", R.capabilities);
397  O.map("trace", R.trace);
398  O.map("initializationOptions", R.initializationOptions);
399  return true;
400 }
401 
402 llvm::json::Value toJSON(const WorkDoneProgressCreateParams &P) {
403  return llvm::json::Object{{"token", P.token}};
404 }
405 
406 llvm::json::Value toJSON(const WorkDoneProgressBegin &P) {
407  llvm::json::Object Result{
408  {"kind", "begin"},
409  {"title", P.title},
410  };
411  if (P.cancellable)
412  Result["cancellable"] = true;
413  if (P.percentage)
414  Result["percentage"] = 0;
415 
416  // FIXME: workaround for older gcc/clang
417  return std::move(Result);
418 }
419 
420 llvm::json::Value toJSON(const WorkDoneProgressReport &P) {
421  llvm::json::Object Result{{"kind", "report"}};
422  if (P.cancellable)
423  Result["cancellable"] = *P.cancellable;
424  if (P.message)
425  Result["message"] = *P.message;
426  if (P.percentage)
427  Result["percentage"] = *P.percentage;
428  // FIXME: workaround for older gcc/clang
429  return std::move(Result);
430 }
431 
432 llvm::json::Value toJSON(const WorkDoneProgressEnd &P) {
433  llvm::json::Object Result{{"kind", "end"}};
434  if (P.message)
435  Result["message"] = *P.message;
436  // FIXME: workaround for older gcc/clang
437  return std::move(Result);
438 }
439 
440 llvm::json::Value toJSON(const MessageType &R) {
441  return static_cast<int64_t>(R);
442 }
443 
444 llvm::json::Value toJSON(const ShowMessageParams &R) {
445  return llvm::json::Object{{"type", R.type}, {"message", R.message}};
446 }
447 
448 bool fromJSON(const llvm::json::Value &Params, DidOpenTextDocumentParams &R) {
449  llvm::json::ObjectMapper O(Params);
450  return O && O.map("textDocument", R.textDocument);
451 }
452 
453 bool fromJSON(const llvm::json::Value &Params, DidCloseTextDocumentParams &R) {
454  llvm::json::ObjectMapper O(Params);
455  return O && O.map("textDocument", R.textDocument);
456 }
457 
458 bool fromJSON(const llvm::json::Value &Params, DidSaveTextDocumentParams &R) {
459  llvm::json::ObjectMapper O(Params);
460  return O && O.map("textDocument", R.textDocument);
461 }
462 
463 bool fromJSON(const llvm::json::Value &Params, DidChangeTextDocumentParams &R) {
464  llvm::json::ObjectMapper O(Params);
465  if (!O)
466  return false;
467  O.map("forceRebuild", R.forceRebuild); // Optional clangd extension.
468  return O.map("textDocument", R.textDocument) &&
469  O.map("contentChanges", R.contentChanges) &&
470  O.map("wantDiagnostics", R.wantDiagnostics);
471 }
472 
473 bool fromJSON(const llvm::json::Value &E, FileChangeType &Out) {
474  if (auto T = E.getAsInteger()) {
475  if (*T < static_cast<int>(FileChangeType::Created) ||
476  *T > static_cast<int>(FileChangeType::Deleted))
477  return false;
478  Out = static_cast<FileChangeType>(*T);
479  return true;
480  }
481  return false;
482 }
483 
484 bool fromJSON(const llvm::json::Value &Params, FileEvent &R) {
485  llvm::json::ObjectMapper O(Params);
486  return O && O.map("uri", R.uri) && O.map("type", R.type);
487 }
488 
489 bool fromJSON(const llvm::json::Value &Params, DidChangeWatchedFilesParams &R) {
490  llvm::json::ObjectMapper O(Params);
491  return O && O.map("changes", R.changes);
492 }
493 
494 bool fromJSON(const llvm::json::Value &Params,
496  llvm::json::ObjectMapper O(Params);
497  return O && O.map("range", R.range) && O.map("rangeLength", R.rangeLength) &&
498  O.map("text", R.text);
499 }
500 
501 bool fromJSON(const llvm::json::Value &Params,
503  llvm::json::ObjectMapper O(Params);
504  return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
505 }
506 
507 bool fromJSON(const llvm::json::Value &Params,
509  llvm::json::ObjectMapper O(Params);
510  return O && O.map("textDocument", R.textDocument) &&
511  O.map("position", R.position) && O.map("ch", R.ch);
512 }
513 
514 bool fromJSON(const llvm::json::Value &Params, DocumentFormattingParams &R) {
515  llvm::json::ObjectMapper O(Params);
516  return O && O.map("textDocument", R.textDocument);
517 }
518 
519 bool fromJSON(const llvm::json::Value &Params, DocumentSymbolParams &R) {
520  llvm::json::ObjectMapper O(Params);
521  return O && O.map("textDocument", R.textDocument);
522 }
523 
524 llvm::json::Value toJSON(const DiagnosticRelatedInformation &DRI) {
525  return llvm::json::Object{
526  {"location", DRI.location},
527  {"message", DRI.message},
528  };
529 }
530 
531 llvm::json::Value toJSON(const Diagnostic &D) {
532  llvm::json::Object Diag{
533  {"range", D.range},
534  {"severity", D.severity},
535  {"message", D.message},
536  };
537  if (D.category)
538  Diag["category"] = *D.category;
539  if (D.codeActions)
540  Diag["codeActions"] = D.codeActions;
541  if (!D.code.empty())
542  Diag["code"] = D.code;
543  if (!D.source.empty())
544  Diag["source"] = D.source;
545  if (D.relatedInformation)
546  Diag["relatedInformation"] = *D.relatedInformation;
547  // FIXME: workaround for older gcc/clang
548  return std::move(Diag);
549 }
550 
551 bool fromJSON(const llvm::json::Value &Params, Diagnostic &R) {
552  llvm::json::ObjectMapper O(Params);
553  if (!O || !O.map("range", R.range) || !O.map("message", R.message))
554  return false;
555  O.map("severity", R.severity);
556  O.map("category", R.category);
557  O.map("code", R.code);
558  O.map("source", R.source);
559  return true;
560 }
561 
562 llvm::json::Value toJSON(const PublishDiagnosticsParams &PDP) {
563  llvm::json::Object Result{
564  {"uri", PDP.uri},
565  {"diagnostics", PDP.diagnostics},
566  };
567  if (PDP.version)
568  Result["version"] = PDP.version;
569  return std::move(Result);
570 }
571 
572 bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R) {
573  llvm::json::ObjectMapper O(Params);
574  return O && O.map("diagnostics", R.diagnostics);
575 }
576 
577 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diagnostic &D) {
578  OS << D.range << " [";
579  switch (D.severity) {
580  case 1:
581  OS << "error";
582  break;
583  case 2:
584  OS << "warning";
585  break;
586  case 3:
587  OS << "note";
588  break;
589  case 4:
590  OS << "remark";
591  break;
592  default:
593  OS << "diagnostic";
594  break;
595  }
596  return OS << '(' << D.severity << "): " << D.message << "]";
597 }
598 
599 bool fromJSON(const llvm::json::Value &Params, CodeActionParams &R) {
600  llvm::json::ObjectMapper O(Params);
601  return O && O.map("textDocument", R.textDocument) &&
602  O.map("range", R.range) && O.map("context", R.context);
603 }
604 
605 bool fromJSON(const llvm::json::Value &Params, WorkspaceEdit &R) {
606  llvm::json::ObjectMapper O(Params);
607  return O && O.map("changes", R.changes);
608 }
609 
610 const llvm::StringLiteral ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND =
611  "clangd.applyFix";
612 const llvm::StringLiteral ExecuteCommandParams::CLANGD_APPLY_TWEAK =
613  "clangd.applyTweak";
614 
615 bool fromJSON(const llvm::json::Value &Params, ExecuteCommandParams &R) {
616  llvm::json::ObjectMapper O(Params);
617  if (!O || !O.map("command", R.command))
618  return false;
619 
620  auto Args = Params.getAsObject()->getArray("arguments");
622  return Args && Args->size() == 1 &&
623  fromJSON(Args->front(), R.workspaceEdit);
624  }
626  return Args && Args->size() == 1 && fromJSON(Args->front(), R.tweakArgs);
627  return false; // Unrecognized command.
628 }
629 
630 llvm::json::Value toJSON(const SymbolInformation &P) {
631  return llvm::json::Object{
632  {"name", P.name},
633  {"kind", static_cast<int>(P.kind)},
634  {"location", P.location},
635  {"containerName", P.containerName},
636  };
637 }
638 
639 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
640  const SymbolInformation &SI) {
641  O << SI.containerName << "::" << SI.name << " - " << toJSON(SI);
642  return O;
643 }
644 
645 bool operator==(const SymbolDetails &LHS, const SymbolDetails &RHS) {
646  return LHS.name == RHS.name && LHS.containerName == RHS.containerName &&
647  LHS.USR == RHS.USR && LHS.ID == RHS.ID;
648 }
649 
650 llvm::json::Value toJSON(const SymbolDetails &P) {
651  llvm::json::Object Result{{"name", llvm::json::Value(nullptr)},
652  {"containerName", llvm::json::Value(nullptr)},
653  {"usr", llvm::json::Value(nullptr)},
654  {"id", llvm::json::Value(nullptr)}};
655 
656  if (!P.name.empty())
657  Result["name"] = P.name;
658 
659  if (!P.containerName.empty())
660  Result["containerName"] = P.containerName;
661 
662  if (!P.USR.empty())
663  Result["usr"] = P.USR;
664 
665  if (P.ID.hasValue())
666  Result["id"] = P.ID.getValue().str();
667 
668  // FIXME: workaround for older gcc/clang
669  return std::move(Result);
670 }
671 
672 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const SymbolDetails &S) {
673  if (!S.containerName.empty()) {
674  O << S.containerName;
675  llvm::StringRef ContNameRef;
676  if (!ContNameRef.endswith("::")) {
677  O << " ";
678  }
679  }
680  O << S.name << " - " << toJSON(S);
681  return O;
682 }
683 
684 bool fromJSON(const llvm::json::Value &Params, WorkspaceSymbolParams &R) {
685  llvm::json::ObjectMapper O(Params);
686  return O && O.map("query", R.query);
687 }
688 
689 llvm::json::Value toJSON(const Command &C) {
690  auto Cmd = llvm::json::Object{{"title", C.title}, {"command", C.command}};
691  if (C.workspaceEdit)
692  Cmd["arguments"] = {*C.workspaceEdit};
693  if (C.tweakArgs)
694  Cmd["arguments"] = {*C.tweakArgs};
695  return std::move(Cmd);
696 }
697 
698 const llvm::StringLiteral CodeAction::QUICKFIX_KIND = "quickfix";
699 const llvm::StringLiteral CodeAction::REFACTOR_KIND = "refactor";
700 const llvm::StringLiteral CodeAction::INFO_KIND = "info";
701 
702 llvm::json::Value toJSON(const CodeAction &CA) {
703  auto CodeAction = llvm::json::Object{{"title", CA.title}};
704  if (CA.kind)
705  CodeAction["kind"] = *CA.kind;
706  if (CA.diagnostics)
707  CodeAction["diagnostics"] = llvm::json::Array(*CA.diagnostics);
708  if (CA.edit)
709  CodeAction["edit"] = *CA.edit;
710  if (CA.command)
711  CodeAction["command"] = *CA.command;
712  return std::move(CodeAction);
713 }
714 
715 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S) {
716  return O << S.name << " - " << toJSON(S);
717 }
718 
719 llvm::json::Value toJSON(const DocumentSymbol &S) {
720  llvm::json::Object Result{{"name", S.name},
721  {"kind", static_cast<int>(S.kind)},
722  {"range", S.range},
723  {"selectionRange", S.selectionRange}};
724 
725  if (!S.detail.empty())
726  Result["detail"] = S.detail;
727  if (!S.children.empty())
728  Result["children"] = S.children;
729  if (S.deprecated)
730  Result["deprecated"] = true;
731  // FIXME: workaround for older gcc/clang
732  return std::move(Result);
733 }
734 
735 llvm::json::Value toJSON(const WorkspaceEdit &WE) {
736  if (!WE.changes)
737  return llvm::json::Object{};
738  llvm::json::Object FileChanges;
739  for (auto &Change : *WE.changes)
740  FileChanges[Change.first] = llvm::json::Array(Change.second);
741  return llvm::json::Object{{"changes", std::move(FileChanges)}};
742 }
743 
744 bool fromJSON(const llvm::json::Value &Params, TweakArgs &A) {
745  llvm::json::ObjectMapper O(Params);
746  return O && O.map("file", A.file) && O.map("selection", A.selection) &&
747  O.map("tweakID", A.tweakID);
748 }
749 
750 llvm::json::Value toJSON(const TweakArgs &A) {
751  return llvm::json::Object{
752  {"tweakID", A.tweakID}, {"selection", A.selection}, {"file", A.file}};
753 }
754 
755 llvm::json::Value toJSON(const ApplyWorkspaceEditParams &Params) {
756  return llvm::json::Object{{"edit", Params.edit}};
757 }
758 
759 bool fromJSON(const llvm::json::Value &Response,
761  llvm::json::ObjectMapper O(Response);
762  if (!O || !O.map("applied", R.applied))
763  return false;
764  O.map("failureReason", R.failureReason);
765  return true;
766 }
767 
768 bool fromJSON(const llvm::json::Value &Params, TextDocumentPositionParams &R) {
769  llvm::json::ObjectMapper O(Params);
770  return O && O.map("textDocument", R.textDocument) &&
771  O.map("position", R.position);
772 }
773 
774 bool fromJSON(const llvm::json::Value &Params, CompletionContext &R) {
775  llvm::json::ObjectMapper O(Params);
776  if (!O)
777  return false;
778 
779  int TriggerKind;
780  if (!O.map("triggerKind", TriggerKind))
781  return false;
782  R.triggerKind = static_cast<CompletionTriggerKind>(TriggerKind);
783 
784  if (auto *TC = Params.getAsObject()->get("triggerCharacter"))
785  return fromJSON(*TC, R.triggerCharacter);
786  return true;
787 }
788 
789 bool fromJSON(const llvm::json::Value &Params, CompletionParams &R) {
790  if (!fromJSON(Params, static_cast<TextDocumentPositionParams &>(R)))
791  return false;
792  if (auto *Context = Params.getAsObject()->get("context"))
793  return fromJSON(*Context, R.context);
794  return true;
795 }
796 
797 static llvm::StringRef toTextKind(MarkupKind Kind) {
798  switch (Kind) {
800  return "plaintext";
802  return "markdown";
803  }
804  llvm_unreachable("Invalid MarkupKind");
805 }
806 
807 bool fromJSON(const llvm::json::Value &V, MarkupKind &K) {
808  auto Str = V.getAsString();
809  if (!Str) {
810  elog("Failed to parse markup kind: expected a string");
811  return false;
812  }
813  if (*Str == "plaintext")
815  else if (*Str == "markdown")
817  else {
818  elog("Unknown markup kind: {0}", *Str);
819  return false;
820  }
821  return true;
822 }
823 
824 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, MarkupKind K) {
825  return OS << toTextKind(K);
826 }
827 
828 llvm::json::Value toJSON(const MarkupContent &MC) {
829  if (MC.value.empty())
830  return nullptr;
831 
832  return llvm::json::Object{
833  {"kind", toTextKind(MC.kind)},
834  {"value", MC.value},
835  };
836 }
837 
838 llvm::json::Value toJSON(const Hover &H) {
839  llvm::json::Object Result{{"contents", toJSON(H.contents)}};
840 
841  if (H.range.hasValue())
842  Result["range"] = toJSON(*H.range);
843 
844  return std::move(Result);
845 }
846 
847 bool fromJSON(const llvm::json::Value &E, CompletionItemKind &Out) {
848  if (auto T = E.getAsInteger()) {
849  if (*T < static_cast<int>(CompletionItemKind::Text) ||
850  *T > static_cast<int>(CompletionItemKind::TypeParameter))
851  return false;
852  Out = static_cast<CompletionItemKind>(*T);
853  return true;
854  }
855  return false;
856 }
857 
860  CompletionItemKindBitset &SupportedCompletionItemKinds) {
861  auto KindVal = static_cast<size_t>(Kind);
862  if (KindVal >= CompletionItemKindMin &&
863  KindVal <= SupportedCompletionItemKinds.size() &&
864  SupportedCompletionItemKinds[KindVal])
865  return Kind;
866 
867  switch (Kind) {
868  // Provide some fall backs for common kinds that are close enough.
875  default:
877  }
878 }
879 
880 bool fromJSON(const llvm::json::Value &E, CompletionItemKindBitset &Out) {
881  if (auto *A = E.getAsArray()) {
882  for (size_t I = 0; I < A->size(); ++I) {
883  CompletionItemKind KindOut;
884  if (fromJSON((*A)[I], KindOut))
885  Out.set(size_t(KindOut));
886  }
887  return true;
888  }
889  return false;
890 }
891 
892 llvm::json::Value toJSON(const CompletionItem &CI) {
893  assert(!CI.label.empty() && "completion item label is required");
894  llvm::json::Object Result{{"label", CI.label}};
895  if (CI.kind != CompletionItemKind::Missing)
896  Result["kind"] = static_cast<int>(CI.kind);
897  if (!CI.detail.empty())
898  Result["detail"] = CI.detail;
899  if (CI.documentation)
900  Result["documentation"] = CI.documentation;
901  if (!CI.sortText.empty())
902  Result["sortText"] = CI.sortText;
903  if (!CI.filterText.empty())
904  Result["filterText"] = CI.filterText;
905  if (!CI.insertText.empty())
906  Result["insertText"] = CI.insertText;
907  if (CI.insertTextFormat != InsertTextFormat::Missing)
908  Result["insertTextFormat"] = static_cast<int>(CI.insertTextFormat);
909  if (CI.textEdit)
910  Result["textEdit"] = *CI.textEdit;
911  if (!CI.additionalTextEdits.empty())
912  Result["additionalTextEdits"] = llvm::json::Array(CI.additionalTextEdits);
913  if (CI.deprecated)
914  Result["deprecated"] = CI.deprecated;
915  Result["score"] = CI.score;
916  return std::move(Result);
917 }
918 
919 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const CompletionItem &I) {
920  O << I.label << " - " << toJSON(I);
921  return O;
922 }
923 
924 bool operator<(const CompletionItem &L, const CompletionItem &R) {
925  return (L.sortText.empty() ? L.label : L.sortText) <
926  (R.sortText.empty() ? R.label : R.sortText);
927 }
928 
929 llvm::json::Value toJSON(const CompletionList &L) {
930  return llvm::json::Object{
931  {"isIncomplete", L.isIncomplete},
932  {"items", llvm::json::Array(L.items)},
933  };
934 }
935 
936 llvm::json::Value toJSON(const ParameterInformation &PI) {
937  assert((PI.labelOffsets.hasValue() || !PI.labelString.empty()) &&
938  "parameter information label is required");
939  llvm::json::Object Result;
940  if (PI.labelOffsets)
941  Result["label"] =
942  llvm::json::Array({PI.labelOffsets->first, PI.labelOffsets->second});
943  else
944  Result["label"] = PI.labelString;
945  if (!PI.documentation.empty())
946  Result["documentation"] = PI.documentation;
947  return std::move(Result);
948 }
949 
950 llvm::json::Value toJSON(const SignatureInformation &SI) {
951  assert(!SI.label.empty() && "signature information label is required");
952  llvm::json::Object Result{
953  {"label", SI.label},
954  {"parameters", llvm::json::Array(SI.parameters)},
955  };
956  if (!SI.documentation.empty())
957  Result["documentation"] = SI.documentation;
958  return std::move(Result);
959 }
960 
961 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
962  const SignatureInformation &I) {
963  O << I.label << " - " << toJSON(I);
964  return O;
965 }
966 
967 llvm::json::Value toJSON(const SignatureHelp &SH) {
968  assert(SH.activeSignature >= 0 &&
969  "Unexpected negative value for number of active signatures.");
970  assert(SH.activeParameter >= 0 &&
971  "Unexpected negative value for active parameter index");
972  return llvm::json::Object{
973  {"activeSignature", SH.activeSignature},
974  {"activeParameter", SH.activeParameter},
975  {"signatures", llvm::json::Array(SH.signatures)},
976  };
977 }
978 
979 bool fromJSON(const llvm::json::Value &Params, RenameParams &R) {
980  llvm::json::ObjectMapper O(Params);
981  return O && O.map("textDocument", R.textDocument) &&
982  O.map("position", R.position) && O.map("newName", R.newName);
983 }
984 
985 llvm::json::Value toJSON(const DocumentHighlight &DH) {
986  return llvm::json::Object{
987  {"range", toJSON(DH.range)},
988  {"kind", static_cast<int>(DH.kind)},
989  };
990 }
991 
992 llvm::json::Value toJSON(const FileStatus &FStatus) {
993  return llvm::json::Object{
994  {"uri", FStatus.uri},
995  {"state", FStatus.state},
996  };
997 }
998 
999 constexpr unsigned SemanticTokenEncodingSize = 5;
1000 static llvm::json::Value encodeTokens(llvm::ArrayRef<SemanticToken> Toks) {
1001  llvm::json::Array Result;
1002  for (const auto &Tok : Toks) {
1003  Result.push_back(Tok.deltaLine);
1004  Result.push_back(Tok.deltaStart);
1005  Result.push_back(Tok.length);
1006  Result.push_back(Tok.tokenType);
1007  Result.push_back(Tok.tokenModifiers);
1008  }
1009  assert(Result.size() == SemanticTokenEncodingSize * Toks.size());
1010  return std::move(Result);
1011 }
1012 
1013 bool operator==(const SemanticToken &L, const SemanticToken &R) {
1014  return std::tie(L.deltaLine, L.deltaStart, L.length, L.tokenType,
1015  L.tokenModifiers) == std::tie(R.deltaLine, R.deltaStart,
1016  R.length, R.tokenType,
1017  R.tokenModifiers);
1018 }
1019 
1020 llvm::json::Value toJSON(const SemanticTokens &Tokens) {
1021  return llvm::json::Object{{"resultId", Tokens.resultId},
1022  {"data", encodeTokens(Tokens.tokens)}};
1023 }
1024 
1025 llvm::json::Value toJSON(const SemanticTokensEdit &Edit) {
1026  return llvm::json::Object{
1027  {"start", SemanticTokenEncodingSize * Edit.startToken},
1028  {"deleteCount", SemanticTokenEncodingSize * Edit.deleteTokens},
1029  {"data", encodeTokens(Edit.tokens)}};
1030 }
1031 
1032 llvm::json::Value toJSON(const SemanticTokensOrDelta &TE) {
1033  llvm::json::Object Result{{"resultId", TE.resultId}};
1034  if (TE.edits)
1035  Result["edits"] = *TE.edits;
1036  if (TE.tokens)
1037  Result["data"] = encodeTokens(*TE.tokens);
1038  return std::move(Result);
1039 }
1040 
1041 bool fromJSON(const llvm::json::Value &Params, SemanticTokensParams &R) {
1042  llvm::json::ObjectMapper O(Params);
1043  return O && O.map("textDocument", R.textDocument);
1044 }
1045 
1046 bool fromJSON(const llvm::json::Value &Params, SemanticTokensDeltaParams &R) {
1047  llvm::json::ObjectMapper O(Params);
1048  return O && O.map("textDocument", R.textDocument) &&
1049  O.map("previousResultId", R.previousResultId);
1050 }
1051 
1052 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1053  const DocumentHighlight &V) {
1054  O << V.range;
1056  O << "(r)";
1058  O << "(w)";
1059  return O;
1060 }
1061 
1062 bool fromJSON(const llvm::json::Value &Params,
1064  llvm::json::ObjectMapper O(Params);
1065  return O && O.map("settings", CCP.settings);
1066 }
1067 
1068 bool fromJSON(const llvm::json::Value &Params,
1069  ClangdCompileCommand &CDbUpdate) {
1070  llvm::json::ObjectMapper O(Params);
1071  return O && O.map("workingDirectory", CDbUpdate.workingDirectory) &&
1072  O.map("compilationCommand", CDbUpdate.compilationCommand);
1073 }
1074 
1075 bool fromJSON(const llvm::json::Value &Params, ConfigurationSettings &S) {
1076  llvm::json::ObjectMapper O(Params);
1077  if (!O)
1078  return true; // 'any' type in LSP.
1079  O.map("compilationDatabaseChanges", S.compilationDatabaseChanges);
1080  return true;
1081 }
1082 
1083 bool fromJSON(const llvm::json::Value &Params, InitializationOptions &Opts) {
1084  llvm::json::ObjectMapper O(Params);
1085  if (!O)
1086  return true; // 'any' type in LSP.
1087 
1088  fromJSON(Params, Opts.ConfigSettings);
1089  O.map("compilationDatabasePath", Opts.compilationDatabasePath);
1090  O.map("fallbackFlags", Opts.fallbackFlags);
1091  O.map("clangdFileStatus", Opts.FileStatus);
1092  return true;
1093 }
1094 
1095 bool fromJSON(const llvm::json::Value &E, TypeHierarchyDirection &Out) {
1096  auto T = E.getAsInteger();
1097  if (!T)
1098  return false;
1099  if (*T < static_cast<int>(TypeHierarchyDirection::Children) ||
1100  *T > static_cast<int>(TypeHierarchyDirection::Both))
1101  return false;
1102  Out = static_cast<TypeHierarchyDirection>(*T);
1103  return true;
1104 }
1105 
1106 bool fromJSON(const llvm::json::Value &Params, TypeHierarchyParams &R) {
1107  llvm::json::ObjectMapper O(Params);
1108  return O && O.map("textDocument", R.textDocument) &&
1109  O.map("position", R.position) && O.map("resolve", R.resolve) &&
1110  O.map("direction", R.direction);
1111 }
1112 
1113 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1114  const TypeHierarchyItem &I) {
1115  return O << I.name << " - " << toJSON(I);
1116 }
1117 
1118 llvm::json::Value toJSON(const TypeHierarchyItem &I) {
1119  llvm::json::Object Result{{"name", I.name},
1120  {"kind", static_cast<int>(I.kind)},
1121  {"range", I.range},
1122  {"selectionRange", I.selectionRange},
1123  {"uri", I.uri}};
1124 
1125  if (I.detail)
1126  Result["detail"] = I.detail;
1127  if (I.deprecated)
1128  Result["deprecated"] = I.deprecated;
1129  if (I.parents)
1130  Result["parents"] = I.parents;
1131  if (I.children)
1132  Result["children"] = I.children;
1133  if (I.data)
1134  Result["data"] = I.data;
1135  return std::move(Result);
1136 }
1137 
1138 bool fromJSON(const llvm::json::Value &Params, TypeHierarchyItem &I) {
1139  llvm::json::ObjectMapper O(Params);
1140 
1141  // Required fields.
1142  if (!(O && O.map("name", I.name) && O.map("kind", I.kind) &&
1143  O.map("uri", I.uri) && O.map("range", I.range) &&
1144  O.map("selectionRange", I.selectionRange))) {
1145  return false;
1146  }
1147 
1148  // Optional fields.
1149  O.map("detail", I.detail);
1150  O.map("deprecated", I.deprecated);
1151  O.map("parents", I.parents);
1152  O.map("children", I.children);
1153  O.map("data", I.data);
1154 
1155  return true;
1156 }
1157 
1158 bool fromJSON(const llvm::json::Value &Params,
1160  llvm::json::ObjectMapper O(Params);
1161  return O && O.map("item", P.item) && O.map("resolve", P.resolve) &&
1162  O.map("direction", P.direction);
1163 }
1164 
1165 bool fromJSON(const llvm::json::Value &Params, ReferenceParams &R) {
1167  return fromJSON(Params, Base);
1168 }
1169 
1170 static const char *toString(OffsetEncoding OE) {
1171  switch (OE) {
1172  case OffsetEncoding::UTF8:
1173  return "utf-8";
1174  case OffsetEncoding::UTF16:
1175  return "utf-16";
1176  case OffsetEncoding::UTF32:
1177  return "utf-32";
1179  return "unknown";
1180  }
1181  llvm_unreachable("Unknown clang.clangd.OffsetEncoding");
1182 }
1183 llvm::json::Value toJSON(const OffsetEncoding &OE) { return toString(OE); }
1184 bool fromJSON(const llvm::json::Value &V, OffsetEncoding &OE) {
1185  auto Str = V.getAsString();
1186  if (!Str)
1187  return false;
1188  OE = llvm::StringSwitch<OffsetEncoding>(*Str)
1189  .Case("utf-8", OffsetEncoding::UTF8)
1190  .Case("utf-16", OffsetEncoding::UTF16)
1191  .Case("utf-32", OffsetEncoding::UTF32)
1193  return true;
1194 }
1195 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, OffsetEncoding Enc) {
1196  return OS << toString(Enc);
1197 }
1198 
1201  return Lhs.Line == Rhs.Line && Lhs.Tokens == Rhs.Tokens;
1202 }
1203 
1204 llvm::json::Value
1206  return llvm::json::Object{{"line", Highlighting.Line},
1207  {"tokens", Highlighting.Tokens},
1208  {"isInactive", Highlighting.IsInactive}};
1209 }
1210 
1211 llvm::json::Value toJSON(const TheiaSemanticHighlightingParams &Highlighting) {
1212  return llvm::json::Object{
1213  {"textDocument", Highlighting.TextDocument},
1214  {"lines", std::move(Highlighting.Lines)},
1215  };
1216 }
1217 
1218 bool fromJSON(const llvm::json::Value &Params, SelectionRangeParams &P) {
1219  llvm::json::ObjectMapper O(Params);
1220  return O && O.map("textDocument", P.textDocument) &&
1221  O.map("positions", P.positions);
1222 }
1223 
1224 llvm::json::Value toJSON(const SelectionRange &Out) {
1225  if (Out.parent) {
1226  return llvm::json::Object{{"range", Out.range},
1227  {"parent", toJSON(*Out.parent)}};
1228  }
1229  return llvm::json::Object{{"range", Out.range}};
1230 }
1231 
1232 bool fromJSON(const llvm::json::Value &Params, DocumentLinkParams &R) {
1233  llvm::json::ObjectMapper O(Params);
1234  return O && O.map("textDocument", R.textDocument);
1235 }
1236 
1237 llvm::json::Value toJSON(const DocumentLink &DocumentLink) {
1238  return llvm::json::Object{
1239  {"range", DocumentLink.range},
1240  {"target", DocumentLink.target},
1241  };
1242 }
1243 
1244 bool fromJSON(const llvm::json::Value &Params, FoldingRangeParams &R) {
1245  llvm::json::ObjectMapper O(Params);
1246  return O && O.map("textDocument", R.textDocument);
1247 }
1248 
1249 llvm::json::Value toJSON(const FoldingRange &Range) {
1250  llvm::json::Object Result{
1251  {"startLine", Range.startLine},
1252  {"endLine", Range.endLine},
1253  };
1254  if (Range.startCharacter)
1255  Result["startCharacter"] = Range.startCharacter;
1256  if (Range.endCharacter)
1257  Result["endCharacter"] = Range.endCharacter;
1258  if (Range.kind)
1259  Result["kind"] = *Range.kind;
1260  return Result;
1261 }
1262 
1263 } // namespace clangd
1264 } // namespace clang
clang::clangd::TraceLevel::Messages
clang::clangd::DocumentHighlight
A document highlight is a range inside a text document which deserves special attention.
Definition: Protocol.h:1248
clang::clangd::WorkspaceEdit::changes
llvm::Optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
Definition: Protocol.h:862
clang::clangd::TypeHierarchyItem::selectionRange
Range selectionRange
The range that should be selected and revealed when this type hierarchy item is being picked,...
Definition: Protocol.h:1311
clang::clangd::SignatureInformation::documentation
std::string documentation
The documentation of this signature. Optional.
Definition: Protocol.h:1200
clang::clangd::WorkspaceEdit
Definition: Protocol.h:860
clang::clangd::CompletionList::isIncomplete
bool isIncomplete
The list is not complete.
Definition: Protocol.h:1169
clang::clangd::DocumentSymbol::range
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
Definition: Protocol.h:962
clang::clangd::DidOpenTextDocumentParams::textDocument
TextDocumentItem textDocument
The document that was opened.
Definition: Protocol.h:651
Base
std::unique_ptr< GlobalCompilationDatabase > Base
Definition: GlobalCompilationDatabaseTests.cpp:85
clang::clangd::Diagnostic::source
std::string source
A human-readable string describing the source of this diagnostic, e.g.
Definition: Protocol.h:797
clang::clangd::DocumentOnTypeFormattingParams::ch
std::string ch
The character that has been typed.
Definition: Protocol.h:756
clang::clangd::SymbolKindMin
constexpr auto SymbolKindMin
Definition: Protocol.h:350
clang::clangd::TextDocumentIdentifier::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:123
clang::clangd::ClangdCompileCommand
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
Definition: Protocol.h:478
clang::clangd::ExecuteCommandParams::CLANGD_APPLY_TWEAK
const static llvm::StringLiteral CLANGD_APPLY_TWEAK
Definition: Protocol.h:897
clang::clangd::ClangdCompileCommand::workingDirectory
std::string workingDirectory
Definition: Protocol.h:479
clang::clangd::MarkupKind::PlainText
clang::clangd::ClientCapabilities::DiagnosticFixes
bool DiagnosticFixes
Whether the client accepts diagnostics with codeActions attached inline.
Definition: Protocol.h:397
clang::clangd::MarkupKind::Markdown
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:692
clang::clangd::SemanticTokensDeltaParams::previousResultId
std::string previousResultId
The previous result id.
Definition: Protocol.h:1405
clang::clangd::SemanticToken::tokenModifiers
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
Definition: Protocol.h:1375
clang::clangd::Edit
A set of edits generated for a single file.
Definition: SourceCode.h:180
clang::clangd::SemanticTokensParams
Body of textDocument/semanticTokens/full request.
Definition: Protocol.h:1393
E
const Expr * E
Definition: AvoidBindCheck.cpp:88
clang::clangd::Location::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:201
clang::clangd::PublishDiagnosticsParams::diagnostics
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
Definition: Protocol.h:836
clang::clangd::FileEvent::uri
URIForFile uri
The file's URI.
Definition: Protocol.h:714
clang::clangd::TraceLevel
TraceLevel
Definition: Protocol.h:253
clang::clangd::ClientCapabilities::DiagnosticCategory
bool DiagnosticCategory
Whether the client accepts diagnostics with category attached to it using the "category" extension.
Definition: Protocol.h:406
clang::clangd::SemanticTokensOrDelta::resultId
std::string resultId
Definition: Protocol.h:1423
clang::clangd::CompletionItemKind::Class
clang::clangd::FileEvent
Definition: Protocol.h:712
clang::clangd::ShowMessageParams::type
MessageType type
The message type.
Definition: Protocol.h:643
clang::clangd::ResolveTypeHierarchyItemParams::resolve
int resolve
The hierarchy levels to resolve. 0 indicates no level.
Definition: Protocol.h:1337
clang::clangd::SemanticTokensParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1395
clang::clangd::CodeAction
A code action represents a change that can be performed in code, e.g.
Definition: Protocol.h:918
clang::clangd::Diagnostic::category
llvm::Optional< std::string > category
The diagnostic's category.
Definition: Protocol.h:810
clang::clangd::SemanticTokensDeltaParams
Body of textDocument/semanticTokens/full/delta request.
Definition: Protocol.h:1401
clang::clangd::MarkupContent::kind
MarkupKind kind
Definition: Protocol.h:1065
clang::clangd::Location
Definition: Protocol.h:199
clang::clangd::ClientCapabilities::CompletionItemKinds
llvm::Optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
Definition: Protocol.h:431
clang::clangd::SemanticTokenEncodingSize
constexpr unsigned SemanticTokenEncodingSize
Definition: Protocol.cpp:999
clang::clangd::DocumentOnTypeFormattingParams::textDocument
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:750
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:623
clang::clangd::DocumentRangeFormattingParams::textDocument
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:741
clang::clangd::InitializeParams::processId
llvm::Optional< int > processId
The process Id of the parent process that started the server.
Definition: Protocol.h:517
clang::clangd::CompletionList
Represents a collection of completion items to be presented in the editor.
Definition: Protocol.h:1166
clang::clangd::ClientCapabilities::CompletionFixes
bool CompletionFixes
Client supports completions with additionalTextEdit near the cursor.
Definition: Protocol.h:415
clang::clangd::Context::get
const Type * get(const Key< Type > &Key) const
Get data stored for a typed Key.
Definition: Context.h:100
clang::clangd::CompletionItemKind::Field
clang::clangd::ClientCapabilities
Definition: Protocol.h:390
clang::clangd::SemanticTokensEdit
Describes a a replacement of a contiguous range of semanticTokens.
Definition: Protocol.h:1410
clang::clangd::SemanticTokensOrDelta
This models LSP SemanticTokensDelta | SemanticTokens, which is the result of textDocument/semanticTok...
Definition: Protocol.h:1422
clang::clangd::DocumentRangeFormattingParams::range
Range range
The range to format.
Definition: Protocol.h:744
clang::clangd::Hover
Definition: Protocol.h:1070
clang::clangd::ClientCapabilities::WorkspaceSymbolKinds
llvm::Optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
Definition: Protocol.h:393
clang::clangd::SelectionRangeParams::positions
std::vector< Position > positions
The positions inside the text document.
Definition: Protocol.h:1463
clang::clangd::DidCloseTextDocumentParams
Definition: Protocol.h:655
clang::clangd::DocumentOnTypeFormattingParams::position
Position position
The position at which this request was sent.
Definition: Protocol.h:753
CI
std::unique_ptr< CompilerInvocation > CI
Definition: TUScheduler.cpp:320
clang::clangd::ApplyWorkspaceEditResponse::applied
bool applied
Definition: Protocol.h:1025
clang::clangd::OffsetEncoding::UTF32
clang::clangd::SymbolInformation
Represents information about programming constructs like variables, classes, interfaces etc.
Definition: Protocol.h:976
clang::clangd::TheiaSemanticHighlightingInformation::Tokens
std::string Tokens
The base64 encoded string of highlighting tokens.
Definition: Protocol.h:1437
clang::clangd::DidChangeConfigurationParams::settings
ConfigurationSettings settings
Definition: Protocol.h:727
Kind
BindArgumentKind Kind
Definition: AvoidBindCheck.cpp:59
clang::clangd::CompletionItem::label
std::string label
The label of this completion item.
Definition: Protocol.h:1101
clang::clangd::ClientCapabilities::HierarchicalDocumentSymbol
bool HierarchicalDocumentSymbol
Client supports hierarchical document symbols.
Definition: Protocol.h:419
clang::clangd::Range::start
Position start
The range's start position.
Definition: Protocol.h:175
clang::clangd::URI::resolvePath
static llvm::Expected< std::string > resolvePath(llvm::StringRef AbsPath, llvm::StringRef HintPath="")
Resolves AbsPath into a canonical path of its URI, by converting AbsPath to URI and resolving the URI...
Definition: URI.cpp:240
clang::clangd::CompletionItemKind::Folder
clang::clangd::DidChangeTextDocumentParams::forceRebuild
bool forceRebuild
Force a complete rebuild of the file, ignoring all cached state.
Definition: Protocol.h:698
clang::clangd::SymbolInformation::name
std::string name
The name of this symbol.
Definition: Protocol.h:978
clang::clangd::ClientCapabilities::CompletionDocumentationFormat
MarkupKind CompletionDocumentationFormat
The documentation format that should be used for textDocument/completion.
Definition: Protocol.h:435
clang::clangd::FileChangeType::Created
The file got created.
clang::clangd::ParameterInformation::documentation
std::string documentation
The documentation of this parameter. Optional.
Definition: Protocol.h:1189
clang::clangd::TypeHierarchyItem::kind
SymbolKind kind
The kind of the hierarchy item. For instance, class or interface.
Definition: Protocol.h:1294
clang::clangd::FoldingRangeParams
Definition: Protocol.h:1515
clang::clangd::ClientCapabilities::CompletionSnippets
bool CompletionSnippets
Client supports snippets as insert text.
Definition: Protocol.h:410
clang::clangd::Location::range
Range range
Definition: Protocol.h:202
clang::clangd::SemanticToken::deltaLine
unsigned deltaLine
token line number, relative to the previous token
Definition: Protocol.h:1366
clang::clangd::CompletionItemKind::Property
clang::clangd::InitializeParams
Definition: Protocol.h:512
clang::clangd::DocumentHighlight::range
Range range
The range this highlight applies to.
Definition: Protocol.h:1250
clang::clangd::URIForFile::fromURI
static llvm::Expected< URIForFile > fromURI(const URI &U, llvm::StringRef HintPath)
Definition: Protocol.cpp:46
clang::clangd::CompletionItemKind::Text
clang::clangd::TweakArgs::tweakID
std::string tweakID
ID of the tweak that should be executed. Corresponds to Tweak::id().
Definition: Protocol.h:880
clang::clangd::CodeActionParams::textDocument
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Definition: Protocol.h:850
clang::clangd::SymbolKind::Class
clang::clangd::CodeActionParams::context
CodeActionContext context
Context carrying additional information.
Definition: Protocol.h:856
clang::clangd::TextDocumentItem
Definition: Protocol.h:235
clang::clangd::ApplyWorkspaceEditResponse::failureReason
llvm::Optional< std::string > failureReason
Definition: Protocol.h:1026
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:1186
clang::clangd::URI::parse
static llvm::Expected< URI > parse(llvm::StringRef Uri)
Parse a URI string "<scheme>:[//<authority>/]<path>".
Definition: URI.cpp:163
clang::clangd::DocumentSymbol::children
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
Definition: Protocol.h:969
clang::clangd::SymbolKindBitset
std::bitset< SymbolKindMax+1 > SymbolKindBitset
Definition: Protocol.h:352
clang::clangd::CompletionItem
Definition: Protocol.h:1098
clang::clangd::SymbolDetails::containerName
std::string containerName
Definition: Protocol.h:997
clang::clangd::DocumentFormattingParams
Definition: Protocol.h:760
clang::clangd::TypeHierarchyItem::range
Range range
The range enclosing this type hierarchy item not including leading/trailing whitespace but everything...
Definition: Protocol.h:1306
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:246
clang::clangd::SymbolKind
SymbolKind
A symbol kind.
Definition: Protocol.h:321
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:572
clang::clangd::RenameParams::position
Position position
The position at which this request was sent.
Definition: Protocol.h:1235
clang::clangd::Diagnostic::range
Range range
The range at which the message applies.
Definition: Protocol.h:786
clang::clangd::MarkupContent::value
std::string value
Definition: Protocol.h:1066
clang::clangd::WorkDoneProgressReport::cancellable
llvm::Optional< bool > cancellable
Controls enablement state of a cancel button.
Definition: Protocol.h:600
clang::clangd::ExecuteCommandParams::tweakArgs
llvm::Optional< TweakArgs > tweakArgs
Definition: Protocol.h:904
clang::clangd::DocumentSymbolParams
Definition: Protocol.h:766
clang::clangd::OffsetEncoding::UTF8
clang::clangd::CompletionItemKindBitset
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
Definition: Protocol.h:314
clang::clangd::Position::line
int line
Line position in a document (zero-based).
Definition: Protocol.h:146
clang::clangd::CodeAction::kind
llvm::Optional< std::string > kind
The kind of the code action.
Definition: Protocol.h:924
clang::clangd::SelectionRangeParams
Definition: Protocol.h:1458
clang::clangd::WorkDoneProgressBegin
To start progress reporting a $/progress notification with the following payload must be sent.
Definition: Protocol.h:562
clang::clangd::DiagnosticRelatedInformation::location
Location location
The location of this related diagnostic information.
Definition: Protocol.h:777
clang::clangd::CompletionItemKind::Enum
clang::clangd::CodeAction::title
std::string title
A short, human-readable, title for this code action.
Definition: Protocol.h:920
clang::clangd::DocumentHighlight::kind
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
Definition: Protocol.h:1253
clang::clangd::TheiaSemanticHighlightingInformation
Represents a semantic highlighting information that has to be applied on a specific line of the text ...
Definition: Protocol.h:1433
clang::clangd::SymbolDetails::name
std::string name
Definition: Protocol.h:995
Protocol.h
clang::clangd::toTextKind
static llvm::StringRef toTextKind(MarkupKind Kind)
Definition: Protocol.cpp:797
clang::clangd::TypeHierarchyDirection::Both
clang::clangd::SignatureInformation::parameters
std::vector< ParameterInformation > parameters
The parameters of this signature.
Definition: Protocol.h:1203
clang::clangd::URI::resolve
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
Resolves the absolute path of U.
Definition: URI.cpp:232
clang::clangd::Diagnostic
Definition: Protocol.h:784
clang::clangd::TextDocumentItem::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:237
clang::clangd::WorkDoneProgressEnd
Signals the end of progress reporting.
Definition: Protocol.h:620
clang::clangd::ClientCapabilities::offsetEncoding
llvm::Optional< std::vector< OffsetEncoding > > offsetEncoding
Supported encodings for LSP character offsets. (clangd extension).
Definition: Protocol.h:453
clang::clangd::ClientCapabilities::OffsetsInSignatureHelp
bool OffsetsInSignatureHelp
Client supports processing label offsets instead of a simple label string.
Definition: Protocol.h:427
clang::clangd::CompletionContext::triggerCharacter
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
Definition: Protocol.h:1055
clang::clangd::Position
Definition: Protocol.h:144
clang::clangd::CodeAction::edit
llvm::Optional< WorkspaceEdit > edit
The workspace edit this code action performs.
Definition: Protocol.h:933
clang::clangd::InitializeParams::capabilities
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
Definition: Protocol.h:534
clang::clangd::SymbolKind::Method
clang::clangd::SymbolKind::Function
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:1356
clang::clangd::ClientCapabilities::RenamePrepareSupport
bool RenamePrepareSupport
The client supports testing for validity of rename operations before execution.
Definition: Protocol.h:461
clang::clangd::ClientCapabilities::HoverContentFormat
MarkupKind HoverContentFormat
The content format that should be used for Hover requests.
Definition: Protocol.h:457
clang::clangd::TweakArgs
Arguments for the 'applyTweak' command.
Definition: Protocol.h:874
clang::clangd::TypeHierarchyDirection::Children
clang::clangd::SemanticToken
Specifies a single semantic token in the document.
Definition: Protocol.h:1364
clang::clangd::CompletionItemKind::Interface
clang::clangd::SignatureInformation::label
std::string label
The label of this signature. Mandatory.
Definition: Protocol.h:1197
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:1425
clang::clangd::SignatureHelp::signatures
std::vector< SignatureInformation > signatures
The resulting signatures.
Definition: Protocol.h:1213
clang::clangd::TheiaSemanticHighlightingParams
Parameters for the semantic highlighting (server-side) push notification.
Definition: Protocol.h:1450
clang::clangd::DocumentSymbolParams::textDocument
TextDocumentIdentifier textDocument
Definition: Protocol.h:768
clang::clangd::TheiaSemanticHighlightingParams::Lines
std::vector< TheiaSemanticHighlightingInformation > Lines
The lines of highlightings that should be sent.
Definition: Protocol.h:1454
clang::clangd::DidChangeWatchedFilesParams
Definition: Protocol.h:720
clang::clangd::PublishDiagnosticsParams::uri
URIForFile uri
The URI for which diagnostic information is reported.
Definition: Protocol.h:834
clang::clangd::Diag
A top-level diagnostic that may have Notes and Fixes.
Definition: Diagnostics.h:86
clang::clangd::toJSON
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
Definition: Index.cpp:48
Logger.h
clang::clangd::CompletionList::items
std::vector< CompletionItem > items
The completion items.
Definition: Protocol.h:1172
clang::clangd::WorkDoneProgressReport::message
llvm::Optional< std::string > message
Optional, more detailed associated progress message.
Definition: Protocol.h:607
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:1369
clang::clangd::OffsetEncoding::UTF16
clang::clangd::TypeHierarchyItem::name
std::string name
The human readable name of the hierarchy item.
Definition: Protocol.h:1287
clang::clangd::Symbol
The class presents a C++ symbol, e.g.
Definition: Symbol.h:36
clang::clangd::SemanticToken::tokenType
unsigned tokenType
will be looked up in SemanticTokensLegend.tokenTypes
Definition: Protocol.h:1373
clang::clangd::FileChangeType::Deleted
The file got deleted.
clang::clangd::TextDocumentIdentifier
Definition: Protocol.h:121
clang::clangd::DocumentSymbol::detail
std::string detail
More detail for this symbol, e.g the signature of a function.
Definition: Protocol.h:950
clang::clangd::DocumentRangeFormattingParams
Definition: Protocol.h:739
clang::clangd::WorkDoneProgressCreateParams::token
llvm::json::Value token
The token to be used to report progress.
Definition: Protocol.h:546
clang::clangd::TweakArgs::file
URIForFile file
A file provided by the client on a textDocument/codeAction request.
Definition: Protocol.h:876
clang::clangd::FileStatus::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:1353
clang::clangd::ExecuteCommandParams::command
std::string command
The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND.
Definition: Protocol.h:900
clang::clangd::FoldingRangeParams::textDocument
TextDocumentIdentifier textDocument
Definition: Protocol.h:1516
clang::clangd::indexSymbolKindToSymbolKind
SymbolKind indexSymbolKindToSymbolKind(index::SymbolKind Kind)
Definition: Protocol.cpp:230
clang::clangd::DocumentSymbol::selectionRange
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition: Protocol.h:966
clang::clangd::TheiaSemanticHighlightingInformation::Line
int Line
The line these highlightings belong to.
Definition: Protocol.h:1435
clang::clangd::TextDocumentItem::languageId
std::string languageId
The text document's language identifier.
Definition: Protocol.h:240
clang::clangd::CompletionItem::sortText
std::string sortText
A string that should be used when comparing this item with other items.
Definition: Protocol.h:1116
clang::clangd::toString
static const char * toString(OffsetEncoding OE)
Definition: Protocol.cpp:1170
clang::clangd::Position::character
int character
Character offset on a line in a document (zero-based).
Definition: Protocol.h:151
clang::clangd::CompletionContext::triggerKind
CompletionTriggerKind triggerKind
How the completion was triggered.
Definition: Protocol.h:1052
clang::clangd::CompletionItemKind::Struct
clang::clangd::fromJSON
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request)
Definition: Index.cpp:34
clang::clangd::TextDocumentPositionParams::position
Position position
The position inside the text document.
Definition: Protocol.h:1035
clang::clangd::Range::end
Position end
The range's end position.
Definition: Protocol.h:178
clang::clangd::DocumentSymbol
Represents programming constructs like variables, classes, interfaces etc.
Definition: Protocol.h:945
clang::clangd::SemanticTokensOrDelta::tokens
llvm::Optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
Definition: Protocol.h:1427
clang::clangd::URIForFile
Definition: Protocol.h:74
clang::clangd::SemanticToken::length
unsigned length
the length of the token. A token cannot be multiline
Definition: Protocol.h:1371
clang::clangd::URIForFile::uri
std::string uri() const
Definition: Protocol.h:97
clang::clangd::DidChangeConfigurationParams
Definition: Protocol.h:726
clang::clangd::DidChangeWatchedFilesParams::changes
std::vector< FileEvent > changes
The actual file events.
Definition: Protocol.h:722
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:1321
clang::clangd::SelectionRange
Definition: Protocol.h:1467
clang::clangd::operator<<
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
Definition: CodeComplete.cpp:1912
clang::clangd::CodeAction::command
llvm::Optional< Command > command
A command this code action executes.
Definition: Protocol.h:937
clang::clangd::DocumentFormattingParams::textDocument
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:762
clang::clangd::CompletionItemKind
CompletionItemKind
The kind of a completion entry.
Definition: Protocol.h:281
clang::clangd::TypeHierarchyItem::uri
URIForFile uri
The URI of the text document where this type hierarchy item belongs to.
Definition: Protocol.h:1300
clang::clangd::DocumentHighlightKind::Write
clang::clangd::SymbolDetails
Represents information about identifier.
Definition: Protocol.h:994
clang::clangd::ConfigurationSettings
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Definition: Protocol.h:487
clang::clangd::DocumentLinkParams
Parameters for the document link request.
Definition: Protocol.h:1481
clang::clangd::ClientCapabilities::DiagnosticRelatedInformation
bool DiagnosticRelatedInformation
Whether the client accepts diagnostics with related locations.
Definition: Protocol.h:401
clang::clangd::SymbolDetails::USR
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol.
Definition: Protocol.h:1004
clang::clangd::ExecuteCommandParams
Exact commands are not specified in the protocol so we define the ones supported by Clangd here.
Definition: Protocol.h:893
SymbolKind
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
Definition: SymbolInfo.cpp:21
clang::clangd::SignatureHelp::activeSignature
int activeSignature
The active signature.
Definition: Protocol.h:1216
clang::clangd::TextDocumentItem::text
std::string text
The content of the opened text document.
Definition: Protocol.h:249
clang::clangd::InitializeParams::initializationOptions
InitializationOptions initializationOptions
User-provided initialization options.
Definition: Protocol.h:540
clang::clangd::encodeTokens
static llvm::json::Value encodeTokens(llvm::ArrayRef< SemanticToken > Toks)
Definition: Protocol.cpp:1000
clang::clangd::TypeHierarchyParams::resolve
int resolve
The hierarchy levels to resolve. 0 indicates no level.
Definition: Protocol.h:1278
clang::clangd::CompletionItemKind::File
clang::clangd::CodeActionContext::diagnostics
std::vector< Diagnostic > diagnostics
An array of diagnostics.
Definition: Protocol.h:844
clang::clangd::SelectionRangeParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1460
clang::clangd::WorkDoneProgressReport
Reporting progress is done using the following payload.
Definition: Protocol.h:588
clang::clangd::PublishDiagnosticsParams
Definition: Protocol.h:832
clang::clangd::ClientCapabilities::WorkDoneProgress
bool WorkDoneProgress
The client supports progress notifications.
Definition: Protocol.h:465
clang::clangd::HighlightingKind::Parameter
clang::clangd::MarkupKind
MarkupKind
Definition: Protocol.h:380
clang::clangd::CodeAction::diagnostics
llvm::Optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Definition: Protocol.h:930
clang::clangd::MessageType
MessageType
Definition: Protocol.h:627
clang::clangd::TypeHierarchyDirection
TypeHierarchyDirection
Definition: Protocol.h:1270
clang::clangd::TypeHierarchyParams
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
Definition: Protocol.h:1276
clang::clangd::SymbolKind::Variable
clang::clangd::TypeHierarchyItem
Definition: Protocol.h:1285
clang::clangd::DidChangeTextDocumentParams
Definition: Protocol.h:679
clang::clangd::ConfigurationSettings::compilationDatabaseChanges
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
Definition: Protocol.h:490
clang::clangd::TypeHierarchyItem::detail
llvm::Optional< std::string > detail
Optional detail for the hierarchy item.
Definition: Protocol.h:1291
clang::clangd::TypeHierarchyItem::deprecated
bool deprecated
true if the hierarchy item is deprecated. Otherwise, false.
Definition: Protocol.h:1297
clang::clangd::SignatureInformation
Represents the signature of something callable.
Definition: Protocol.h:1194
clang::clangd::ClientCapabilities::CodeActionStructure
bool CodeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
Definition: Protocol.h:439
Info
FunctionInfo Info
Definition: FunctionSizeCheck.cpp:120
clang::clangd::DocumentSymbol::kind
SymbolKind kind
The kind of this symbol.
Definition: Protocol.h:953
clang::clangd::WorkDoneProgressReport::percentage
llvm::Optional< double > percentage
Optional progress percentage to display (value 100 is considered 100%).
Definition: Protocol.h:615
clang::clangd::CompletionItemKind::EnumMember
clang::clangd::WorkDoneProgressBegin::percentage
bool percentage
Optional progress percentage to display (value 100 is considered 100%).
Definition: Protocol.h:583
clang::clangd::DidChangeTextDocumentParams::contentChanges
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
Definition: Protocol.h:686
clang::clangd::DidChangeTextDocumentParams::textDocument
VersionedTextDocumentIdentifier textDocument
The document that did change.
Definition: Protocol.h:683
clang::clangd::TypeHierarchyParams::direction
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition: Protocol.h:1281
clang::clangd::TextDocumentPositionParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1032
clang::clangd::DidSaveTextDocumentParams::textDocument
TextDocumentIdentifier textDocument
The document that was saved.
Definition: Protocol.h:663
clang::clangd::WorkspaceSymbolParams
The parameters of a Workspace Symbol Request.
Definition: Protocol.h:1013
clang::clangd::CompletionParams
Definition: Protocol.h:1059
clang::clangd::ClangdCompileCommand::compilationCommand
std::vector< std::string > compilationCommand
Definition: Protocol.h:480
clang::clangd::TheiaSemanticHighlightingParams::TextDocument
VersionedTextDocumentIdentifier TextDocument
The textdocument these highlightings belong to.
Definition: Protocol.h:1452
clang::clangd::Range
Definition: Protocol.h:173
clang::clangd::TheiaSemanticHighlightingInformation::IsInactive
bool IsInactive
Is the line in an inactive preprocessor branch? This is a clangd extension.
Definition: Protocol.h:1442
clang::clangd::FileEvent::type
FileChangeType type
The change type.
Definition: Protocol.h:716
clang::clangd::SignatureHelp
Represents the signature of a callable.
Definition: Protocol.h:1210
clang::clangd::FileChangeType
FileChangeType
Definition: Protocol.h:702
clang::clangd::SemanticTokens
A versioned set of tokens.
Definition: Protocol.h:1380
clang::clangd::VersionedTextDocumentIdentifier::version
llvm::Optional< std::int64_t > version
The version number of this document.
Definition: Protocol.h:139
clang::clangd::ShowMessageParams::message
std::string message
The actual message.
Definition: Protocol.h:645
clang::clangd::Diagnostic::message
std::string message
The diagnostic's message.
Definition: Protocol.h:800
clang::clangd::URIForFile::URIForFile
URIForFile()=default
clang::clangd::URIForFile::canonicalize
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
Canonicalizes AbsPath via URI.
Definition: Protocol.cpp:33
clang::clangd::ApplyWorkspaceEditResponse
Definition: Protocol.h:1024
clang::clangd::Diagnostic::severity
int severity
The diagnostic's severity.
Definition: Protocol.h:790
clang::clangd::ParameterInformation::labelString
std::string labelString
The label of this parameter. Ignored when labelOffsets is set.
Definition: Protocol.h:1180
clang::clangd::InitializeParams::trace
llvm::Optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
Definition: Protocol.h:537
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:838
clang::clangd::Diagnostic::codeActions
llvm::Optional< std::vector< CodeAction > > codeActions
Clangd extension: code actions related to this diagnostic.
Definition: Protocol.h:815
OS
llvm::raw_string_ostream OS
Definition: TraceTests.cpp:162
clang::clangd::FoldingRange
Stores information about a region of code that can be folded.
Definition: Protocol.h:1521
clang::clangd::CodeAction::REFACTOR_KIND
const static llvm::StringLiteral REFACTOR_KIND
Definition: Protocol.h:926
clang::clangd::DidSaveTextDocumentParams
Definition: Protocol.h:661
clang::clangd::TypeHierarchyItem::parents
llvm::Optional< std::vector< TypeHierarchyItem > > parents
If this type hierarchy item is resolved, it contains the direct parents.
Definition: Protocol.h:1316
clang::clangd::OffsetEncoding
OffsetEncoding
Definition: Protocol.h:364
clang::clangd::TextDocumentContentChangeEvent::range
llvm::Optional< Range > range
The range of the document that changed.
Definition: Protocol.h:669
clang::clangd::FileStatus
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
Definition: Protocol.h:1351
clang::clangd::TextDocumentContentChangeEvent
Definition: Protocol.h:667
clang::clangd::WorkspaceSymbolParams::query
std::string query
A non-empty query string.
Definition: Protocol.h:1015
clang::clangd::DocumentSymbol::deprecated
bool deprecated
Indicates if this symbol is deprecated.
Definition: Protocol.h:956
clang::clangd::ClientCapabilities::TheiaSemanticHighlighting
bool TheiaSemanticHighlighting
Client supports Theia semantic highlighting extension.
Definition: Protocol.h:450
clang::clangd::CodeActionParams
Definition: Protocol.h:848
clang::clangd::operator<
bool operator<(const Ref &L, const Ref &R)
Definition: Ref.h:93
clang::clangd::TextDocumentPositionParams
Definition: Protocol.h:1030
clang::clangd::InitializeParams::rootPath
llvm::Optional< std::string > rootPath
The rootPath of the workspace.
Definition: Protocol.h:523
clang::clangd::InitializationOptions
Clangd extension: parameters configurable at initialize time.
Definition: Protocol.h:496
clang::clangd::DidCloseTextDocumentParams::textDocument
TextDocumentIdentifier textDocument
The document that was closed.
Definition: Protocol.h:657
clang::clangd::Diagnostic::code
std::string code
The diagnostic's code. Can be omitted.
Definition: Protocol.h:793
clang::clangd::RenameParams::textDocument
TextDocumentIdentifier textDocument
The document that was opened.
Definition: Protocol.h:1232
clang::clangd::DocumentOnTypeFormattingParams
Definition: Protocol.h:748
clang::clangd::TextEdit
Definition: Protocol.h:219
clang::clangd::SignatureHelp::activeParameter
int activeParameter
The active parameter of the active signature.
Definition: Protocol.h:1219
clang::clangd::OffsetEncoding::UnsupportedEncoding
clang::clangd::SymbolInformation::containerName
std::string containerName
The name of the symbol containing this symbol.
Definition: Protocol.h:987
clang::clangd::RenameParams
Definition: Protocol.h:1230
clang::clangd::ApplyWorkspaceEditParams
Definition: Protocol.h:1019
clang::clangd::ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND
const static llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND
Definition: Protocol.h:895
clang::clangd::TraceLevel::Off
clang::clangd::SymbolKind::Namespace
clang::clangd::operator==
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
Definition: Headers.cpp:273
clang::clangd::ClientCapabilities::ImplicitProgressCreation
bool ImplicitProgressCreation
The client supports implicit $/progress work-done progress streams, without a preceding window/workDo...
Definition: Protocol.h:471
clang::clangd::DidOpenTextDocumentParams
Definition: Protocol.h:649
clang::clangd::TraceLevel::Verbose
clang::clangd::DocumentSymbol::name
std::string name
The name of this symbol.
Definition: Protocol.h:947
clang::clangd::TweakArgs::selection
Range selection
A selection provided by the client on a textDocument/codeAction request.
Definition: Protocol.h:878
clang::clangd::CompletionItemKind::Missing
clang::clangd::CompletionItemKind::Module
clang::clangd::DocumentHighlightKind::Read
clang::clangd::CompletionParams::context
CompletionContext context
Definition: Protocol.h:1060
clang::clangd::ClientCapabilities::SemanticTokens
bool SemanticTokens
Client advertises support for the semanticTokens feature.
Definition: Protocol.h:444
clang::clangd::ExecuteCommandParams::workspaceEdit
llvm::Optional< WorkspaceEdit > workspaceEdit
Definition: Protocol.h:903
clang::clangd::ReferenceParams
Definition: Protocol.h:1344
clang::clangd::SymbolDetails::ID
llvm::Optional< SymbolID > ID
Definition: Protocol.h:1006
URI.h
clang::clangd::SymbolKind::File
clang::clangd::ParameterInformation
A single parameter of a particular signature.
Definition: Protocol.h:1177
clang::clangd::Diagnostic::relatedInformation
llvm::Optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
An array of related diagnostic information, e.g.
Definition: Protocol.h:804
clang::clangd::DocumentLinkParams::textDocument
TextDocumentIdentifier textDocument
The document to provide document links for.
Definition: Protocol.h:1483
clang::clangd::LSPError::ID
static char ID
Definition: Protocol.h:60
clang::clangd::TextEdit::newText
std::string newText
The string to be inserted.
Definition: Protocol.h:226
clang::clangd::SymbolInformation::location
Location location
The location of this symbol.
Definition: Protocol.h:984
Out
CompiledFragmentImpl & Out
Definition: ConfigCompile.cpp:70
clang::clangd::SemanticTokensDeltaParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1403
clang::clangd::elog
void elog(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:56
clang::clangd::MarkupContent
Definition: Protocol.h:1064
clang::clangd::InitializeParams::rootUri
llvm::Optional< URIForFile > rootUri
The rootUri of the workspace.
Definition: Protocol.h:528
clang::clangd::DiagnosticRelatedInformation
Represents a related message and source code location for a diagnostic.
Definition: Protocol.h:775
clang::clangd::ResolveTypeHierarchyItemParams::direction
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition: Protocol.h:1340
clang::clangd::CompletionContext
Definition: Protocol.h:1050
clang::clangd::TextDocumentContentChangeEvent::text
std::string text
The new text of the range/document.
Definition: Protocol.h:675
clang::clangd::CompletionItemKind::TypeParameter
clang::clangd::CompletionItemKindMin
constexpr auto CompletionItemKindMin
Definition: Protocol.h:310
clang::clangd::ResolveTypeHierarchyItemParams::item
TypeHierarchyItem item
The item to resolve.
Definition: Protocol.h:1334
clang::clangd::ApplyWorkspaceEditParams::edit
WorkspaceEdit edit
Definition: Protocol.h:1020
clang::clangd::TextEdit::range
Range range
The range of the text document to be manipulated.
Definition: Protocol.h:222
clang::clangd::Context
A context is an immutable container for per-request data that must be propagated through layers that ...
Definition: Context.h:69
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:641
clang::clangd::CodeAction::INFO_KIND
const static llvm::StringLiteral INFO_KIND
Definition: Protocol.h:927
clang::clangd::SymbolKind::Constructor
clang::clangd::CodeActionContext
Definition: Protocol.h:842
clang::clangd::URI
A URI describes the location of a source file.
Definition: URI.h:28
clang::clangd::SymbolInformation::kind
SymbolKind kind
The kind of this symbol.
Definition: Protocol.h:981
clang::clangd::ClientCapabilities::HasSignatureHelp
bool HasSignatureHelp
Client supports signature help.
Definition: Protocol.h:423
clang::clangd::VersionedTextDocumentIdentifier
Definition: Protocol.h:128
clang::clangd::WorkDoneProgressBegin::title
std::string title
Mandatory title of the progress operation.
Definition: Protocol.h:567
clang::clangd::CodeActionParams::range
Range range
The range for which the command was invoked.
Definition: Protocol.h:853
clang::clangd::SymbolKind::String
clang::clangd::DiagnosticRelatedInformation::message
std::string message
The message of this related diagnostic information.
Definition: Protocol.h:779
clang::clangd::TypeHierarchyItem::data
llvm::Optional< std::string > data
An optional 'data' filed, which can be used to identify a type hierarchy item in a resolve request.
Definition: Protocol.h:1325
clang::clangd::RenameParams::newName
std::string newName
The new name of the symbol.
Definition: Protocol.h:1238
clang::clangd::adjustKindToCapability
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
Definition: Protocol.cpp:212
clang::clangd::TextDocumentContentChangeEvent::rangeLength
llvm::Optional< int > rangeLength
The length of the range that got replaced.
Definition: Protocol.h:672
clang::clangd::CodeAction::QUICKFIX_KIND
const static llvm::StringLiteral QUICKFIX_KIND
Definition: Protocol.h:925
clang::clangd::ResolveTypeHierarchyItemParams
Parameters for the typeHierarchy/resolve request.
Definition: Protocol.h:1332
clang::clangd::WorkDoneProgressCreateParams
Definition: Protocol.h:544