clang-tools  14.0.0git
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 namespace {
31 
32 // Helper that doesn't treat `null` and absent fields as failures.
33 template <typename T>
34 bool mapOptOrNull(const llvm::json::Value &Params, llvm::StringLiteral Prop,
35  T &Out, llvm::json::Path P) {
36  auto *O = Params.getAsObject();
37  assert(O);
38  auto *V = O->get(Prop);
39  // Field is missing or null.
40  if (!V || V->getAsNull().hasValue())
41  return true;
42  return fromJSON(*V, Out, P.field(Prop));
43 }
44 } // namespace
45 
46 char LSPError::ID;
47 
48 URIForFile URIForFile::canonicalize(llvm::StringRef AbsPath,
49  llvm::StringRef TUPath) {
50  assert(llvm::sys::path::is_absolute(AbsPath) && "the path is relative");
51  auto Resolved = URI::resolvePath(AbsPath, TUPath);
52  if (!Resolved) {
53  elog("URIForFile: failed to resolve path {0} with TU path {1}: "
54  "{2}.\nUsing unresolved path.",
55  AbsPath, TUPath, Resolved.takeError());
56  return URIForFile(std::string(AbsPath));
57  }
58  return URIForFile(std::move(*Resolved));
59 }
60 
61 llvm::Expected<URIForFile> URIForFile::fromURI(const URI &U,
62  llvm::StringRef HintPath) {
63  auto Resolved = URI::resolve(U, HintPath);
64  if (!Resolved)
65  return Resolved.takeError();
66  return URIForFile(std::move(*Resolved));
67 }
68 
70  if (auto S = E.getAsString()) {
71  auto Parsed = URI::parse(*S);
72  if (!Parsed) {
73  consumeError(Parsed.takeError());
74  P.report("failed to parse URI");
75  return false;
76  }
77  if (Parsed->scheme() != "file" && Parsed->scheme() != "test") {
78  P.report("clangd only supports 'file' URI scheme for workspace files");
79  return false;
80  }
81  // "file" and "test" schemes do not require hint path.
82  auto U = URIForFile::fromURI(*Parsed, /*HintPath=*/"");
83  if (!U) {
84  P.report("unresolvable URI");
85  consumeError(U.takeError());
86  return false;
87  }
88  R = std::move(*U);
89  return true;
90  }
91  return false;
92 }
93 
94 llvm::json::Value toJSON(const URIForFile &U) { return U.uri(); }
95 
96 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URIForFile &U) {
97  return OS << U.uri();
98 }
99 
101  return llvm::json::Object{{"uri", R.uri}};
102 }
103 
105  llvm::json::Path P) {
106  llvm::json::ObjectMapper O(Params, P);
107  return O && O.map("uri", R.uri);
108 }
109 
111  auto Result = toJSON(static_cast<const TextDocumentIdentifier &>(R));
112  Result.getAsObject()->try_emplace("version", R.version);
113  return Result;
114 }
115 
116 bool fromJSON(const llvm::json::Value &Params,
118  llvm::json::ObjectMapper O(Params, P);
119  return fromJSON(Params, static_cast<TextDocumentIdentifier &>(R), P) && O &&
120  O.map("version", R.version);
121 }
122 
123 bool fromJSON(const llvm::json::Value &Params, Position &R,
124  llvm::json::Path P) {
125  llvm::json::ObjectMapper O(Params, P);
126  return O && O.map("line", R.line) && O.map("character", R.character);
127 }
128 
130  return llvm::json::Object{
131  {"line", P.line},
132  {"character", P.character},
133  };
134 }
135 
136 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Position &P) {
137  return OS << P.line << ':' << P.character;
138 }
139 
140 bool fromJSON(const llvm::json::Value &Params, Range &R, llvm::json::Path P) {
141  llvm::json::ObjectMapper O(Params, P);
142  return O && O.map("start", R.start) && O.map("end", R.end);
143 }
144 
146  return llvm::json::Object{
147  {"start", P.start},
148  {"end", P.end},
149  };
150 }
151 
152 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Range &R) {
153  return OS << R.start << '-' << R.end;
154 }
155 
157  return llvm::json::Object{
158  {"uri", P.uri},
159  {"range", P.range},
160  };
161 }
162 
163 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Location &L) {
164  return OS << L.range << '@' << L.uri;
165 }
166 
168  llvm::json::Path P) {
169  llvm::json::ObjectMapper O(Params, P);
170  return O && O.map("uri", R.uri) && O.map("languageId", R.languageId) &&
171  O.map("version", R.version) && O.map("text", R.text);
172 }
173 
174 bool fromJSON(const llvm::json::Value &Params, TextEdit &R,
175  llvm::json::Path P) {
176  llvm::json::ObjectMapper O(Params, P);
177  return O && O.map("range", R.range) && O.map("newText", R.newText);
178 }
179 
181  return llvm::json::Object{
182  {"range", P.range},
183  {"newText", P.newText},
184  };
185 }
186 
187 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TextEdit &TE) {
188  OS << TE.range << " => \"";
189  llvm::printEscapedString(TE.newText, OS);
190  return OS << '"';
191 }
192 
194  if (auto S = E.getAsString()) {
195  if (*S == "off") {
197  return true;
198  }
199  if (*S == "messages") {
201  return true;
202  }
203  if (*S == "verbose") {
205  return true;
206  }
207  }
208  return false;
209 }
210 
212  if (auto T = E.getAsInteger()) {
213  if (*T < static_cast<int>(SymbolKind::File) ||
214  *T > static_cast<int>(SymbolKind::TypeParameter))
215  return false;
216  Out = static_cast<SymbolKind>(*T);
217  return true;
218  }
219  return false;
220 }
221 
223  llvm::json::Path P) {
224  if (auto *A = E.getAsArray()) {
225  for (size_t I = 0; I < A->size(); ++I) {
226  SymbolKind KindOut;
227  if (fromJSON((*A)[I], KindOut, P.index(I)))
228  Out.set(size_t(KindOut));
229  }
230  return true;
231  }
232  return false;
233 }
234 
236  SymbolKindBitset &SupportedSymbolKinds) {
237  auto KindVal = static_cast<size_t>(Kind);
238  if (KindVal >= SymbolKindMin && KindVal <= SupportedSymbolKinds.size() &&
239  SupportedSymbolKinds[KindVal])
240  return Kind;
241 
242  switch (Kind) {
243  // Provide some fall backs for common kinds that are close enough.
244  case SymbolKind::Struct:
245  return SymbolKind::Class;
247  return SymbolKind::Enum;
248  default:
249  return SymbolKind::String;
250  }
251 }
252 
254  switch (Kind) {
256  return SymbolKind::Variable;
257  case index::SymbolKind::Module:
258  return SymbolKind::Module;
259  case index::SymbolKind::Namespace:
260  return SymbolKind::Namespace;
261  case index::SymbolKind::NamespaceAlias:
262  return SymbolKind::Namespace;
263  case index::SymbolKind::Macro:
264  return SymbolKind::String;
265  case index::SymbolKind::Enum:
266  return SymbolKind::Enum;
267  case index::SymbolKind::Struct:
268  return SymbolKind::Struct;
269  case index::SymbolKind::Class:
270  return SymbolKind::Class;
271  case index::SymbolKind::Protocol:
272  return SymbolKind::Interface;
273  case index::SymbolKind::Extension:
274  return SymbolKind::Interface;
275  case index::SymbolKind::Union:
276  return SymbolKind::Class;
277  case index::SymbolKind::TypeAlias:
278  return SymbolKind::Class;
279  case index::SymbolKind::Function:
280  return SymbolKind::Function;
281  case index::SymbolKind::Variable:
282  return SymbolKind::Variable;
283  case index::SymbolKind::Field:
284  return SymbolKind::Field;
285  case index::SymbolKind::EnumConstant:
286  return SymbolKind::EnumMember;
287  case index::SymbolKind::InstanceMethod:
288  case index::SymbolKind::ClassMethod:
289  case index::SymbolKind::StaticMethod:
290  return SymbolKind::Method;
291  case index::SymbolKind::InstanceProperty:
292  case index::SymbolKind::ClassProperty:
293  case index::SymbolKind::StaticProperty:
294  return SymbolKind::Property;
295  case index::SymbolKind::Constructor:
296  case index::SymbolKind::Destructor:
298  case index::SymbolKind::ConversionFunction:
299  return SymbolKind::Function;
300  case index::SymbolKind::Parameter:
301  case index::SymbolKind::NonTypeTemplateParm:
302  return SymbolKind::Variable;
303  case index::SymbolKind::Using:
304  return SymbolKind::Namespace;
305  case index::SymbolKind::TemplateTemplateParm:
306  case index::SymbolKind::TemplateTypeParm:
308  }
309  llvm_unreachable("invalid symbol kind");
310 }
311 
313  llvm::json::Path P) {
314  const llvm::json::Object *O = Params.getAsObject();
315  if (!O) {
316  P.report("expected object");
317  return false;
318  }
319  if (auto *TextDocument = O->getObject("textDocument")) {
320  if (auto *SemanticHighlighting =
321  TextDocument->getObject("semanticHighlightingCapabilities")) {
322  if (auto SemanticHighlightingSupport =
323  SemanticHighlighting->getBoolean("semanticHighlighting"))
324  R.TheiaSemanticHighlighting = *SemanticHighlightingSupport;
325  }
326  if (TextDocument->getObject("semanticTokens"))
327  R.SemanticTokens = true;
328  if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
329  if (auto CategorySupport = Diagnostics->getBoolean("categorySupport"))
330  R.DiagnosticCategory = *CategorySupport;
331  if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline"))
332  R.DiagnosticFixes = *CodeActions;
333  if (auto RelatedInfo = Diagnostics->getBoolean("relatedInformation"))
334  R.DiagnosticRelatedInformation = *RelatedInfo;
335  }
336  if (auto *Completion = TextDocument->getObject("completion")) {
337  if (auto *Item = Completion->getObject("completionItem")) {
338  if (auto SnippetSupport = Item->getBoolean("snippetSupport"))
339  R.CompletionSnippets = *SnippetSupport;
340  if (const auto *DocumentationFormat =
341  Item->getArray("documentationFormat")) {
342  for (const auto &Format : *DocumentationFormat) {
343  if (fromJSON(Format, R.CompletionDocumentationFormat, P))
344  break;
345  }
346  }
347  }
348  if (auto *ItemKind = Completion->getObject("completionItemKind")) {
349  if (auto *ValueSet = ItemKind->get("valueSet")) {
350  R.CompletionItemKinds.emplace();
351  if (!fromJSON(*ValueSet, *R.CompletionItemKinds,
352  P.field("textDocument")
353  .field("completion")
354  .field("completionItemKind")
355  .field("valueSet")))
356  return false;
357  }
358  }
359  if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
360  R.CompletionFixes = *EditsNearCursor;
361  }
362  if (auto *CodeAction = TextDocument->getObject("codeAction")) {
363  if (CodeAction->getObject("codeActionLiteralSupport"))
364  R.CodeActionStructure = true;
365  }
366  if (auto *DocumentSymbol = TextDocument->getObject("documentSymbol")) {
367  if (auto HierarchicalSupport =
368  DocumentSymbol->getBoolean("hierarchicalDocumentSymbolSupport"))
369  R.HierarchicalDocumentSymbol = *HierarchicalSupport;
370  }
371  if (auto *Hover = TextDocument->getObject("hover")) {
372  if (auto *ContentFormat = Hover->getArray("contentFormat")) {
373  for (const auto &Format : *ContentFormat) {
374  if (fromJSON(Format, R.HoverContentFormat, P))
375  break;
376  }
377  }
378  }
379  if (auto *Help = TextDocument->getObject("signatureHelp")) {
380  R.HasSignatureHelp = true;
381  if (auto *Info = Help->getObject("signatureInformation")) {
382  if (auto *Parameter = Info->getObject("parameterInformation")) {
383  if (auto OffsetSupport = Parameter->getBoolean("labelOffsetSupport"))
384  R.OffsetsInSignatureHelp = *OffsetSupport;
385  }
386  }
387  }
388  if (auto *Rename = TextDocument->getObject("rename")) {
389  if (auto RenameSupport = Rename->getBoolean("prepareSupport"))
390  R.RenamePrepareSupport = *RenameSupport;
391  }
392  }
393  if (auto *Workspace = O->getObject("workspace")) {
394  if (auto *Symbol = Workspace->getObject("symbol")) {
395  if (auto *SymbolKind = Symbol->getObject("symbolKind")) {
396  if (auto *ValueSet = SymbolKind->get("valueSet")) {
397  R.WorkspaceSymbolKinds.emplace();
398  if (!fromJSON(*ValueSet, *R.WorkspaceSymbolKinds,
399  P.field("workspace")
400  .field("symbol")
401  .field("symbolKind")
402  .field("valueSet")))
403  return false;
404  }
405  }
406  }
407  if (auto *SemanticTokens = Workspace->getObject("semanticTokens")) {
408  if (auto RefreshSupport = SemanticTokens->getBoolean("refreshSupport"))
409  R.SemanticTokenRefreshSupport = *RefreshSupport;
410  }
411  }
412  if (auto *Window = O->getObject("window")) {
413  if (auto WorkDoneProgress = Window->getBoolean("workDoneProgress"))
414  R.WorkDoneProgress = *WorkDoneProgress;
415  if (auto Implicit = Window->getBoolean("implicitWorkDoneProgressCreate"))
416  R.ImplicitProgressCreation = *Implicit;
417  }
418  if (auto *General = O->getObject("general")) {
419  if (auto *StaleRequestSupport = General->getObject("staleRequestSupport")) {
420  if (auto Cancel = StaleRequestSupport->getBoolean("cancel"))
421  R.CancelsStaleRequests = *Cancel;
422  }
423  }
424  if (auto *OffsetEncoding = O->get("offsetEncoding")) {
425  R.offsetEncoding.emplace();
427  P.field("offsetEncoding")))
428  return false;
429  }
430  return true;
431 }
432 
434  llvm::json::Path P) {
435  llvm::json::ObjectMapper O(Params, P);
436  if (!O)
437  return false;
438  // We deliberately don't fail if we can't parse individual fields.
439  // Failing to handle a slightly malformed initialize would be a disaster.
440  O.map("processId", R.processId);
441  O.map("rootUri", R.rootUri);
442  O.map("rootPath", R.rootPath);
443  O.map("capabilities", R.capabilities);
444  if (auto *RawCaps = Params.getAsObject()->getObject("capabilities"))
445  R.rawCapabilities = *RawCaps;
446  O.map("trace", R.trace);
447  O.map("initializationOptions", R.initializationOptions);
448  return true;
449 }
450 
452  return llvm::json::Object{{"token", P.token}};
453 }
454 
456  llvm::json::Object Result{
457  {"kind", "begin"},
458  {"title", P.title},
459  };
460  if (P.cancellable)
461  Result["cancellable"] = true;
462  if (P.percentage)
463  Result["percentage"] = 0;
464 
465  // FIXME: workaround for older gcc/clang
466  return std::move(Result);
467 }
468 
470  llvm::json::Object Result{{"kind", "report"}};
471  if (P.cancellable)
472  Result["cancellable"] = *P.cancellable;
473  if (P.message)
474  Result["message"] = *P.message;
475  if (P.percentage)
476  Result["percentage"] = *P.percentage;
477  // FIXME: workaround for older gcc/clang
478  return std::move(Result);
479 }
480 
482  llvm::json::Object Result{{"kind", "end"}};
483  if (P.message)
484  Result["message"] = *P.message;
485  // FIXME: workaround for older gcc/clang
486  return std::move(Result);
487 }
488 
490  return static_cast<int64_t>(R);
491 }
492 
494  return llvm::json::Object{{"type", R.type}, {"message", R.message}};
495 }
496 
498  llvm::json::Path P) {
499  llvm::json::ObjectMapper O(Params, P);
500  return O && O.map("textDocument", R.textDocument);
501 }
502 
504  llvm::json::Path P) {
505  llvm::json::ObjectMapper O(Params, P);
506  return O && O.map("textDocument", R.textDocument);
507 }
508 
510  llvm::json::Path P) {
511  llvm::json::ObjectMapper O(Params, P);
512  return O && O.map("textDocument", R.textDocument);
513 }
514 
516  llvm::json::Path P) {
517  llvm::json::ObjectMapper O(Params, P);
518  return O && O.map("textDocument", R.textDocument) &&
519  O.map("contentChanges", R.contentChanges) &&
520  O.map("wantDiagnostics", R.wantDiagnostics) &&
521  mapOptOrNull(Params, "forceRebuild", R.forceRebuild, P);
522 }
523 
525  llvm::json::Path P) {
526  if (auto T = E.getAsInteger()) {
527  if (*T < static_cast<int>(FileChangeType::Created) ||
528  *T > static_cast<int>(FileChangeType::Deleted))
529  return false;
530  Out = static_cast<FileChangeType>(*T);
531  return true;
532  }
533  return false;
534 }
535 
536 bool fromJSON(const llvm::json::Value &Params, FileEvent &R,
537  llvm::json::Path P) {
538  llvm::json::ObjectMapper O(Params, P);
539  return O && O.map("uri", R.uri) && O.map("type", R.type);
540 }
541 
543  llvm::json::Path P) {
544  llvm::json::ObjectMapper O(Params, P);
545  return O && O.map("changes", R.changes);
546 }
547 
548 bool fromJSON(const llvm::json::Value &Params,
550  llvm::json::ObjectMapper O(Params, P);
551  return O && O.map("range", R.range) && O.map("rangeLength", R.rangeLength) &&
552  O.map("text", R.text);
553 }
554 
556  llvm::json::Path P) {
557  llvm::json::ObjectMapper O(Params, P);
558  return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
559 }
560 
561 bool fromJSON(const llvm::json::Value &Params,
563  llvm::json::ObjectMapper O(Params, P);
564  return O && O.map("textDocument", R.textDocument) &&
565  O.map("position", R.position) && O.map("ch", R.ch);
566 }
567 
569  llvm::json::Path P) {
570  llvm::json::ObjectMapper O(Params, P);
571  return O && O.map("textDocument", R.textDocument);
572 }
573 
575  llvm::json::Path P) {
576  llvm::json::ObjectMapper O(Params, P);
577  return O && O.map("textDocument", R.textDocument);
578 }
579 
581  return llvm::json::Object{
582  {"location", DRI.location},
583  {"message", DRI.message},
584  };
585 }
586 
587 llvm::json::Value toJSON(DiagnosticTag Tag) { return static_cast<int>(Tag); }
588 
590  llvm::json::Object Diag{
591  {"range", D.range},
592  {"severity", D.severity},
593  {"message", D.message},
594  };
595  if (D.category)
596  Diag["category"] = *D.category;
597  if (D.codeActions)
598  Diag["codeActions"] = D.codeActions;
599  if (!D.code.empty())
600  Diag["code"] = D.code;
601  if (!D.source.empty())
602  Diag["source"] = D.source;
603  if (D.relatedInformation)
604  Diag["relatedInformation"] = *D.relatedInformation;
605  if (!D.data.empty())
606  Diag["data"] = llvm::json::Object(D.data);
607  if (!D.tags.empty())
608  Diag["tags"] = llvm::json::Array{D.tags};
609  // FIXME: workaround for older gcc/clang
610  return std::move(Diag);
611 }
612 
613 bool fromJSON(const llvm::json::Value &Params, Diagnostic &R,
614  llvm::json::Path P) {
615  llvm::json::ObjectMapper O(Params, P);
616  if (!O)
617  return false;
618  if (auto *Data = Params.getAsObject()->getObject("data"))
619  R.data = *Data;
620  return O.map("range", R.range) && O.map("message", R.message) &&
621  mapOptOrNull(Params, "severity", R.severity, P) &&
622  mapOptOrNull(Params, "category", R.category, P) &&
623  mapOptOrNull(Params, "code", R.code, P) &&
624  mapOptOrNull(Params, "source", R.source, P);
625 }
626 
628  llvm::json::Object Result{
629  {"uri", PDP.uri},
630  {"diagnostics", PDP.diagnostics},
631  };
632  if (PDP.version)
633  Result["version"] = PDP.version;
634  return std::move(Result);
635 }
636 
638  llvm::json::Path P) {
639  llvm::json::ObjectMapper O(Params, P);
640  if (!O || !O.map("diagnostics", R.diagnostics))
641  return false;
642  O.map("only", R.only);
643  return true;
644 }
645 
646 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diagnostic &D) {
647  OS << D.range << " [";
648  switch (D.severity) {
649  case 1:
650  OS << "error";
651  break;
652  case 2:
653  OS << "warning";
654  break;
655  case 3:
656  OS << "note";
657  break;
658  case 4:
659  OS << "remark";
660  break;
661  default:
662  OS << "diagnostic";
663  break;
664  }
665  return OS << '(' << D.severity << "): " << D.message << "]";
666 }
667 
669  llvm::json::Path P) {
670  llvm::json::ObjectMapper O(Params, P);
671  return O && O.map("textDocument", R.textDocument) &&
672  O.map("range", R.range) && O.map("context", R.context);
673 }
674 
675 bool fromJSON(const llvm::json::Value &Params, WorkspaceEdit &R,
676  llvm::json::Path P) {
677  llvm::json::ObjectMapper O(Params, P);
678  return O && O.map("changes", R.changes);
679 }
680 
682  llvm::json::Path P) {
683  llvm::json::ObjectMapper O(Params, P);
684  if (!O || !O.map("command", R.command))
685  return false;
686 
687  const auto *Args = Params.getAsObject()->get("arguments");
688  if (!Args)
689  return true; // Missing args is ok, argument is null.
690  const auto *ArgsArray = Args->getAsArray();
691  if (!ArgsArray) {
692  P.field("arguments").report("expected array");
693  return false;
694  }
695  if (ArgsArray->size() > 1) {
696  P.field("arguments").report("Command should have 0 or 1 argument");
697  return false;
698  } else if (ArgsArray->size() == 1) {
699  R.argument = ArgsArray->front();
700  }
701  return true;
702 }
703 
705  llvm::json::Object O{
706  {"name", P.name},
707  {"kind", static_cast<int>(P.kind)},
708  {"location", P.location},
709  {"containerName", P.containerName},
710  };
711  if (P.score)
712  O["score"] = *P.score;
713  return std::move(O);
714 }
715 
716 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
717  const SymbolInformation &SI) {
718  O << SI.containerName << "::" << SI.name << " - " << toJSON(SI);
719  return O;
720 }
721 
722 bool operator==(const SymbolDetails &LHS, const SymbolDetails &RHS) {
723  return LHS.name == RHS.name && LHS.containerName == RHS.containerName &&
724  LHS.USR == RHS.USR && LHS.ID == RHS.ID;
725 }
726 
728  llvm::json::Object Result{{"name", llvm::json::Value(nullptr)},
729  {"containerName", llvm::json::Value(nullptr)},
730  {"usr", llvm::json::Value(nullptr)},
731  {"id", llvm::json::Value(nullptr)}};
732 
733  if (!P.name.empty())
734  Result["name"] = P.name;
735 
736  if (!P.containerName.empty())
737  Result["containerName"] = P.containerName;
738 
739  if (!P.USR.empty())
740  Result["usr"] = P.USR;
741 
742  if (P.ID)
743  Result["id"] = P.ID.str();
744 
745  // FIXME: workaround for older gcc/clang
746  return std::move(Result);
747 }
748 
749 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const SymbolDetails &S) {
750  if (!S.containerName.empty()) {
751  O << S.containerName;
752  llvm::StringRef ContNameRef;
753  if (!ContNameRef.endswith("::")) {
754  O << " ";
755  }
756  }
757  O << S.name << " - " << toJSON(S);
758  return O;
759 }
760 
762  llvm::json::Path P) {
763  llvm::json::ObjectMapper O(Params, P);
764  return O && O.map("query", R.query) &&
765  mapOptOrNull(Params, "limit", R.limit, P);
766 }
767 
768 llvm::json::Value toJSON(const Command &C) {
769  auto Cmd = llvm::json::Object{{"title", C.title}, {"command", C.command}};
770  if (!C.argument.getAsNull())
771  Cmd["arguments"] = llvm::json::Array{C.argument};
772  return std::move(Cmd);
773 }
774 
775 const llvm::StringLiteral CodeAction::QUICKFIX_KIND = "quickfix";
776 const llvm::StringLiteral CodeAction::REFACTOR_KIND = "refactor";
777 const llvm::StringLiteral CodeAction::INFO_KIND = "info";
778 
780  auto CodeAction = llvm::json::Object{{"title", CA.title}};
781  if (CA.kind)
782  CodeAction["kind"] = *CA.kind;
783  if (CA.diagnostics)
784  CodeAction["diagnostics"] = llvm::json::Array(*CA.diagnostics);
785  if (CA.isPreferred)
786  CodeAction["isPreferred"] = true;
787  if (CA.edit)
788  CodeAction["edit"] = *CA.edit;
789  if (CA.command)
790  CodeAction["command"] = *CA.command;
791  return std::move(CodeAction);
792 }
793 
794 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S) {
795  return O << S.name << " - " << toJSON(S);
796 }
797 
799  llvm::json::Object Result{{"name", S.name},
800  {"kind", static_cast<int>(S.kind)},
801  {"range", S.range},
802  {"selectionRange", S.selectionRange}};
803 
804  if (!S.detail.empty())
805  Result["detail"] = S.detail;
806  if (!S.children.empty())
807  Result["children"] = S.children;
808  if (S.deprecated)
809  Result["deprecated"] = true;
810  // FIXME: workaround for older gcc/clang
811  return std::move(Result);
812 }
813 
815  llvm::json::Object FileChanges;
816  for (auto &Change : WE.changes)
817  FileChanges[Change.first] = llvm::json::Array(Change.second);
818  return llvm::json::Object{{"changes", std::move(FileChanges)}};
819 }
820 
821 bool fromJSON(const llvm::json::Value &Params, TweakArgs &A,
822  llvm::json::Path P) {
823  llvm::json::ObjectMapper O(Params, P);
824  return O && O.map("file", A.file) && O.map("selection", A.selection) &&
825  O.map("tweakID", A.tweakID);
826 }
827 
829  return llvm::json::Object{
830  {"tweakID", A.tweakID}, {"selection", A.selection}, {"file", A.file}};
831 }
832 
834  return llvm::json::Object{{"edit", Params.edit}};
835 }
836 
838  llvm::json::Path P) {
839  llvm::json::ObjectMapper O(Response, P);
840  return O && O.map("applied", R.applied) &&
841  O.map("failureReason", R.failureReason);
842 }
843 
845  llvm::json::Path P) {
846  llvm::json::ObjectMapper O(Params, P);
847  return O && O.map("textDocument", R.textDocument) &&
848  O.map("position", R.position);
849 }
850 
852  llvm::json::Path P) {
853  llvm::json::ObjectMapper O(Params, P);
854  int TriggerKind;
855  if (!O || !O.map("triggerKind", TriggerKind) ||
856  !mapOptOrNull(Params, "triggerCharacter", R.triggerCharacter, P))
857  return false;
858  R.triggerKind = static_cast<CompletionTriggerKind>(TriggerKind);
859  return true;
860 }
861 
863  llvm::json::Path P) {
864  if (!fromJSON(Params, static_cast<TextDocumentPositionParams &>(R), P) ||
865  !mapOptOrNull(Params, "limit", R.limit, P))
866  return false;
867  if (auto *Context = Params.getAsObject()->get("context"))
868  return fromJSON(*Context, R.context, P.field("context"));
869  return true;
870 }
871 
872 static llvm::StringRef toTextKind(MarkupKind Kind) {
873  switch (Kind) {
875  return "plaintext";
877  return "markdown";
878  }
879  llvm_unreachable("Invalid MarkupKind");
880 }
881 
883  auto Str = V.getAsString();
884  if (!Str) {
885  P.report("expected string");
886  return false;
887  }
888  if (*Str == "plaintext")
890  else if (*Str == "markdown")
892  else {
893  P.report("unknown markup kind");
894  return false;
895  }
896  return true;
897 }
898 
899 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, MarkupKind K) {
900  return OS << toTextKind(K);
901 }
902 
904  if (MC.value.empty())
905  return nullptr;
906 
907  return llvm::json::Object{
908  {"kind", toTextKind(MC.kind)},
909  {"value", MC.value},
910  };
911 }
912 
914  llvm::json::Object Result{{"contents", toJSON(H.contents)}};
915 
916  if (H.range.hasValue())
917  Result["range"] = toJSON(*H.range);
918 
919  return std::move(Result);
920 }
921 
923  llvm::json::Path P) {
924  if (auto T = E.getAsInteger()) {
925  if (*T < static_cast<int>(CompletionItemKind::Text) ||
926  *T > static_cast<int>(CompletionItemKind::TypeParameter))
927  return false;
928  Out = static_cast<CompletionItemKind>(*T);
929  return true;
930  }
931  return false;
932 }
933 
936  CompletionItemKindBitset &SupportedCompletionItemKinds) {
937  auto KindVal = static_cast<size_t>(Kind);
938  if (KindVal >= CompletionItemKindMin &&
939  KindVal <= SupportedCompletionItemKinds.size() &&
940  SupportedCompletionItemKinds[KindVal])
941  return Kind;
942 
943  switch (Kind) {
944  // Provide some fall backs for common kinds that are close enough.
951  default:
953  }
954 }
955 
957  llvm::json::Path P) {
958  if (auto *A = E.getAsArray()) {
959  for (size_t I = 0; I < A->size(); ++I) {
960  CompletionItemKind KindOut;
961  if (fromJSON((*A)[I], KindOut, P.index(I)))
962  Out.set(size_t(KindOut));
963  }
964  return true;
965  }
966  return false;
967 }
968 
970  assert(!CI.label.empty() && "completion item label is required");
971  llvm::json::Object Result{{"label", CI.label}};
972  if (CI.kind != CompletionItemKind::Missing)
973  Result["kind"] = static_cast<int>(CI.kind);
974  if (!CI.detail.empty())
975  Result["detail"] = CI.detail;
976  if (CI.documentation)
977  Result["documentation"] = CI.documentation;
978  if (!CI.sortText.empty())
979  Result["sortText"] = CI.sortText;
980  if (!CI.filterText.empty())
981  Result["filterText"] = CI.filterText;
982  if (!CI.insertText.empty())
983  Result["insertText"] = CI.insertText;
984  if (CI.insertTextFormat != InsertTextFormat::Missing)
985  Result["insertTextFormat"] = static_cast<int>(CI.insertTextFormat);
986  if (CI.textEdit)
987  Result["textEdit"] = *CI.textEdit;
988  if (!CI.additionalTextEdits.empty())
989  Result["additionalTextEdits"] = llvm::json::Array(CI.additionalTextEdits);
990  if (CI.deprecated)
991  Result["deprecated"] = CI.deprecated;
992  Result["score"] = CI.score;
993  return std::move(Result);
994 }
995 
996 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const CompletionItem &I) {
997  O << I.label << " - " << toJSON(I);
998  return O;
999 }
1000 
1001 bool operator<(const CompletionItem &L, const CompletionItem &R) {
1002  return (L.sortText.empty() ? L.label : L.sortText) <
1003  (R.sortText.empty() ? R.label : R.sortText);
1004 }
1005 
1007  return llvm::json::Object{
1008  {"isIncomplete", L.isIncomplete},
1009  {"items", llvm::json::Array(L.items)},
1010  };
1011 }
1012 
1014  assert((PI.labelOffsets.hasValue() || !PI.labelString.empty()) &&
1015  "parameter information label is required");
1016  llvm::json::Object Result;
1017  if (PI.labelOffsets)
1018  Result["label"] =
1019  llvm::json::Array({PI.labelOffsets->first, PI.labelOffsets->second});
1020  else
1021  Result["label"] = PI.labelString;
1022  if (!PI.documentation.empty())
1023  Result["documentation"] = PI.documentation;
1024  return std::move(Result);
1025 }
1026 
1028  assert(!SI.label.empty() && "signature information label is required");
1029  llvm::json::Object Result{
1030  {"label", SI.label},
1031  {"parameters", llvm::json::Array(SI.parameters)},
1032  };
1033  if (!SI.documentation.empty())
1034  Result["documentation"] = SI.documentation;
1035  return std::move(Result);
1036 }
1037 
1038 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1039  const SignatureInformation &I) {
1040  O << I.label << " - " << toJSON(I);
1041  return O;
1042 }
1043 
1045  assert(SH.activeSignature >= 0 &&
1046  "Unexpected negative value for number of active signatures.");
1047  assert(SH.activeParameter >= 0 &&
1048  "Unexpected negative value for active parameter index");
1049  return llvm::json::Object{
1050  {"activeSignature", SH.activeSignature},
1051  {"activeParameter", SH.activeParameter},
1052  {"signatures", llvm::json::Array(SH.signatures)},
1053  };
1054 }
1055 
1056 bool fromJSON(const llvm::json::Value &Params, RenameParams &R,
1057  llvm::json::Path P) {
1058  llvm::json::ObjectMapper O(Params, P);
1059  return O && O.map("textDocument", R.textDocument) &&
1060  O.map("position", R.position) && O.map("newName", R.newName);
1061 }
1062 
1064  return llvm::json::Object{
1065  {"range", toJSON(DH.range)},
1066  {"kind", static_cast<int>(DH.kind)},
1067  };
1068 }
1069 
1071  return llvm::json::Object{
1072  {"uri", FStatus.uri},
1073  {"state", FStatus.state},
1074  };
1075 }
1076 
1077 constexpr unsigned SemanticTokenEncodingSize = 5;
1078 static llvm::json::Value encodeTokens(llvm::ArrayRef<SemanticToken> Toks) {
1079  llvm::json::Array Result;
1080  Result.reserve(SemanticTokenEncodingSize * Toks.size());
1081  for (const auto &Tok : Toks) {
1082  Result.push_back(Tok.deltaLine);
1083  Result.push_back(Tok.deltaStart);
1084  Result.push_back(Tok.length);
1085  Result.push_back(Tok.tokenType);
1086  Result.push_back(Tok.tokenModifiers);
1087  }
1088  assert(Result.size() == SemanticTokenEncodingSize * Toks.size());
1089  return std::move(Result);
1090 }
1091 
1092 bool operator==(const SemanticToken &L, const SemanticToken &R) {
1093  return std::tie(L.deltaLine, L.deltaStart, L.length, L.tokenType,
1094  L.tokenModifiers) == std::tie(R.deltaLine, R.deltaStart,
1095  R.length, R.tokenType,
1096  R.tokenModifiers);
1097 }
1098 
1100  return llvm::json::Object{{"resultId", Tokens.resultId},
1101  {"data", encodeTokens(Tokens.tokens)}};
1102 }
1103 
1105  return llvm::json::Object{
1106  {"start", SemanticTokenEncodingSize * Edit.startToken},
1107  {"deleteCount", SemanticTokenEncodingSize * Edit.deleteTokens},
1108  {"data", encodeTokens(Edit.tokens)}};
1109 }
1110 
1112  llvm::json::Object Result{{"resultId", TE.resultId}};
1113  if (TE.edits)
1114  Result["edits"] = *TE.edits;
1115  if (TE.tokens)
1116  Result["data"] = encodeTokens(*TE.tokens);
1117  return std::move(Result);
1118 }
1119 
1121  llvm::json::Path P) {
1122  llvm::json::ObjectMapper O(Params, P);
1123  return O && O.map("textDocument", R.textDocument);
1124 }
1125 
1127  llvm::json::Path P) {
1128  llvm::json::ObjectMapper O(Params, P);
1129  return O && O.map("textDocument", R.textDocument) &&
1130  O.map("previousResultId", R.previousResultId);
1131 }
1132 
1133 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1134  const DocumentHighlight &V) {
1135  O << V.range;
1137  O << "(r)";
1139  O << "(w)";
1140  return O;
1141 }
1142 
1143 bool fromJSON(const llvm::json::Value &Params,
1145  llvm::json::ObjectMapper O(Params, P);
1146  return O && O.map("settings", CCP.settings);
1147 }
1148 
1149 bool fromJSON(const llvm::json::Value &Params, ClangdCompileCommand &CDbUpdate,
1150  llvm::json::Path P) {
1151  llvm::json::ObjectMapper O(Params, P);
1152  return O && O.map("workingDirectory", CDbUpdate.workingDirectory) &&
1153  O.map("compilationCommand", CDbUpdate.compilationCommand);
1154 }
1155 
1157  llvm::json::Path P) {
1158  llvm::json::ObjectMapper O(Params, P);
1159  if (!O)
1160  return true; // 'any' type in LSP.
1161  return mapOptOrNull(Params, "compilationDatabaseChanges",
1163 }
1164 
1166  llvm::json::Path P) {
1167  llvm::json::ObjectMapper O(Params, P);
1168  if (!O)
1169  return true; // 'any' type in LSP.
1170 
1171  return fromJSON(Params, Opts.ConfigSettings, P) &&
1172  O.map("compilationDatabasePath", Opts.compilationDatabasePath) &&
1173  mapOptOrNull(Params, "fallbackFlags", Opts.fallbackFlags, P) &&
1174  mapOptOrNull(Params, "clangdFileStatus", Opts.FileStatus, P);
1175 }
1176 
1178  llvm::json::Path P) {
1179  auto T = E.getAsInteger();
1180  if (!T)
1181  return false;
1182  if (*T < static_cast<int>(TypeHierarchyDirection::Children) ||
1183  *T > static_cast<int>(TypeHierarchyDirection::Both))
1184  return false;
1185  Out = static_cast<TypeHierarchyDirection>(*T);
1186  return true;
1187 }
1188 
1190  llvm::json::Path P) {
1191  llvm::json::ObjectMapper O(Params, P);
1192  return O && O.map("textDocument", R.textDocument) &&
1193  O.map("position", R.position) && O.map("resolve", R.resolve) &&
1194  O.map("direction", R.direction);
1195 }
1196 
1197 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1198  const TypeHierarchyItem &I) {
1199  return O << I.name << " - " << toJSON(I);
1200 }
1201 
1203  llvm::json::Object Result{{"name", I.name},
1204  {"kind", static_cast<int>(I.kind)},
1205  {"range", I.range},
1206  {"selectionRange", I.selectionRange},
1207  {"uri", I.uri}};
1208 
1209  if (I.detail)
1210  Result["detail"] = I.detail;
1211  if (I.deprecated)
1212  Result["deprecated"] = I.deprecated;
1213  if (I.parents)
1214  Result["parents"] = I.parents;
1215  if (I.children)
1216  Result["children"] = I.children;
1217  if (I.data)
1218  Result["data"] = I.data;
1219  return std::move(Result);
1220 }
1221 
1223  llvm::json::Path P) {
1224  llvm::json::ObjectMapper O(Params, P);
1225 
1226  // Required fields.
1227  return O && O.map("name", I.name) && O.map("kind", I.kind) &&
1228  O.map("uri", I.uri) && O.map("range", I.range) &&
1229  O.map("selectionRange", I.selectionRange) &&
1230  mapOptOrNull(Params, "detail", I.detail, P) &&
1231  mapOptOrNull(Params, "deprecated", I.deprecated, P) &&
1232  mapOptOrNull(Params, "parents", I.parents, P) &&
1233  mapOptOrNull(Params, "children", I.children, P) &&
1234  mapOptOrNull(Params, "data", I.data, P);
1235 }
1236 
1237 bool fromJSON(const llvm::json::Value &Params,
1239  llvm::json::ObjectMapper O(Params, P);
1240  return O && O.map("item", R.item) && O.map("resolve", R.resolve) &&
1241  O.map("direction", R.direction);
1242 }
1243 
1245  llvm::json::Path P) {
1246  llvm::json::ObjectMapper O(Params, P);
1247  return O && O.mapOptional("includeDeclaration", R.includeDeclaration);
1248 }
1249 
1251  llvm::json::Path P) {
1253  llvm::json::ObjectMapper O(Params, P);
1254  return fromJSON(Params, Base, P) && O && O.mapOptional("context", R.context);
1255 }
1256 
1258  return llvm::json::Value{static_cast<int>(Tag)};
1259 }
1260 
1262  llvm::json::Object Result{{"name", I.name},
1263  {"kind", static_cast<int>(I.kind)},
1264  {"range", I.range},
1265  {"selectionRange", I.selectionRange},
1266  {"uri", I.uri}};
1267  if (!I.tags.empty())
1268  Result["tags"] = I.tags;
1269  if (!I.detail.empty())
1270  Result["detail"] = I.detail;
1271  if (!I.data.empty())
1272  Result["data"] = I.data;
1273  return std::move(Result);
1274 }
1275 
1277  llvm::json::Path P) {
1278  llvm::json::ObjectMapper O(Params, P);
1279 
1280  // Populate the required fields only. We don't care about the
1281  // optional fields `Tags` and `Detail` for the purpose of
1282  // client --> server communication.
1283  return O && O.map("name", I.name) && O.map("kind", I.kind) &&
1284  O.map("uri", I.uri) && O.map("range", I.range) &&
1285  O.map("selectionRange", I.selectionRange) &&
1286  mapOptOrNull(Params, "data", I.data, P);
1287 }
1288 
1289 bool fromJSON(const llvm::json::Value &Params,
1291  llvm::json::ObjectMapper O(Params, P);
1292  return O.map("item", C.item);
1293 }
1294 
1296  return llvm::json::Object{{"from", C.from}, {"fromRanges", C.fromRanges}};
1297 }
1298 
1299 bool fromJSON(const llvm::json::Value &Params,
1301  llvm::json::ObjectMapper O(Params, P);
1302  return O.map("item", C.item);
1303 }
1304 
1306  return llvm::json::Object{{"to", C.to}, {"fromRanges", C.fromRanges}};
1307 }
1308 
1310  llvm::json::Path P) {
1311  llvm::json::ObjectMapper O(Params, P);
1312  return O && O.map("textDocument", R.textDocument);
1313 }
1314 
1316  switch (K) {
1318  return "parameter";
1320  return "type";
1321  }
1322  llvm_unreachable("Unknown clang.clangd.InlayHintKind");
1323 }
1324 
1326  return llvm::json::Object{
1327  {"range", H.range}, {"kind", H.kind}, {"label", H.label}};
1328 }
1329 
1330 static const char *toString(OffsetEncoding OE) {
1331  switch (OE) {
1332  case OffsetEncoding::UTF8:
1333  return "utf-8";
1334  case OffsetEncoding::UTF16:
1335  return "utf-16";
1336  case OffsetEncoding::UTF32:
1337  return "utf-32";
1339  return "unknown";
1340  }
1341  llvm_unreachable("Unknown clang.clangd.OffsetEncoding");
1342 }
1345  llvm::json::Path P) {
1346  auto Str = V.getAsString();
1347  if (!Str)
1348  return false;
1349  OE = llvm::StringSwitch<OffsetEncoding>(*Str)
1350  .Case("utf-8", OffsetEncoding::UTF8)
1351  .Case("utf-16", OffsetEncoding::UTF16)
1352  .Case("utf-32", OffsetEncoding::UTF32)
1354  return true;
1355 }
1356 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, OffsetEncoding Enc) {
1357  return OS << toString(Enc);
1358 }
1359 
1361  llvm::json::Path P) {
1362  llvm::json::ObjectMapper O(Params, P);
1363  return O && O.map("textDocument", S.textDocument) &&
1364  O.map("positions", S.positions);
1365 }
1366 
1368  if (Out.parent) {
1369  return llvm::json::Object{{"range", Out.range},
1370  {"parent", toJSON(*Out.parent)}};
1371  }
1372  return llvm::json::Object{{"range", Out.range}};
1373 }
1374 
1376  llvm::json::Path P) {
1377  llvm::json::ObjectMapper O(Params, P);
1378  return O && O.map("textDocument", R.textDocument);
1379 }
1380 
1382  return llvm::json::Object{
1383  {"range", DocumentLink.range},
1384  {"target", DocumentLink.target},
1385  };
1386 }
1387 
1389  llvm::json::Path P) {
1390  llvm::json::ObjectMapper O(Params, P);
1391  return O && O.map("textDocument", R.textDocument);
1392 }
1393 
1395  llvm::json::Object Result{
1396  {"startLine", Range.startLine},
1397  {"endLine", Range.endLine},
1398  };
1399  if (Range.startCharacter)
1400  Result["startCharacter"] = Range.startCharacter;
1401  if (Range.endCharacter)
1402  Result["endCharacter"] = Range.endCharacter;
1403  if (Range.kind)
1404  Result["kind"] = *Range.kind;
1405  return Result;
1406 }
1407 
1409  llvm::json::Object Out;
1410  int64_t Total = MT.self();
1411  Out["_self"] = Total;
1412  for (const auto &Entry : MT.children()) {
1413  auto Child = toJSON(Entry.getSecond());
1414  Total += *Child.getAsObject()->getInteger("_total");
1415  Out[Entry.first] = std::move(Child);
1416  }
1417  Out["_total"] = Total;
1418  return Out;
1419 }
1420 
1421 bool fromJSON(const llvm::json::Value &Params, ASTParams &R,
1422  llvm::json::Path P) {
1423  llvm::json::ObjectMapper O(Params, P);
1424  return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
1425 }
1426 
1428  llvm::json::Object Result{
1429  {"role", N.role},
1430  {"kind", N.kind},
1431  };
1432  if (!N.children.empty())
1433  Result["children"] = N.children;
1434  if (!N.detail.empty())
1435  Result["detail"] = N.detail;
1436  if (!N.arcana.empty())
1437  Result["arcana"] = N.arcana;
1438  if (N.range)
1439  Result["range"] = *N.range;
1440  return Result;
1441 }
1442 
1443 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ASTNode &Root) {
1444  std::function<void(const ASTNode &, unsigned)> Print = [&](const ASTNode &N,
1445  unsigned Level) {
1446  OS.indent(2 * Level) << N.role << ": " << N.kind;
1447  if (!N.detail.empty())
1448  OS << " - " << N.detail;
1449  OS << "\n";
1450  for (const ASTNode &C : N.children)
1451  Print(C, Level + 1);
1452  };
1453  Print(Root, 0);
1454  return OS;
1455 }
1456 
1457 } // namespace clangd
1458 } // namespace clang
clang::clangd::TraceLevel::Messages
@ Messages
clang::clangd::ReferenceContext::includeDeclaration
bool includeDeclaration
Include the declaration of the current symbol.
Definition: Protocol.h:1554
clang::clangd::CallHierarchyItem::selectionRange
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition: Protocol.h:1459
clang::clangd::DocumentHighlight
A document highlight is a range inside a text document which deserves special attention.
Definition: Protocol.h:1329
Total
unsigned Total
Definition: FunctionCognitiveComplexityCheck.cpp:145
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:1394
clang::clangd::SignatureInformation::documentation
std::string documentation
The documentation of this signature. Optional.
Definition: Protocol.h:1281
clang::clangd::WorkspaceEdit
Definition: Protocol.h:926
clang::clangd::DocumentSymbol::range
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
Definition: Protocol.h:1023
clang::clangd::SymbolKind::Field
@ Field
clang::clangd::DidOpenTextDocumentParams::textDocument
TextDocumentItem textDocument
The document that was opened.
Definition: Protocol.h:671
Base
std::unique_ptr< GlobalCompilationDatabase > Base
Definition: GlobalCompilationDatabaseTests.cpp:90
clang::clangd::Diagnostic::source
std::string source
A human-readable string describing the source of this diagnostic, e.g.
Definition: Protocol.h:842
clang::clangd::DocumentOnTypeFormattingParams::ch
std::string ch
The character that has been typed.
Definition: Protocol.h:785
clang::clangd::SymbolKindMin
constexpr auto SymbolKindMin
Definition: Protocol.h:357
clang::clangd::TextDocumentIdentifier::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:125
clang::clangd::ClangdCompileCommand
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
Definition: Protocol.h:493
clang::clangd::ReferenceContext
Definition: Protocol.h:1552
clang::clangd::ClangdCompileCommand::workingDirectory
std::string workingDirectory
Definition: Protocol.h:494
clang::clangd::MarkupKind::PlainText
@ PlainText
clang::clangd::ClientCapabilities::DiagnosticFixes
bool DiagnosticFixes
Whether the client accepts diagnostics with codeActions attached inline.
Definition: Protocol.h:404
clang::clangd::MarkupKind::Markdown
@ 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:716
clang::clangd::SemanticTokensDeltaParams::previousResultId
std::string previousResultId
The previous result id.
Definition: Protocol.h:1619
clang::clangd::SemanticToken::tokenModifiers
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
Definition: Protocol.h:1588
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:1606
E
const Expr * E
Definition: AvoidBindCheck.cpp:88
clang::clangd::Location::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:205
clang::clangd::SymbolTag
SymbolTag
Definition: Protocol.h:1428
clang::clangd::PublishDiagnosticsParams::diagnostics
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
Definition: Protocol.h:891
clang::clangd::FileEvent::uri
URIForFile uri
The file's URI.
Definition: Protocol.h:740
clang::clangd::TraceLevel
TraceLevel
Definition: Protocol.h:257
clang::clangd::ClientCapabilities::DiagnosticCategory
bool DiagnosticCategory
Whether the client accepts diagnostics with category attached to it using the "category" extension.
Definition: Protocol.h:413
clang::clangd::SemanticTokensOrDelta::resultId
std::string resultId
Definition: Protocol.h:1638
clang::clangd::CompletionItemKind::Class
@ Class
clang::clangd::FileEvent
Definition: Protocol.h:738
clang::clangd::CallHierarchyItem::uri
URIForFile uri
The resource identifier of this item.
Definition: Protocol.h:1450
clang::clangd::ShowMessageParams::type
MessageType type
The message type.
Definition: Protocol.h:663
clang::clangd::ResolveTypeHierarchyItemParams::resolve
int resolve
The hierarchy levels to resolve. 0 indicates no level.
Definition: Protocol.h:1420
clang::clangd::SemanticTokensParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1608
clang::clangd::CallHierarchyItem::detail
std::string detail
More detaill for this item, e.g. the signature of a function.
Definition: Protocol.h:1447
clang::clangd::CodeAction
A code action represents a change that can be performed in code, e.g.
Definition: Protocol.h:972
clang::clangd::Diagnostic::category
llvm::Optional< std::string > category
The diagnostic's category.
Definition: Protocol.h:858
clang::clangd::SemanticTokensDeltaParams
Body of textDocument/semanticTokens/full/delta request.
Definition: Protocol.h:1615
clang::clangd::MarkupContent::kind
MarkupKind kind
Definition: Protocol.h:1146
clang::clangd::Location
Definition: Protocol.h:203
clang::clangd::ClientCapabilities::CompletionItemKinds
llvm::Optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
Definition: Protocol.h:438
clang::clangd::SemanticTokenEncodingSize
constexpr unsigned SemanticTokenEncodingSize
Definition: Protocol.cpp:1077
clang::clangd::DocumentOnTypeFormattingParams::textDocument
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:779
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:643
clang::clangd::DocumentRangeFormattingParams::textDocument
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:769
clang::clangd::InitializeParams::processId
llvm::Optional< int > processId
The process Id of the parent process that started the server.
Definition: Protocol.h:535
clang::clangd::ASTNode::detail
std::string detail
Brief additional information, such as "||" for the particular operator.
Definition: Protocol.h:1767
clang::clangd::CompletionList
Represents a collection of completion items to be presented in the editor.
Definition: Protocol.h:1247
clang::clangd::ClientCapabilities::CompletionFixes
bool CompletionFixes
Client supports completions with additionalTextEdit near the cursor.
Definition: Protocol.h:422
Diagnostics
WantDiagnostics Diagnostics
Definition: TUScheduler.cpp:561
clang::clangd::Context::get
const Type * get(const Key< Type > &Key) const
Get data stored for a typed Key.
Definition: Context.h:98
clang::clangd::CodeActionContext::only
std::vector< std::string > only
Requested kind of actions to return.
Definition: Protocol.h:910
clang::clangd::DiagnosticTag
DiagnosticTag
Definition: Protocol.h:815
clang::clangd::ClientCapabilities
Definition: Protocol.h:397
clang::clangd::SemanticTokensEdit
Describes a a replacement of a contiguous range of semanticTokens.
Definition: Protocol.h:1625
clang::clangd::SemanticTokensOrDelta
This models LSP SemanticTokensDelta | SemanticTokens, which is the result of textDocument/semanticTok...
Definition: Protocol.h:1637
clang::clangd::DocumentRangeFormattingParams::range
Range range
The range to format.
Definition: Protocol.h:772
clang::clangd::Hover
Definition: Protocol.h:1151
clang::clangd::ClientCapabilities::WorkspaceSymbolKinds
llvm::Optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
Definition: Protocol.h:400
clang::clangd::SelectionRangeParams::positions
std::vector< Position > positions
The positions inside the text document.
Definition: Protocol.h:1651
clang::clangd::DidCloseTextDocumentParams
Definition: Protocol.h:676
clang::clangd::DocumentOnTypeFormattingParams::position
Position position
The position at which this request was sent.
Definition: Protocol.h:782
CI
std::unique_ptr< CompilerInvocation > CI
Definition: TUScheduler.cpp:450
clang::clangd::CodeAction::isPreferred
bool isPreferred
Marks this as a preferred action.
Definition: Protocol.h:991
clang::clangd::ApplyWorkspaceEditResponse::applied
bool applied
Definition: Protocol.h:1100
clang::clangd::OffsetEncoding::UTF32
@ UTF32
Root
ASTNode Root
Definition: DumpAST.cpp:332
clang::clangd::SymbolInformation
Represents information about programming constructs like variables, classes, interfaces etc.
Definition: Protocol.h:1037
clang::clangd::DidChangeConfigurationParams::settings
ConfigurationSettings settings
Definition: Protocol.h:754
Kind
BindArgumentKind Kind
Definition: AvoidBindCheck.cpp:59
clang::clangd::CompletionItem::label
std::string label
The label of this completion item.
Definition: Protocol.h:1182
clang::clangd::ClientCapabilities::HierarchicalDocumentSymbol
bool HierarchicalDocumentSymbol
Client supports hierarchical document symbols.
Definition: Protocol.h:426
clang::clangd::Range::start
Position start
The range's start position.
Definition: Protocol.h:179
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:255
clang::clangd::CompletionItemKind::Folder
@ Folder
clang::clangd::DidChangeTextDocumentParams::forceRebuild
bool forceRebuild
Force a complete rebuild of the file, ignoring all cached state.
Definition: Protocol.h:722
clang::clangd::SymbolInformation::name
std::string name
The name of this symbol.
Definition: Protocol.h:1039
clang::clangd::ClientCapabilities::CompletionDocumentationFormat
MarkupKind CompletionDocumentationFormat
The documentation format that should be used for textDocument/completion.
Definition: Protocol.h:442
clang::clangd::FileChangeType::Created
@ Created
The file got created.
clang::clangd::CallHierarchyItem::tags
std::vector< SymbolTag > tags
Tags for this item.
Definition: Protocol.h:1444
clang::clangd::ParameterInformation::documentation
std::string documentation
The documentation of this parameter. Optional.
Definition: Protocol.h:1270
clang::clangd::TypeHierarchyItem::kind
SymbolKind kind
The kind of the hierarchy item. For instance, class or interface.
Definition: Protocol.h:1377
clang::clangd::FoldingRangeParams
Definition: Protocol.h:1705
clang::clangd::ClientCapabilities::CompletionSnippets
bool CompletionSnippets
Client supports snippets as insert text.
Definition: Protocol.h:417
clang::clangd::Location::range
Range range
Definition: Protocol.h:206
clang::clangd::SemanticToken::deltaLine
unsigned deltaLine
token line number, relative to the previous token
Definition: Protocol.h:1579
clang::clangd::InitializeParams
Definition: Protocol.h:530
clang::clangd::DocumentHighlight::range
Range range
The range this highlight applies to.
Definition: Protocol.h:1331
clang::clangd::URIForFile::fromURI
static llvm::Expected< URIForFile > fromURI(const URI &U, llvm::StringRef HintPath)
Definition: Protocol.cpp:61
clang::clangd::CompletionItemKind::Text
@ Text
clang::clangd::CodeActionParams::textDocument
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Definition: Protocol.h:916
clang::clangd::SymbolKind::Class
@ Class
clang::clangd::CodeActionParams::context
CodeActionContext context
Context carrying additional information.
Definition: Protocol.h:922
clang::clangd::TextDocumentItem
Definition: Protocol.h:239
clang::clangd::ApplyWorkspaceEditResponse::failureReason
llvm::Optional< std::string > failureReason
Definition: Protocol.h:1101
clang::clangd::ASTNode::kind
std::string kind
The specific kind of node this is, such as "BinaryOperator".
Definition: Protocol.h:1764
clang::clangd::ASTParams::range
llvm::Optional< Range > range
The position of the node to be dumped.
Definition: Protocol.h:1751
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:1267
clang::clangd::CallHierarchyIncomingCall
Represents an incoming call, e.g. a caller of a method or constructor.
Definition: Protocol.h:1476
clang::clangd::URI::parse
static llvm::Expected< URI > parse(llvm::StringRef Uri)
Parse a URI string "<scheme>:[//<authority>/]<path>".
Definition: URI.cpp:179
clang::clangd::InitializeParams::rawCapabilities
llvm::json::Object rawCapabilities
The same data as capabilities, but not parsed (to expose to modules).
Definition: Protocol.h:554
clang::clangd::WorkspaceSymbolParams::limit
llvm::Optional< int > limit
Max results to return, overriding global default.
Definition: Protocol.h:1089
clang::clangd::DocumentSymbol::children
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
Definition: Protocol.h:1030
clang::clangd::SymbolKindBitset
std::bitset< SymbolKindMax+1 > SymbolKindBitset
Definition: Protocol.h:359
clang::clangd::CompletionItem
Definition: Protocol.h:1179
clang::clangd::SymbolDetails::containerName
std::string containerName
Definition: Protocol.h:1066
clang::clangd::DocumentFormattingParams
Definition: Protocol.h:790
clang::clangd::TypeHierarchyItem::range
Range range
The range enclosing this type hierarchy item not including leading/trailing whitespace but everything...
Definition: Protocol.h:1389
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:250
clang::clangd::SymbolKind
SymbolKind
A symbol kind.
Definition: Protocol.h:328
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:592
clang::clangd::RenameParams::position
Position position
The position at which this request was sent.
Definition: Protocol.h:1316
clang::clangd::Diagnostic::range
Range range
The range at which the message applies.
Definition: Protocol.h:831
clang::clangd::MarkupContent::value
std::string value
Definition: Protocol.h:1147
clang::clangd::WorkDoneProgressReport::cancellable
llvm::Optional< bool > cancellable
Controls enablement state of a cancel button.
Definition: Protocol.h:620
clang::clangd::DocumentSymbolParams
Definition: Protocol.h:797
clang::clangd::ASTNode::range
llvm::Optional< Range > range
The range of the original source file covered by this node.
Definition: Protocol.h:1775
clang::clangd::OffsetEncoding::UTF8
@ UTF8
clang::clangd::CompletionItemKindBitset
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
Definition: Protocol.h:320
clang::clangd::Position::line
int line
Line position in a document (zero-based).
Definition: Protocol.h:150
clang::clangd::CodeAction::kind
llvm::Optional< std::string > kind
The kind of the code action.
Definition: Protocol.h:978
clang::clangd::SelectionRangeParams
Definition: Protocol.h:1646
clang::clangd::WorkDoneProgressBegin
To start progress reporting a $/progress notification with the following payload must be sent.
Definition: Protocol.h:582
clang::clangd::SymbolKind::TypeParameter
@ TypeParameter
clang::clangd::DiagnosticRelatedInformation::location
Location location
The location of this related diagnostic information.
Definition: Protocol.h:809
clang::clangd::CompletionItemKind::Enum
@ Enum
clang::clangd::CodeAction::title
std::string title
A short, human-readable, title for this code action.
Definition: Protocol.h:974
clang::clangd::DocumentHighlight::kind
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
Definition: Protocol.h:1334
clang::clangd::SymbolDetails::name
std::string name
Definition: Protocol.h:1064
Protocol.h
clang::clangd::InlayHint
An annotation to be displayed inline next to a range of source code.
Definition: Protocol.h:1535
clang::clangd::toTextKind
static llvm::StringRef toTextKind(MarkupKind Kind)
Definition: Protocol.cpp:872
clang::clangd::WorkspaceEdit::changes
std::map< std::string, std::vector< TextEdit > > changes
Holds changes to existing resources.
Definition: Protocol.h:928
clang::clangd::TypeHierarchyDirection::Both
@ Both
clang::clangd::SignatureInformation::parameters
std::vector< ParameterInformation > parameters
The parameters of this signature.
Definition: Protocol.h:1284
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:247
clang::clangd::Diagnostic
Definition: Protocol.h:829
clang::clangd::TextDocumentItem::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:241
clang::clangd::WorkDoneProgressEnd
Signals the end of progress reporting.
Definition: Protocol.h:640
clang::clangd::ClientCapabilities::offsetEncoding
llvm::Optional< std::vector< OffsetEncoding > > offsetEncoding
Supported encodings for LSP character offsets. (clangd extension).
Definition: Protocol.h:459
clang::clangd::ClientCapabilities::OffsetsInSignatureHelp
bool OffsetsInSignatureHelp
Client supports processing label offsets instead of a simple label string.
Definition: Protocol.h:434
ns1::ns2::A
@ A
Definition: CategoricalFeature.h:3
clang::clangd::CompletionContext::triggerCharacter
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
Definition: Protocol.h:1132
clang::clangd::Position
Definition: Protocol.h:148
clang::clangd::CodeAction::edit
llvm::Optional< WorkspaceEdit > edit
The workspace edit this code action performs.
Definition: Protocol.h:994
clang::clangd::InitializeParams::capabilities
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
Definition: Protocol.h:552
clang::clangd::SymbolDetails::ID
SymbolID ID
Definition: Protocol.h:1075
ns1::ns2::D
@ D
Definition: CategoricalFeature.h:3
clang::clangd::SymbolKind::Method
@ Method
clang::clangd::SymbolKind::Function
@ Function
clang::clangd::ExecuteCommandParams::argument
llvm::json::Value argument
Definition: Protocol.h:957
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:1569
clang::clangd::ClientCapabilities::RenamePrepareSupport
bool RenamePrepareSupport
The client supports testing for validity of rename operations before execution.
Definition: Protocol.h:467
clang::clangd::Unknown
@ Unknown
Definition: FuzzyMatch.h:56
clang::clangd::ClientCapabilities::HoverContentFormat
MarkupKind HoverContentFormat
The content format that should be used for Hover requests.
Definition: Protocol.h:463
clang::clangd::TweakArgs
Arguments for the 'applyTweak' command.
Definition: Protocol.h:940
clang::clangd::TypeHierarchyDirection::Children
@ Children
clang::clangd::SemanticToken
Specifies a single semantic token in the document.
Definition: Protocol.h:1577
clang::clangd::MemoryTree
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
Definition: MemoryTree.h:32
clang::clangd::SignatureInformation::label
std::string label
The label of this signature. Mandatory.
Definition: Protocol.h:1278
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:1640
clang::clangd::SignatureHelp::signatures
std::vector< SignatureInformation > signatures
The resulting signatures.
Definition: Protocol.h:1294
clang::clangd::DocumentSymbolParams::textDocument
TextDocumentIdentifier textDocument
Definition: Protocol.h:799
clang::clangd::DidChangeWatchedFilesParams
Definition: Protocol.h:746
clang::clangd::ASTNode::role
std::string role
The general kind of node, such as "expression" Corresponds to the base AST node type such as Expr.
Definition: Protocol.h:1760
clang::clangd::PublishDiagnosticsParams::uri
URIForFile uri
The URI for which diagnostic information is reported.
Definition: Protocol.h:889
clang::clangd::Diag
A top-level diagnostic that may have Notes and Fixes.
Definition: Diagnostics.h:97
clang::clangd::toJSON
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
Definition: Index.cpp:49
clang::clangd::InlayHintKind::TypeHint
@ TypeHint
The hint corresponds to information about a deduced type.
Logger.h
clang::clangd::WorkDoneProgressReport::message
llvm::Optional< std::string > message
Optional, more detailed associated progress message.
Definition: Protocol.h:627
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:1582
Args
llvm::json::Object Args
Definition: Trace.cpp:139
clang::clangd::SymbolKind::Interface
@ Interface
clang::clangd::OffsetEncoding::UTF16
@ UTF16
clang::clangd::TypeHierarchyItem::name
std::string name
The human readable name of the hierarchy item.
Definition: Protocol.h:1370
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:1586
clang::clangd::FileChangeType::Deleted
@ Deleted
The file got deleted.
clang::clangd::CallHierarchyOutgoingCall
Represents an outgoing call, e.g.
Definition: Protocol.h:1495
if
if(CLANGD_ENABLE_REMOTE) generate_protos(RemoteIndexProto "Index.proto") generate_protos(MonitoringServiceProto "MonitoringService.proto" GRPC) generate_protos(RemoteIndexServiceProto "Service.proto" DEPENDS "Index.proto" GRPC) target_link_libraries(RemoteIndexServiceProto PRIVATE RemoteIndexProto MonitoringServiceProto) include_directories($
Definition: clangd/index/remote/CMakeLists.txt:1
clang::clangd::fromJSON
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request, llvm::json::Path P)
Definition: Index.cpp:34
clang::clangd::TextDocumentIdentifier
Definition: Protocol.h:123
clang::clangd::DocumentSymbol::detail
std::string detail
More detail for this symbol, e.g the signature of a function.
Definition: Protocol.h:1011
clang::clangd::DocumentRangeFormattingParams
Definition: Protocol.h:767
clang::clangd::WorkDoneProgressCreateParams::token
llvm::json::Value token
The token to be used to report progress.
Definition: Protocol.h:566
clang::clangd::FileStatus::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:1566
clang::clangd::CallHierarchyItem::data
std::string data
An optional 'data' field, which can be used to identify a call hierarchy item in an incomingCalls or ...
Definition: Protocol.h:1463
clang::clangd::ExecuteCommandParams::command
std::string command
The identifier of the actual command handler.
Definition: Protocol.h:953
clang::clangd::FoldingRangeParams::textDocument
TextDocumentIdentifier textDocument
Definition: Protocol.h:1706
clang::clangd::indexSymbolKindToSymbolKind
SymbolKind indexSymbolKindToSymbolKind(index::SymbolKind Kind)
Definition: Protocol.cpp:253
clang::clangd::Diagnostic::data
llvm::json::Object data
A data entry field that is preserved between a textDocument/publishDiagnostics notification andtextDo...
Definition: Protocol.h:870
clang::clangd::DocumentSymbol::selectionRange
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition: Protocol.h:1027
clang::clangd::TextDocumentItem::languageId
std::string languageId
The text document's language identifier.
Definition: Protocol.h:244
clang::clangd::CompletionItem::sortText
std::string sortText
A string that should be used when comparing this item with other items.
Definition: Protocol.h:1197
clang::clangd::InsertTextFormat::Missing
@ Missing
clang::clangd::toString
static const char * toString(OffsetEncoding OE)
Definition: Protocol.cpp:1330
clang::clangd::Position::character
int character
Character offset on a line in a document (zero-based).
Definition: Protocol.h:155
clang::clangd::ReferenceParams::context
ReferenceContext context
Definition: Protocol.h:1558
clang::clangd::CompletionContext::triggerKind
CompletionTriggerKind triggerKind
How the completion was triggered.
Definition: Protocol.h:1129
clang::clangd::CompletionItemKind::Struct
@ Struct
clang::clangd::TextDocumentPositionParams::position
Position position
The position inside the text document.
Definition: Protocol.h:1111
clang::clangd::Range::end
Position end
The range's end position.
Definition: Protocol.h:182
clang::clangd::SymbolID::str
std::string str() const
Definition: SymbolID.cpp:34
clang::clangd::DocumentSymbol
Represents programming constructs like variables, classes, interfaces etc.
Definition: Protocol.h:1006
clang::clangd::SemanticTokensOrDelta::tokens
llvm::Optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
Definition: Protocol.h:1642
clang::clangd::URIForFile
Definition: Protocol.h:76
clang::clangd::SemanticToken::length
unsigned length
the length of the token. A token cannot be multiline
Definition: Protocol.h:1584
clang::clangd::URIForFile::uri
std::string uri() const
Definition: Protocol.h:99
clang::clangd::DidChangeConfigurationParams
Definition: Protocol.h:753
clang::clangd::SymbolKind::Enum
@ Enum
clang::clangd::DidChangeWatchedFilesParams::changes
std::vector< FileEvent > changes
The actual file events.
Definition: Protocol.h:748
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:1404
clang::clangd::SelectionRange
Definition: Protocol.h:1656
clang::clangd::MemoryTree::children
const llvm::DenseMap< llvm::StringRef, MemoryTree > & children() const
Returns edges to direct children of this node.
Definition: MemoryTree.cpp:35
clang::clangd::operator<<
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
Definition: CodeComplete.cpp:2013
clang::clangd::CodeAction::command
llvm::Optional< Command > command
A command this code action executes.
Definition: Protocol.h:998
clang::clangd::DocumentFormattingParams::textDocument
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:792
clang::clangd::CompletionItemKind
CompletionItemKind
The kind of a completion entry.
Definition: Protocol.h:286
clang::clangd::TypeHierarchyItem::uri
URIForFile uri
The URI of the text document where this type hierarchy item belongs to.
Definition: Protocol.h:1383
clang::clangd::DocumentHighlightKind::Write
@ Write
clang::clangd::SymbolDetails
Represents information about identifier.
Definition: Protocol.h:1063
clang::clangd::ConfigurationSettings
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Definition: Protocol.h:503
clang::clangd::DocumentLinkParams
Parameters for the document link request.
Definition: Protocol.h:1670
clang::clangd::ClientCapabilities::DiagnosticRelatedInformation
bool DiagnosticRelatedInformation
Whether the client accepts diagnostics with related locations.
Definition: Protocol.h:408
clang::clangd::SymbolDetails::USR
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol.
Definition: Protocol.h:1073
clang::clangd::ExecuteCommandParams
Definition: Protocol.h:951
clang::clangd::SymbolKind::Module
@ Module
SymbolKind
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
Definition: SymbolInfo.cpp:21
clang::clangd::SignatureHelp::activeSignature
int activeSignature
The active signature.
Definition: Protocol.h:1297
clang::clangd::TextDocumentItem::text
std::string text
The content of the opened text document.
Definition: Protocol.h:253
clang::clangd::InitializeParams::initializationOptions
InitializationOptions initializationOptions
User-provided initialization options.
Definition: Protocol.h:560
clang::clangd::encodeTokens
static llvm::json::Value encodeTokens(llvm::ArrayRef< SemanticToken > Toks)
Definition: Protocol.cpp:1078
clang::clangd::SymbolInformation::score
llvm::Optional< float > score
The score that clangd calculates to rank the returned symbols.
Definition: Protocol.h:1056
clang::clangd::CallHierarchyIncomingCallsParams
The parameter of a callHierarchy/incomingCalls request.
Definition: Protocol.h:1469
Entry
Definition: Modularize.cpp:428
clang::clangd::TypeHierarchyParams::resolve
int resolve
The hierarchy levels to resolve. 0 indicates no level.
Definition: Protocol.h:1360
clang::clangd::CompletionItemKind::File
@ File
clang::clangd::CodeActionContext::diagnostics
std::vector< Diagnostic > diagnostics
An array of diagnostics known on the client side overlapping the range provided to the textDocument/c...
Definition: Protocol.h:904
clang::clangd::SelectionRangeParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1648
clang::clangd::WorkDoneProgressReport
Reporting progress is done using the following payload.
Definition: Protocol.h:608
clang::clangd::PublishDiagnosticsParams
Definition: Protocol.h:887
clang::clangd::MemoryTree::self
size_t self() const
Returns total number of bytes used by this node only.
Definition: MemoryTree.h:67
clang::clangd::ClientCapabilities::WorkDoneProgress
bool WorkDoneProgress
The client supports progress notifications.
Definition: Protocol.h:471
clang::clangd::HighlightingKind::Parameter
@ Parameter
clang::clangd::MarkupKind
MarkupKind
Definition: Protocol.h:387
clang::clangd::CodeAction::diagnostics
llvm::Optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Definition: Protocol.h:984
clang::clangd::MessageType
MessageType
Definition: Protocol.h:647
clang::clangd::TypeHierarchyDirection
TypeHierarchyDirection
Definition: Protocol.h:1351
clang::clangd::TypeHierarchyParams
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
Definition: Protocol.h:1358
clang::clangd::SymbolKind::Variable
@ Variable
clang::clangd::TypeHierarchyItem
Definition: Protocol.h:1368
clang::clangd::DidChangeTextDocumentParams
Definition: Protocol.h:703
clang::clangd::CompletionTriggerKind
CompletionTriggerKind
Definition: Protocol.h:1116
clang::clangd::ConfigurationSettings::compilationDatabaseChanges
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
Definition: Protocol.h:506
clang::clangd::TypeHierarchyItem::detail
llvm::Optional< std::string > detail
Optional detail for the hierarchy item.
Definition: Protocol.h:1374
clang::clangd::TypeHierarchyItem::deprecated
bool deprecated
true if the hierarchy item is deprecated. Otherwise, false.
Definition: Protocol.h:1380
clang::clangd::SignatureInformation
Represents the signature of something callable.
Definition: Protocol.h:1275
clang::clangd::ClientCapabilities::SemanticTokenRefreshSupport
bool SemanticTokenRefreshSupport
Whether the client implementation supports a refresh request sent from the server to the client.
Definition: Protocol.h:485
clang::clangd::ClientCapabilities::CodeActionStructure
bool CodeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
Definition: Protocol.h:446
clang::clangd::ASTParams
Payload for textDocument/ast request.
Definition: Protocol.h:1744
Info
FunctionInfo Info
Definition: FunctionSizeCheck.cpp:120
clang::clangd::DocumentSymbol::kind
SymbolKind kind
The kind of this symbol.
Definition: Protocol.h:1014
clang::clangd::CompletionItemKind::EnumMember
@ EnumMember
clang::clangd::WorkDoneProgressBegin::percentage
bool percentage
Optional progress percentage to display (value 100 is considered 100%).
Definition: Protocol.h:603
clang::clangd::DidChangeTextDocumentParams::contentChanges
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
Definition: Protocol.h:710
clang::clangd::DidChangeTextDocumentParams::textDocument
VersionedTextDocumentIdentifier textDocument
The document that did change.
Definition: Protocol.h:707
clang::clangd::TypeHierarchyParams::direction
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition: Protocol.h:1363
clang::clangd::TextDocumentPositionParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1108
clang::clangd::DidSaveTextDocumentParams::textDocument
TextDocumentIdentifier textDocument
The document that was saved.
Definition: Protocol.h:685
clang::clangd::InlayHintKind::ParameterHint
@ ParameterHint
The hint corresponds to parameter information.
clang::clangd::WorkspaceSymbolParams
The parameters of a Workspace Symbol Request.
Definition: Protocol.h:1082
clang::clangd::CompletionParams
Definition: Protocol.h:1136
clang::clangd::ClangdCompileCommand::compilationCommand
std::vector< std::string > compilationCommand
Definition: Protocol.h:495
clang::clangd::Range
Definition: Protocol.h:177
clang::clangd::FileEvent::type
FileChangeType type
The change type.
Definition: Protocol.h:742
clang::clangd::SignatureHelp
Represents the signature of a callable.
Definition: Protocol.h:1291
clang::clangd::FileChangeType
FileChangeType
Definition: Protocol.h:727
clang::clangd::SemanticTokens
A versioned set of tokens.
Definition: Protocol.h:1593
clang::clangd::VersionedTextDocumentIdentifier::version
llvm::Optional< std::int64_t > version
The version number of this document.
Definition: Protocol.h:142
C
const Criteria C
Definition: FunctionCognitiveComplexityCheck.cpp:93
clang::clangd::ShowMessageParams::message
std::string message
The actual message.
Definition: Protocol.h:665
clang::clangd::Diagnostic::message
std::string message
The diagnostic's message.
Definition: Protocol.h:845
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:48
clang::clangd::ApplyWorkspaceEditResponse
Definition: Protocol.h:1099
clang::clangd::Diagnostic::severity
int severity
The diagnostic's severity.
Definition: Protocol.h:835
clang::clangd::ParameterInformation::labelString
std::string labelString
The label of this parameter. Ignored when labelOffsets is set.
Definition: Protocol.h:1261
clang::clangd::InitializeParams::trace
llvm::Optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
Definition: Protocol.h:557
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:893
clang::clangd::WorkDoneProgressReport::percentage
llvm::Optional< unsigned > percentage
Optional progress percentage to display (value 100 is considered 100%).
Definition: Protocol.h:635
OS
llvm::raw_string_ostream OS
Definition: TraceTests.cpp:163
clang::clangd::FoldingRange
Stores information about a region of code that can be folded.
Definition: Protocol.h:1712
clang::clangd::CodeAction::REFACTOR_KIND
const static llvm::StringLiteral REFACTOR_KIND
Definition: Protocol.h:980
clang::clangd::DidSaveTextDocumentParams
Definition: Protocol.h:683
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:1399
clang::clangd::CallHierarchyItem::range
Range range
The range enclosing this symbol not including leading / trailing whitespace but everything else,...
Definition: Protocol.h:1454
clang::clangd::OffsetEncoding
OffsetEncoding
Definition: Protocol.h:371
clang::clangd::TextDocumentContentChangeEvent::range
llvm::Optional< Range > range
The range of the document that changed.
Definition: Protocol.h:692
clang::clangd::FileStatus
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
Definition: Protocol.h:1564
clang::clangd::TextDocumentContentChangeEvent
Definition: Protocol.h:690
clang::clangd::WorkspaceSymbolParams::query
std::string query
A query string to filter symbols by.
Definition: Protocol.h:1085
clang::clangd::DocumentSymbol::deprecated
bool deprecated
Indicates if this symbol is deprecated.
Definition: Protocol.h:1017
clang::clangd::ClientCapabilities::TheiaSemanticHighlighting
bool TheiaSemanticHighlighting
Client supports Theia semantic highlighting extension.
Definition: Protocol.h:456
clang::clangd::CodeActionParams
Definition: Protocol.h:914
clang::clangd::operator<
bool operator<(const Ref &L, const Ref &R)
Definition: Ref.h:97
clang::clangd::TextDocumentPositionParams
Definition: Protocol.h:1106
clang::clangd::InitializeParams::rootPath
llvm::Optional< std::string > rootPath
The rootPath of the workspace.
Definition: Protocol.h:541
clang::clangd::InitializationOptions
Clangd extension: parameters configurable at initialize time.
Definition: Protocol.h:513
clang::clangd::DidCloseTextDocumentParams::textDocument
TextDocumentIdentifier textDocument
The document that was closed.
Definition: Protocol.h:678
clang::clangd::CallHierarchyItem
Represents programming constructs like functions or constructors in the context of call hierarchy.
Definition: Protocol.h:1436
clang::clangd::Diagnostic::code
std::string code
The diagnostic's code. Can be omitted.
Definition: Protocol.h:838
clang::clangd::SymbolKind::EnumMember
@ EnumMember
clang::clangd::RenameParams::textDocument
TextDocumentIdentifier textDocument
The document that was opened.
Definition: Protocol.h:1313
clang::clangd::DocumentOnTypeFormattingParams
Definition: Protocol.h:777
clang::clangd::TextEdit
Definition: Protocol.h:223
clang::clangd::SignatureHelp::activeParameter
int activeParameter
The active parameter of the active signature.
Definition: Protocol.h:1300
clang::clangd::OffsetEncoding::UnsupportedEncoding
@ UnsupportedEncoding
clang::clangd::SymbolInformation::containerName
std::string containerName
The name of the symbol containing this symbol.
Definition: Protocol.h:1048
clang::clangd::RenameParams
Definition: Protocol.h:1311
clang::clangd::ApplyWorkspaceEditParams
Definition: Protocol.h:1094
clang::clangd::CompletionParams::limit
llvm::Optional< int > limit
Max results to return, overriding global default.
Definition: Protocol.h:1141
clang::clangd::TraceLevel::Off
@ Off
clang::clangd::SymbolKind::Namespace
@ 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:477
clang::clangd::DidOpenTextDocumentParams
Definition: Protocol.h:669
clang::clangd::TraceLevel::Verbose
@ Verbose
clang::clangd::DocumentSymbol::name
std::string name
The name of this symbol.
Definition: Protocol.h:1008
clang::clangd::CompletionItemKind::Missing
@ Missing
clang::clangd::DocumentHighlightKind::Read
@ Read
clang::clangd::CompletionParams::context
CompletionContext context
Definition: Protocol.h:1137
clang::clangd::ClientCapabilities::SemanticTokens
bool SemanticTokens
Client advertises support for the semanticTokens feature.
Definition: Protocol.h:451
clang::clangd::ReferenceParams
Definition: Protocol.h:1557
clang::clangd::InlayHintKind
InlayHintKind
A set of predefined hint kinds.
Definition: Protocol.h:1513
URI.h
clang::clangd::SymbolKind::File
@ File
clang::clangd::ASTNode::arcana
std::string arcana
A one-line dump of detailed information about the node.
Definition: Protocol.h:1772
clang::clangd::ParameterInformation
A single parameter of a particular signature.
Definition: Protocol.h:1258
clang::clangd::DocumentLinkParams::textDocument
TextDocumentIdentifier textDocument
The document to provide document links for.
Definition: Protocol.h:1672
clang::clangd::LSPError::ID
static char ID
Definition: Protocol.h:62
clang::clangd::InlayHintsParams::textDocument
TextDocumentIdentifier textDocument
The text document for which inlay hints are requested.
Definition: Protocol.h:1508
clang::clangd::TextEdit::newText
std::string newText
The string to be inserted.
Definition: Protocol.h:230
clang::clangd::SymbolInformation::location
Location location
The location of this symbol.
Definition: Protocol.h:1045
Out
CompiledFragmentImpl & Out
Definition: ConfigCompile.cpp:100
clang::clangd::ClientCapabilities::CancelsStaleRequests
bool CancelsStaleRequests
Whether the client claims to cancel stale requests.
Definition: Protocol.h:481
clang::clangd::SemanticTokensDeltaParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1617
clang::clangd::elog
void elog(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:62
clang::clangd::MarkupContent
Definition: Protocol.h:1145
clang::clangd::ASTNode::children
std::vector< ASTNode > children
Nodes nested within this one, such as the operands of a BinaryOperator.
Definition: Protocol.h:1777
clang::clangd::InitializeParams::rootUri
llvm::Optional< URIForFile > rootUri
The rootUri of the workspace.
Definition: Protocol.h:546
clang::clangd::DiagnosticRelatedInformation
Represents a related message and source code location for a diagnostic.
Definition: Protocol.h:807
clang::clangd::ResolveTypeHierarchyItemParams::direction
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition: Protocol.h:1423
clang::clangd::CompletionContext
Definition: Protocol.h:1127
clang::clangd::TextDocumentContentChangeEvent::text
std::string text
The new text of the range/document.
Definition: Protocol.h:698
clang::clangd::ASTParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1746
Tag
HTMLTag Tag
Definition: HTMLGenerator.cpp:90
clang::clangd::CallHierarchyOutgoingCallsParams
The parameter of a callHierarchy/outgoingCalls request.
Definition: Protocol.h:1487
clang::clangd::CompletionItemKind::TypeParameter
@ TypeParameter
clang::clangd::ASTNode
Simplified description of a clang AST node.
Definition: Protocol.h:1757
clang::clangd::CompletionItemKindMin
constexpr auto CompletionItemKindMin
Definition: Protocol.h:316
clang::clangd::ResolveTypeHierarchyItemParams::item
TypeHierarchyItem item
The item to resolve.
Definition: Protocol.h:1417
clang::clangd::ApplyWorkspaceEditParams::edit
WorkspaceEdit edit
Definition: Protocol.h:1095
clang::clangd::TextEdit::range
Range range
The range of the text document to be manipulated.
Definition: Protocol.h:226
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:661
clang::clangd::CodeAction::INFO_KIND
const static llvm::StringLiteral INFO_KIND
Definition: Protocol.h:981
clang::clangd::SymbolKind::Constructor
@ Constructor
clang::clangd::CodeActionContext
Definition: Protocol.h:897
clang::clangd::URI
A URI describes the location of a source file.
Definition: URI.h:28
K
Kind K
Definition: Rename.cpp:442
clang::clangd::SymbolInformation::kind
SymbolKind kind
The kind of this symbol.
Definition: Protocol.h:1042
clang::clangd::ClientCapabilities::HasSignatureHelp
bool HasSignatureHelp
Client supports signature help.
Definition: Protocol.h:430
clang::clangd::VersionedTextDocumentIdentifier
Definition: Protocol.h:131
clang::clangd::WorkDoneProgressBegin::title
std::string title
Mandatory title of the progress operation.
Definition: Protocol.h:587
clang::clangd::CodeActionParams::range
Range range
The range for which the command was invoked.
Definition: Protocol.h:919
clang::clangd::SymbolKind::String
@ String
clang::clangd::DiagnosticRelatedInformation::message
std::string message
The message of this related diagnostic information.
Definition: Protocol.h:811
Value
static constexpr bool Value
Definition: SuspiciousCallArgumentCheck.cpp:72
clang::clangd::CallHierarchyItem::name
std::string name
The name of this item.
Definition: Protocol.h:1438
clang::clangd::TypeHierarchyItem::data
llvm::Optional< std::string > data
An optional 'data' field, which can be used to identify a type hierarchy item in a resolve request.
Definition: Protocol.h:1408
clang::clangd::RenameParams::newName
std::string newName
The new name of the symbol.
Definition: Protocol.h:1319
clang::clangd::SymbolKind::Property
@ Property
clang::clangd::SymbolKind::Struct
@ Struct
Path
std::vector< HeaderHandle > Path
Definition: PreprocessorTracker.cpp:525
clang::clangd::InlayHintsParams
The parameter of a textDocument/inlayHints request.
Definition: Protocol.h:1506
clang::clangd::adjustKindToCapability
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
Definition: Protocol.cpp:235
clang::clangd::TextDocumentContentChangeEvent::rangeLength
llvm::Optional< int > rangeLength
The length of the range that got replaced.
Definition: Protocol.h:695
clang::clangd::CallHierarchyItem::kind
SymbolKind kind
The kind of this item.
Definition: Protocol.h:1441
clang::clangd::CodeAction::QUICKFIX_KIND
const static llvm::StringLiteral QUICKFIX_KIND
Definition: Protocol.h:979
clang::clangd::ResolveTypeHierarchyItemParams
Parameters for the typeHierarchy/resolve request.
Definition: Protocol.h:1415
clang::clangd::WorkDoneProgressCreateParams
Definition: Protocol.h:564