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  }
699  if (ArgsArray->size() == 1) {
700  R.argument = ArgsArray->front();
701  }
702  return true;
703 }
704 
706  llvm::json::Object O{
707  {"name", P.name},
708  {"kind", static_cast<int>(P.kind)},
709  {"location", P.location},
710  {"containerName", P.containerName},
711  };
712  if (P.score)
713  O["score"] = *P.score;
714  return std::move(O);
715 }
716 
717 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
718  const SymbolInformation &SI) {
719  O << SI.containerName << "::" << SI.name << " - " << toJSON(SI);
720  return O;
721 }
722 
723 bool operator==(const SymbolDetails &LHS, const SymbolDetails &RHS) {
724  return LHS.name == RHS.name && LHS.containerName == RHS.containerName &&
725  LHS.USR == RHS.USR && LHS.ID == RHS.ID;
726 }
727 
729  llvm::json::Object Result{{"name", llvm::json::Value(nullptr)},
730  {"containerName", llvm::json::Value(nullptr)},
731  {"usr", llvm::json::Value(nullptr)},
732  {"id", llvm::json::Value(nullptr)}};
733 
734  if (!P.name.empty())
735  Result["name"] = P.name;
736 
737  if (!P.containerName.empty())
738  Result["containerName"] = P.containerName;
739 
740  if (!P.USR.empty())
741  Result["usr"] = P.USR;
742 
743  if (P.ID)
744  Result["id"] = P.ID.str();
745 
746  // FIXME: workaround for older gcc/clang
747  return std::move(Result);
748 }
749 
750 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const SymbolDetails &S) {
751  if (!S.containerName.empty()) {
752  O << S.containerName;
753  llvm::StringRef ContNameRef;
754  if (!ContNameRef.endswith("::")) {
755  O << " ";
756  }
757  }
758  O << S.name << " - " << toJSON(S);
759  return O;
760 }
761 
763  llvm::json::Path P) {
764  llvm::json::ObjectMapper O(Params, P);
765  return O && O.map("query", R.query) &&
766  mapOptOrNull(Params, "limit", R.limit, P);
767 }
768 
769 llvm::json::Value toJSON(const Command &C) {
770  auto Cmd = llvm::json::Object{{"title", C.title}, {"command", C.command}};
771  if (!C.argument.getAsNull())
772  Cmd["arguments"] = llvm::json::Array{C.argument};
773  return std::move(Cmd);
774 }
775 
776 const llvm::StringLiteral CodeAction::QUICKFIX_KIND = "quickfix";
777 const llvm::StringLiteral CodeAction::REFACTOR_KIND = "refactor";
778 const llvm::StringLiteral CodeAction::INFO_KIND = "info";
779 
781  auto CodeAction = llvm::json::Object{{"title", CA.title}};
782  if (CA.kind)
783  CodeAction["kind"] = *CA.kind;
784  if (CA.diagnostics)
785  CodeAction["diagnostics"] = llvm::json::Array(*CA.diagnostics);
786  if (CA.isPreferred)
787  CodeAction["isPreferred"] = true;
788  if (CA.edit)
789  CodeAction["edit"] = *CA.edit;
790  if (CA.command)
791  CodeAction["command"] = *CA.command;
792  return std::move(CodeAction);
793 }
794 
795 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S) {
796  return O << S.name << " - " << toJSON(S);
797 }
798 
800  llvm::json::Object Result{{"name", S.name},
801  {"kind", static_cast<int>(S.kind)},
802  {"range", S.range},
803  {"selectionRange", S.selectionRange}};
804 
805  if (!S.detail.empty())
806  Result["detail"] = S.detail;
807  if (!S.children.empty())
808  Result["children"] = S.children;
809  if (S.deprecated)
810  Result["deprecated"] = true;
811  // FIXME: workaround for older gcc/clang
812  return std::move(Result);
813 }
814 
816  llvm::json::Object FileChanges;
817  for (auto &Change : WE.changes)
818  FileChanges[Change.first] = llvm::json::Array(Change.second);
819  return llvm::json::Object{{"changes", std::move(FileChanges)}};
820 }
821 
822 bool fromJSON(const llvm::json::Value &Params, TweakArgs &A,
823  llvm::json::Path P) {
824  llvm::json::ObjectMapper O(Params, P);
825  return O && O.map("file", A.file) && O.map("selection", A.selection) &&
826  O.map("tweakID", A.tweakID);
827 }
828 
830  return llvm::json::Object{
831  {"tweakID", A.tweakID}, {"selection", A.selection}, {"file", A.file}};
832 }
833 
835  return llvm::json::Object{{"edit", Params.edit}};
836 }
837 
839  llvm::json::Path P) {
840  llvm::json::ObjectMapper O(Response, P);
841  return O && O.map("applied", R.applied) &&
842  O.map("failureReason", R.failureReason);
843 }
844 
846  llvm::json::Path P) {
847  llvm::json::ObjectMapper O(Params, P);
848  return O && O.map("textDocument", R.textDocument) &&
849  O.map("position", R.position);
850 }
851 
853  llvm::json::Path P) {
854  llvm::json::ObjectMapper O(Params, P);
855  int TriggerKind;
856  if (!O || !O.map("triggerKind", TriggerKind) ||
857  !mapOptOrNull(Params, "triggerCharacter", R.triggerCharacter, P))
858  return false;
859  R.triggerKind = static_cast<CompletionTriggerKind>(TriggerKind);
860  return true;
861 }
862 
864  llvm::json::Path P) {
865  if (!fromJSON(Params, static_cast<TextDocumentPositionParams &>(R), P) ||
866  !mapOptOrNull(Params, "limit", R.limit, P))
867  return false;
868  if (auto *Context = Params.getAsObject()->get("context"))
869  return fromJSON(*Context, R.context, P.field("context"));
870  return true;
871 }
872 
873 static llvm::StringRef toTextKind(MarkupKind Kind) {
874  switch (Kind) {
876  return "plaintext";
878  return "markdown";
879  }
880  llvm_unreachable("Invalid MarkupKind");
881 }
882 
884  auto Str = V.getAsString();
885  if (!Str) {
886  P.report("expected string");
887  return false;
888  }
889  if (*Str == "plaintext")
891  else if (*Str == "markdown")
893  else {
894  P.report("unknown markup kind");
895  return false;
896  }
897  return true;
898 }
899 
900 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, MarkupKind K) {
901  return OS << toTextKind(K);
902 }
903 
905  if (MC.value.empty())
906  return nullptr;
907 
908  return llvm::json::Object{
909  {"kind", toTextKind(MC.kind)},
910  {"value", MC.value},
911  };
912 }
913 
915  llvm::json::Object Result{{"contents", toJSON(H.contents)}};
916 
917  if (H.range.hasValue())
918  Result["range"] = toJSON(*H.range);
919 
920  return std::move(Result);
921 }
922 
924  llvm::json::Path P) {
925  if (auto T = E.getAsInteger()) {
926  if (*T < static_cast<int>(CompletionItemKind::Text) ||
927  *T > static_cast<int>(CompletionItemKind::TypeParameter))
928  return false;
929  Out = static_cast<CompletionItemKind>(*T);
930  return true;
931  }
932  return false;
933 }
934 
937  CompletionItemKindBitset &SupportedCompletionItemKinds) {
938  auto KindVal = static_cast<size_t>(Kind);
939  if (KindVal >= CompletionItemKindMin &&
940  KindVal <= SupportedCompletionItemKinds.size() &&
941  SupportedCompletionItemKinds[KindVal])
942  return Kind;
943 
944  switch (Kind) {
945  // Provide some fall backs for common kinds that are close enough.
952  default:
954  }
955 }
956 
958  llvm::json::Path P) {
959  if (auto *A = E.getAsArray()) {
960  for (size_t I = 0; I < A->size(); ++I) {
961  CompletionItemKind KindOut;
962  if (fromJSON((*A)[I], KindOut, P.index(I)))
963  Out.set(size_t(KindOut));
964  }
965  return true;
966  }
967  return false;
968 }
969 
971  assert(!CI.label.empty() && "completion item label is required");
972  llvm::json::Object Result{{"label", CI.label}};
973  if (CI.kind != CompletionItemKind::Missing)
974  Result["kind"] = static_cast<int>(CI.kind);
975  if (!CI.detail.empty())
976  Result["detail"] = CI.detail;
977  if (CI.documentation)
978  Result["documentation"] = CI.documentation;
979  if (!CI.sortText.empty())
980  Result["sortText"] = CI.sortText;
981  if (!CI.filterText.empty())
982  Result["filterText"] = CI.filterText;
983  if (!CI.insertText.empty())
984  Result["insertText"] = CI.insertText;
985  if (CI.insertTextFormat != InsertTextFormat::Missing)
986  Result["insertTextFormat"] = static_cast<int>(CI.insertTextFormat);
987  if (CI.textEdit)
988  Result["textEdit"] = *CI.textEdit;
989  if (!CI.additionalTextEdits.empty())
990  Result["additionalTextEdits"] = llvm::json::Array(CI.additionalTextEdits);
991  if (CI.deprecated)
992  Result["deprecated"] = CI.deprecated;
993  Result["score"] = CI.score;
994  return std::move(Result);
995 }
996 
997 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const CompletionItem &I) {
998  O << I.label << " - " << toJSON(I);
999  return O;
1000 }
1001 
1002 bool operator<(const CompletionItem &L, const CompletionItem &R) {
1003  return (L.sortText.empty() ? L.label : L.sortText) <
1004  (R.sortText.empty() ? R.label : R.sortText);
1005 }
1006 
1008  return llvm::json::Object{
1009  {"isIncomplete", L.isIncomplete},
1010  {"items", llvm::json::Array(L.items)},
1011  };
1012 }
1013 
1015  assert((PI.labelOffsets.hasValue() || !PI.labelString.empty()) &&
1016  "parameter information label is required");
1017  llvm::json::Object Result;
1018  if (PI.labelOffsets)
1019  Result["label"] =
1020  llvm::json::Array({PI.labelOffsets->first, PI.labelOffsets->second});
1021  else
1022  Result["label"] = PI.labelString;
1023  if (!PI.documentation.empty())
1024  Result["documentation"] = PI.documentation;
1025  return std::move(Result);
1026 }
1027 
1029  assert(!SI.label.empty() && "signature information label is required");
1030  llvm::json::Object Result{
1031  {"label", SI.label},
1032  {"parameters", llvm::json::Array(SI.parameters)},
1033  };
1034  if (!SI.documentation.empty())
1035  Result["documentation"] = SI.documentation;
1036  return std::move(Result);
1037 }
1038 
1039 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1040  const SignatureInformation &I) {
1041  O << I.label << " - " << toJSON(I);
1042  return O;
1043 }
1044 
1046  assert(SH.activeSignature >= 0 &&
1047  "Unexpected negative value for number of active signatures.");
1048  assert(SH.activeParameter >= 0 &&
1049  "Unexpected negative value for active parameter index");
1050  return llvm::json::Object{
1051  {"activeSignature", SH.activeSignature},
1052  {"activeParameter", SH.activeParameter},
1053  {"signatures", llvm::json::Array(SH.signatures)},
1054  };
1055 }
1056 
1057 bool fromJSON(const llvm::json::Value &Params, RenameParams &R,
1058  llvm::json::Path P) {
1059  llvm::json::ObjectMapper O(Params, P);
1060  return O && O.map("textDocument", R.textDocument) &&
1061  O.map("position", R.position) && O.map("newName", R.newName);
1062 }
1063 
1065  return llvm::json::Object{
1066  {"range", toJSON(DH.range)},
1067  {"kind", static_cast<int>(DH.kind)},
1068  };
1069 }
1070 
1072  return llvm::json::Object{
1073  {"uri", FStatus.uri},
1074  {"state", FStatus.state},
1075  };
1076 }
1077 
1078 constexpr unsigned SemanticTokenEncodingSize = 5;
1079 static llvm::json::Value encodeTokens(llvm::ArrayRef<SemanticToken> Toks) {
1080  llvm::json::Array Result;
1081  Result.reserve(SemanticTokenEncodingSize * Toks.size());
1082  for (const auto &Tok : Toks) {
1083  Result.push_back(Tok.deltaLine);
1084  Result.push_back(Tok.deltaStart);
1085  Result.push_back(Tok.length);
1086  Result.push_back(Tok.tokenType);
1087  Result.push_back(Tok.tokenModifiers);
1088  }
1089  assert(Result.size() == SemanticTokenEncodingSize * Toks.size());
1090  return std::move(Result);
1091 }
1092 
1093 bool operator==(const SemanticToken &L, const SemanticToken &R) {
1094  return std::tie(L.deltaLine, L.deltaStart, L.length, L.tokenType,
1095  L.tokenModifiers) == std::tie(R.deltaLine, R.deltaStart,
1096  R.length, R.tokenType,
1097  R.tokenModifiers);
1098 }
1099 
1101  return llvm::json::Object{{"resultId", Tokens.resultId},
1102  {"data", encodeTokens(Tokens.tokens)}};
1103 }
1104 
1106  return llvm::json::Object{
1107  {"start", SemanticTokenEncodingSize * Edit.startToken},
1108  {"deleteCount", SemanticTokenEncodingSize * Edit.deleteTokens},
1109  {"data", encodeTokens(Edit.tokens)}};
1110 }
1111 
1113  llvm::json::Object Result{{"resultId", TE.resultId}};
1114  if (TE.edits)
1115  Result["edits"] = *TE.edits;
1116  if (TE.tokens)
1117  Result["data"] = encodeTokens(*TE.tokens);
1118  return std::move(Result);
1119 }
1120 
1122  llvm::json::Path P) {
1123  llvm::json::ObjectMapper O(Params, P);
1124  return O && O.map("textDocument", R.textDocument);
1125 }
1126 
1128  llvm::json::Path P) {
1129  llvm::json::ObjectMapper O(Params, P);
1130  return O && O.map("textDocument", R.textDocument) &&
1131  O.map("previousResultId", R.previousResultId);
1132 }
1133 
1134 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1135  const DocumentHighlight &V) {
1136  O << V.range;
1138  O << "(r)";
1140  O << "(w)";
1141  return O;
1142 }
1143 
1144 bool fromJSON(const llvm::json::Value &Params,
1146  llvm::json::ObjectMapper O(Params, P);
1147  return O && O.map("settings", CCP.settings);
1148 }
1149 
1150 bool fromJSON(const llvm::json::Value &Params, ClangdCompileCommand &CDbUpdate,
1151  llvm::json::Path P) {
1152  llvm::json::ObjectMapper O(Params, P);
1153  return O && O.map("workingDirectory", CDbUpdate.workingDirectory) &&
1154  O.map("compilationCommand", CDbUpdate.compilationCommand);
1155 }
1156 
1158  llvm::json::Path P) {
1159  llvm::json::ObjectMapper O(Params, P);
1160  if (!O)
1161  return true; // 'any' type in LSP.
1162  return mapOptOrNull(Params, "compilationDatabaseChanges",
1164 }
1165 
1167  llvm::json::Path P) {
1168  llvm::json::ObjectMapper O(Params, P);
1169  if (!O)
1170  return true; // 'any' type in LSP.
1171 
1172  return fromJSON(Params, Opts.ConfigSettings, P) &&
1173  O.map("compilationDatabasePath", Opts.compilationDatabasePath) &&
1174  mapOptOrNull(Params, "fallbackFlags", Opts.fallbackFlags, P) &&
1175  mapOptOrNull(Params, "clangdFileStatus", Opts.FileStatus, P);
1176 }
1177 
1179  llvm::json::Path P) {
1180  auto T = E.getAsInteger();
1181  if (!T)
1182  return false;
1183  if (*T < static_cast<int>(TypeHierarchyDirection::Children) ||
1184  *T > static_cast<int>(TypeHierarchyDirection::Both))
1185  return false;
1186  Out = static_cast<TypeHierarchyDirection>(*T);
1187  return true;
1188 }
1189 
1191  llvm::json::Path P) {
1192  llvm::json::ObjectMapper O(Params, P);
1193  return O && O.map("textDocument", R.textDocument) &&
1194  O.map("position", R.position) && O.map("resolve", R.resolve) &&
1195  O.map("direction", R.direction);
1196 }
1197 
1198 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1199  const TypeHierarchyItem &I) {
1200  return O << I.name << " - " << toJSON(I);
1201 }
1202 
1204  llvm::json::Object Result{{"name", I.name},
1205  {"kind", static_cast<int>(I.kind)},
1206  {"range", I.range},
1207  {"selectionRange", I.selectionRange},
1208  {"uri", I.uri}};
1209 
1210  if (I.detail)
1211  Result["detail"] = I.detail;
1212  if (I.deprecated)
1213  Result["deprecated"] = I.deprecated;
1214  if (I.parents)
1215  Result["parents"] = I.parents;
1216  if (I.children)
1217  Result["children"] = I.children;
1218  if (I.data)
1219  Result["data"] = I.data;
1220  return std::move(Result);
1221 }
1222 
1224  llvm::json::Path P) {
1225  llvm::json::ObjectMapper O(Params, P);
1226 
1227  // Required fields.
1228  return O && O.map("name", I.name) && O.map("kind", I.kind) &&
1229  O.map("uri", I.uri) && O.map("range", I.range) &&
1230  O.map("selectionRange", I.selectionRange) &&
1231  mapOptOrNull(Params, "detail", I.detail, P) &&
1232  mapOptOrNull(Params, "deprecated", I.deprecated, P) &&
1233  mapOptOrNull(Params, "parents", I.parents, P) &&
1234  mapOptOrNull(Params, "children", I.children, P) &&
1235  mapOptOrNull(Params, "data", I.data, P);
1236 }
1237 
1238 bool fromJSON(const llvm::json::Value &Params,
1240  llvm::json::ObjectMapper O(Params, P);
1241  return O && O.map("item", R.item) && O.map("resolve", R.resolve) &&
1242  O.map("direction", R.direction);
1243 }
1244 
1246  llvm::json::Path P) {
1247  llvm::json::ObjectMapper O(Params, P);
1248  return O && O.mapOptional("includeDeclaration", R.includeDeclaration);
1249 }
1250 
1252  llvm::json::Path P) {
1254  llvm::json::ObjectMapper O(Params, P);
1255  return fromJSON(Params, Base, P) && O && O.mapOptional("context", R.context);
1256 }
1257 
1259  return llvm::json::Value{static_cast<int>(Tag)};
1260 }
1261 
1263  llvm::json::Object Result{{"name", I.name},
1264  {"kind", static_cast<int>(I.kind)},
1265  {"range", I.range},
1266  {"selectionRange", I.selectionRange},
1267  {"uri", I.uri}};
1268  if (!I.tags.empty())
1269  Result["tags"] = I.tags;
1270  if (!I.detail.empty())
1271  Result["detail"] = I.detail;
1272  if (!I.data.empty())
1273  Result["data"] = I.data;
1274  return std::move(Result);
1275 }
1276 
1278  llvm::json::Path P) {
1279  llvm::json::ObjectMapper O(Params, P);
1280 
1281  // Populate the required fields only. We don't care about the
1282  // optional fields `Tags` and `Detail` for the purpose of
1283  // client --> server communication.
1284  return O && O.map("name", I.name) && O.map("kind", I.kind) &&
1285  O.map("uri", I.uri) && O.map("range", I.range) &&
1286  O.map("selectionRange", I.selectionRange) &&
1287  mapOptOrNull(Params, "data", I.data, P);
1288 }
1289 
1290 bool fromJSON(const llvm::json::Value &Params,
1292  llvm::json::ObjectMapper O(Params, P);
1293  return O.map("item", C.item);
1294 }
1295 
1297  return llvm::json::Object{{"from", C.from}, {"fromRanges", C.fromRanges}};
1298 }
1299 
1300 bool fromJSON(const llvm::json::Value &Params,
1302  llvm::json::ObjectMapper O(Params, P);
1303  return O.map("item", C.item);
1304 }
1305 
1307  return llvm::json::Object{{"to", C.to}, {"fromRanges", C.fromRanges}};
1308 }
1309 
1311  llvm::json::Path P) {
1312  llvm::json::ObjectMapper O(Params, P);
1313  return O && O.map("textDocument", R.textDocument);
1314 }
1315 
1317  switch (K) {
1319  return "parameter";
1321  return "type";
1322  }
1323  llvm_unreachable("Unknown clang.clangd.InlayHintKind");
1324 }
1325 
1327  return llvm::json::Object{
1328  {"range", H.range}, {"kind", H.kind}, {"label", H.label}};
1329 }
1330 bool operator==(const InlayHint &A, const InlayHint &B) {
1331  return std::tie(A.kind, A.range, A.label) ==
1332  std::tie(B.kind, B.range, B.label);
1333 }
1334 bool operator<(const InlayHint &A, const InlayHint &B) {
1335  return std::tie(A.kind, A.range, A.label) <
1336  std::tie(B.kind, B.range, B.label);
1337 }
1338 
1339 static const char *toString(OffsetEncoding OE) {
1340  switch (OE) {
1341  case OffsetEncoding::UTF8:
1342  return "utf-8";
1343  case OffsetEncoding::UTF16:
1344  return "utf-16";
1345  case OffsetEncoding::UTF32:
1346  return "utf-32";
1348  return "unknown";
1349  }
1350  llvm_unreachable("Unknown clang.clangd.OffsetEncoding");
1351 }
1354  llvm::json::Path P) {
1355  auto Str = V.getAsString();
1356  if (!Str)
1357  return false;
1358  OE = llvm::StringSwitch<OffsetEncoding>(*Str)
1359  .Case("utf-8", OffsetEncoding::UTF8)
1360  .Case("utf-16", OffsetEncoding::UTF16)
1361  .Case("utf-32", OffsetEncoding::UTF32)
1363  return true;
1364 }
1365 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, OffsetEncoding Enc) {
1366  return OS << toString(Enc);
1367 }
1368 
1370  llvm::json::Path P) {
1371  llvm::json::ObjectMapper O(Params, P);
1372  return O && O.map("textDocument", S.textDocument) &&
1373  O.map("positions", S.positions);
1374 }
1375 
1377  if (Out.parent) {
1378  return llvm::json::Object{{"range", Out.range},
1379  {"parent", toJSON(*Out.parent)}};
1380  }
1381  return llvm::json::Object{{"range", Out.range}};
1382 }
1383 
1385  llvm::json::Path P) {
1386  llvm::json::ObjectMapper O(Params, P);
1387  return O && O.map("textDocument", R.textDocument);
1388 }
1389 
1391  return llvm::json::Object{
1392  {"range", DocumentLink.range},
1393  {"target", DocumentLink.target},
1394  };
1395 }
1396 
1398  llvm::json::Path P) {
1399  llvm::json::ObjectMapper O(Params, P);
1400  return O && O.map("textDocument", R.textDocument);
1401 }
1402 
1404  llvm::json::Object Result{
1405  {"startLine", Range.startLine},
1406  {"endLine", Range.endLine},
1407  };
1408  if (Range.startCharacter)
1409  Result["startCharacter"] = Range.startCharacter;
1410  if (Range.endCharacter)
1411  Result["endCharacter"] = Range.endCharacter;
1412  if (Range.kind)
1413  Result["kind"] = *Range.kind;
1414  return Result;
1415 }
1416 
1418  llvm::json::Object Out;
1419  int64_t Total = MT.self();
1420  Out["_self"] = Total;
1421  for (const auto &Entry : MT.children()) {
1422  auto Child = toJSON(Entry.getSecond());
1423  Total += *Child.getAsObject()->getInteger("_total");
1424  Out[Entry.first] = std::move(Child);
1425  }
1426  Out["_total"] = Total;
1427  return Out;
1428 }
1429 
1430 bool fromJSON(const llvm::json::Value &Params, ASTParams &R,
1431  llvm::json::Path P) {
1432  llvm::json::ObjectMapper O(Params, P);
1433  return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
1434 }
1435 
1437  llvm::json::Object Result{
1438  {"role", N.role},
1439  {"kind", N.kind},
1440  };
1441  if (!N.children.empty())
1442  Result["children"] = N.children;
1443  if (!N.detail.empty())
1444  Result["detail"] = N.detail;
1445  if (!N.arcana.empty())
1446  Result["arcana"] = N.arcana;
1447  if (N.range)
1448  Result["range"] = *N.range;
1449  return Result;
1450 }
1451 
1452 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ASTNode &Root) {
1453  std::function<void(const ASTNode &, unsigned)> Print = [&](const ASTNode &N,
1454  unsigned Level) {
1455  OS.indent(2 * Level) << N.role << ": " << N.kind;
1456  if (!N.detail.empty())
1457  OS << " - " << N.detail;
1458  OS << "\n";
1459  for (const ASTNode &C : N.children)
1460  Print(C, Level + 1);
1461  };
1462  Print(Root, 0);
1463  return OS;
1464 }
1465 
1466 } // namespace clangd
1467 } // namespace clang
clang::clangd::TraceLevel::Messages
@ Messages
clang::clangd::ReferenceContext::includeDeclaration
bool includeDeclaration
Include the declaration of the current symbol.
Definition: Protocol.h:1561
clang::clangd::CallHierarchyItem::selectionRange
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition: Protocol.h:1464
clang::clangd::DocumentHighlight
A document highlight is a range inside a text document which deserves special attention.
Definition: Protocol.h:1334
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:1399
clang::clangd::SignatureInformation::documentation
std::string documentation
The documentation of this signature. Optional.
Definition: Protocol.h:1286
clang::clangd::WorkspaceEdit
Definition: Protocol.h:931
clang::clangd::DocumentSymbol::range
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
Definition: Protocol.h:1028
clang::clangd::SymbolKind::Field
@ Field
clang::clangd::DidOpenTextDocumentParams::textDocument
TextDocumentItem textDocument
The document that was opened.
Definition: Protocol.h:676
Base
std::unique_ptr< GlobalCompilationDatabase > Base
Definition: GlobalCompilationDatabaseTests.cpp:89
clang::clangd::Diagnostic::source
std::string source
A human-readable string describing the source of this diagnostic, e.g.
Definition: Protocol.h:847
clang::clangd::DocumentOnTypeFormattingParams::ch
std::string ch
The character that has been typed.
Definition: Protocol.h:790
clang::clangd::SymbolKindMin
constexpr auto SymbolKindMin
Definition: Protocol.h:362
clang::clangd::TextDocumentIdentifier::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:130
clang::clangd::ClangdCompileCommand
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
Definition: Protocol.h:498
clang::clangd::ReferenceContext
Definition: Protocol.h:1559
clang::clangd::ClangdCompileCommand::workingDirectory
std::string workingDirectory
Definition: Protocol.h:499
clang::clangd::MarkupKind::PlainText
@ PlainText
clang::clangd::ClientCapabilities::DiagnosticFixes
bool DiagnosticFixes
Whether the client accepts diagnostics with codeActions attached inline.
Definition: Protocol.h:409
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:721
clang::clangd::SemanticTokensDeltaParams::previousResultId
std::string previousResultId
The previous result id.
Definition: Protocol.h:1626
clang::clangd::SemanticToken::tokenModifiers
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
Definition: Protocol.h:1595
clang::clangd::Edit
A set of edits generated for a single file.
Definition: SourceCode.h:184
clang::clangd::SemanticTokensParams
Body of textDocument/semanticTokens/full request.
Definition: Protocol.h:1613
E
const Expr * E
Definition: AvoidBindCheck.cpp:88
clang::clangd::Location::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:210
clang::clangd::SymbolTag
SymbolTag
Definition: Protocol.h:1433
clang::clangd::PublishDiagnosticsParams::diagnostics
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
Definition: Protocol.h:896
clang::clangd::FileEvent::uri
URIForFile uri
The file's URI.
Definition: Protocol.h:745
clang::clangd::TraceLevel
TraceLevel
Definition: Protocol.h:262
clang::clangd::ClientCapabilities::DiagnosticCategory
bool DiagnosticCategory
Whether the client accepts diagnostics with category attached to it using the "category" extension.
Definition: Protocol.h:418
clang::clangd::SemanticTokensOrDelta::resultId
std::string resultId
Definition: Protocol.h:1645
clang::clangd::CompletionItemKind::Class
@ Class
clang::clangd::FileEvent
Definition: Protocol.h:743
clang::clangd::CallHierarchyItem::uri
URIForFile uri
The resource identifier of this item.
Definition: Protocol.h:1455
clang::clangd::ShowMessageParams::type
MessageType type
The message type.
Definition: Protocol.h:668
clang::clangd::ResolveTypeHierarchyItemParams::resolve
int resolve
The hierarchy levels to resolve. 0 indicates no level.
Definition: Protocol.h:1425
clang::clangd::SemanticTokensParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1615
clang::clangd::CallHierarchyItem::detail
std::string detail
More detaill for this item, e.g. the signature of a function.
Definition: Protocol.h:1452
clang::clangd::CodeAction
A code action represents a change that can be performed in code, e.g.
Definition: Protocol.h:977
clang::clangd::Diagnostic::category
llvm::Optional< std::string > category
The diagnostic's category.
Definition: Protocol.h:863
clang::clangd::SemanticTokensDeltaParams
Body of textDocument/semanticTokens/full/delta request.
Definition: Protocol.h:1622
clang::clangd::MarkupContent::kind
MarkupKind kind
Definition: Protocol.h:1151
clang::clangd::Location
Definition: Protocol.h:208
clang::clangd::ClientCapabilities::CompletionItemKinds
llvm::Optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
Definition: Protocol.h:443
clang::clangd::SemanticTokenEncodingSize
constexpr unsigned SemanticTokenEncodingSize
Definition: Protocol.cpp:1078
clang::clangd::DocumentOnTypeFormattingParams::textDocument
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:784
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:648
clang::clangd::DocumentRangeFormattingParams::textDocument
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:774
clang::clangd::InitializeParams::processId
llvm::Optional< int > processId
The process Id of the parent process that started the server.
Definition: Protocol.h:540
clang::clangd::ASTNode::detail
std::string detail
Brief additional information, such as "||" for the particular operator.
Definition: Protocol.h:1774
clang::clangd::CompletionList
Represents a collection of completion items to be presented in the editor.
Definition: Protocol.h:1252
clang::clangd::ClientCapabilities::CompletionFixes
bool CompletionFixes
Client supports completions with additionalTextEdit near the cursor.
Definition: Protocol.h:427
Diagnostics
WantDiagnostics Diagnostics
Definition: TUScheduler.cpp:567
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:915
clang::clangd::DiagnosticTag
DiagnosticTag
Definition: Protocol.h:820
clang::clangd::ClientCapabilities
Definition: Protocol.h:402
clang::clangd::SemanticTokensEdit
Describes a a replacement of a contiguous range of semanticTokens.
Definition: Protocol.h:1632
clang::clangd::SemanticTokensOrDelta
This models LSP SemanticTokensDelta | SemanticTokens, which is the result of textDocument/semanticTok...
Definition: Protocol.h:1644
clang::clangd::DocumentRangeFormattingParams::range
Range range
The range to format.
Definition: Protocol.h:777
clang::clangd::Hover
Definition: Protocol.h:1156
clang::clangd::ClientCapabilities::WorkspaceSymbolKinds
llvm::Optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
Definition: Protocol.h:405
clang::clangd::SelectionRangeParams::positions
std::vector< Position > positions
The positions inside the text document.
Definition: Protocol.h:1658
clang::clangd::DidCloseTextDocumentParams
Definition: Protocol.h:681
clang::clangd::DocumentOnTypeFormattingParams::position
Position position
The position at which this request was sent.
Definition: Protocol.h:787
CI
std::unique_ptr< CompilerInvocation > CI
Definition: TUScheduler.cpp:456
clang::clangd::CodeAction::isPreferred
bool isPreferred
Marks this as a preferred action.
Definition: Protocol.h:996
clang::clangd::ApplyWorkspaceEditResponse::applied
bool applied
Definition: Protocol.h:1105
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:1042
clang::clangd::DidChangeConfigurationParams::settings
ConfigurationSettings settings
Definition: Protocol.h:759
Kind
BindArgumentKind Kind
Definition: AvoidBindCheck.cpp:59
clang::clangd::CompletionItem::label
std::string label
The label of this completion item.
Definition: Protocol.h:1187
clang::clangd::ClientCapabilities::HierarchicalDocumentSymbol
bool HierarchicalDocumentSymbol
Client supports hierarchical document symbols.
Definition: Protocol.h:431
clang::clangd::Range::start
Position start
The range's start position.
Definition: Protocol.h:184
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:727
clang::clangd::SymbolInformation::name
std::string name
The name of this symbol.
Definition: Protocol.h:1044
clang::clangd::ClientCapabilities::CompletionDocumentationFormat
MarkupKind CompletionDocumentationFormat
The documentation format that should be used for textDocument/completion.
Definition: Protocol.h:447
clang::clangd::FileChangeType::Created
@ Created
The file got created.
clang::clangd::CallHierarchyItem::tags
std::vector< SymbolTag > tags
Tags for this item.
Definition: Protocol.h:1449
clang::clangd::ParameterInformation::documentation
std::string documentation
The documentation of this parameter. Optional.
Definition: Protocol.h:1275
clang::clangd::TypeHierarchyItem::kind
SymbolKind kind
The kind of the hierarchy item. For instance, class or interface.
Definition: Protocol.h:1382
clang::clangd::FoldingRangeParams
Definition: Protocol.h:1712
clang::clangd::ClientCapabilities::CompletionSnippets
bool CompletionSnippets
Client supports snippets as insert text.
Definition: Protocol.h:422
clang::clangd::Location::range
Range range
Definition: Protocol.h:211
clang::clangd::SemanticToken::deltaLine
unsigned deltaLine
token line number, relative to the previous token
Definition: Protocol.h:1586
clang::clangd::InitializeParams
Definition: Protocol.h:535
clang::clangd::DocumentHighlight::range
Range range
The range this highlight applies to.
Definition: Protocol.h:1336
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:921
clang::clangd::SymbolKind::Class
@ Class
clang::clangd::CodeActionParams::context
CodeActionContext context
Context carrying additional information.
Definition: Protocol.h:927
clang::clangd::TextDocumentItem
Definition: Protocol.h:244
clang::clangd::ApplyWorkspaceEditResponse::failureReason
llvm::Optional< std::string > failureReason
Definition: Protocol.h:1106
clang::clangd::ASTNode::kind
std::string kind
The specific kind of node this is, such as "BinaryOperator".
Definition: Protocol.h:1771
clang::clangd::ASTParams::range
llvm::Optional< Range > range
The position of the node to be dumped.
Definition: Protocol.h:1758
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:1272
clang::clangd::CallHierarchyIncomingCall
Represents an incoming call, e.g. a caller of a method or constructor.
Definition: Protocol.h:1481
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:559
clang::clangd::WorkspaceSymbolParams::limit
llvm::Optional< int > limit
Max results to return, overriding global default.
Definition: Protocol.h:1094
clang::clangd::DocumentSymbol::children
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
Definition: Protocol.h:1035
clang::clangd::SymbolKindBitset
std::bitset< SymbolKindMax+1 > SymbolKindBitset
Definition: Protocol.h:364
clang::clangd::CompletionItem
Definition: Protocol.h:1184
clang::clangd::SymbolDetails::containerName
std::string containerName
Definition: Protocol.h:1071
clang::clangd::DocumentFormattingParams
Definition: Protocol.h:795
clang::clangd::TypeHierarchyItem::range
Range range
The range enclosing this type hierarchy item not including leading/trailing whitespace but everything...
Definition: Protocol.h:1394
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:255
clang::clangd::SymbolKind
SymbolKind
A symbol kind.
Definition: Protocol.h:333
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:597
clang::clangd::RenameParams::position
Position position
The position at which this request was sent.
Definition: Protocol.h:1321
clang::clangd::Diagnostic::range
Range range
The range at which the message applies.
Definition: Protocol.h:836
clang::clangd::MarkupContent::value
std::string value
Definition: Protocol.h:1152
clang::clangd::WorkDoneProgressReport::cancellable
llvm::Optional< bool > cancellable
Controls enablement state of a cancel button.
Definition: Protocol.h:625
clang::clangd::DocumentSymbolParams
Definition: Protocol.h:802
clang::clangd::ASTNode::range
llvm::Optional< Range > range
The range of the original source file covered by this node.
Definition: Protocol.h:1782
clang::clangd::OffsetEncoding::UTF8
@ UTF8
clang::clangd::CompletionItemKindBitset
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
Definition: Protocol.h:325
clang::clangd::Position::line
int line
Line position in a document (zero-based).
Definition: Protocol.h:155
clang::clangd::CodeAction::kind
llvm::Optional< std::string > kind
The kind of the code action.
Definition: Protocol.h:983
clang::clangd::SelectionRangeParams
Definition: Protocol.h:1653
clang::clangd::WorkDoneProgressBegin
To start progress reporting a $/progress notification with the following payload must be sent.
Definition: Protocol.h:587
clang::clangd::SymbolKind::TypeParameter
@ TypeParameter
clang::clangd::DiagnosticRelatedInformation::location
Location location
The location of this related diagnostic information.
Definition: Protocol.h:814
clang::clangd::CompletionItemKind::Enum
@ Enum
clang::clangd::CodeAction::title
std::string title
A short, human-readable, title for this code action.
Definition: Protocol.h:979
clang::clangd::DocumentHighlight::kind
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
Definition: Protocol.h:1339
clang::clangd::SymbolDetails::name
std::string name
Definition: Protocol.h:1069
Protocol.h
clang::clangd::InlayHint
An annotation to be displayed inline next to a range of source code.
Definition: Protocol.h:1540
clang::clangd::toTextKind
static llvm::StringRef toTextKind(MarkupKind Kind)
Definition: Protocol.cpp:873
clang::clangd::WorkspaceEdit::changes
std::map< std::string, std::vector< TextEdit > > changes
Holds changes to existing resources.
Definition: Protocol.h:933
clang::clangd::TypeHierarchyDirection::Both
@ Both
clang::clangd::SignatureInformation::parameters
std::vector< ParameterInformation > parameters
The parameters of this signature.
Definition: Protocol.h:1289
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:834
clang::clangd::TextDocumentItem::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:246
clang::clangd::WorkDoneProgressEnd
Signals the end of progress reporting.
Definition: Protocol.h:645
clang::clangd::ClientCapabilities::offsetEncoding
llvm::Optional< std::vector< OffsetEncoding > > offsetEncoding
Supported encodings for LSP character offsets. (clangd extension).
Definition: Protocol.h:464
clang::clangd::ClientCapabilities::OffsetsInSignatureHelp
bool OffsetsInSignatureHelp
Client supports processing label offsets instead of a simple label string.
Definition: Protocol.h:439
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:1137
clang::clangd::Position
Definition: Protocol.h:153
clang::clangd::CodeAction::edit
llvm::Optional< WorkspaceEdit > edit
The workspace edit this code action performs.
Definition: Protocol.h:999
clang::clangd::InitializeParams::capabilities
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
Definition: Protocol.h:557
clang::clangd::SymbolDetails::ID
SymbolID ID
Definition: Protocol.h:1080
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:962
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:1576
clang::clangd::ClientCapabilities::RenamePrepareSupport
bool RenamePrepareSupport
The client supports testing for validity of rename operations before execution.
Definition: Protocol.h:472
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:468
clang::clangd::TweakArgs
Arguments for the 'applyTweak' command.
Definition: Protocol.h:945
clang::clangd::TypeHierarchyDirection::Children
@ Children
clang::clangd::SemanticToken
Specifies a single semantic token in the document.
Definition: Protocol.h:1584
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:1283
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:1647
clang::clangd::SignatureHelp::signatures
std::vector< SignatureInformation > signatures
The resulting signatures.
Definition: Protocol.h:1299
clang::clangd::DocumentSymbolParams::textDocument
TextDocumentIdentifier textDocument
Definition: Protocol.h:804
clang::clangd::DidChangeWatchedFilesParams
Definition: Protocol.h:751
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:1767
clang::clangd::PublishDiagnosticsParams::uri
URIForFile uri
The URI for which diagnostic information is reported.
Definition: Protocol.h:894
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:632
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:1589
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:1375
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:1593
clang::clangd::FileChangeType::Deleted
@ Deleted
The file got deleted.
clang::clangd::CallHierarchyOutgoingCall
Represents an outgoing call, e.g.
Definition: Protocol.h:1500
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:128
clang::clangd::DocumentSymbol::detail
std::string detail
More detail for this symbol, e.g the signature of a function.
Definition: Protocol.h:1016
clang::clangd::DocumentRangeFormattingParams
Definition: Protocol.h:772
clang::clangd::WorkDoneProgressCreateParams::token
llvm::json::Value token
The token to be used to report progress.
Definition: Protocol.h:571
clang::clangd::FileStatus::uri
URIForFile uri
The text document's URI.
Definition: Protocol.h:1573
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:1468
clang::clangd::ExecuteCommandParams::command
std::string command
The identifier of the actual command handler.
Definition: Protocol.h:958
clang::clangd::FoldingRangeParams::textDocument
TextDocumentIdentifier textDocument
Definition: Protocol.h:1713
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:875
clang::clangd::DocumentSymbol::selectionRange
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition: Protocol.h:1032
clang::clangd::TextDocumentItem::languageId
std::string languageId
The text document's language identifier.
Definition: Protocol.h:249
clang::clangd::CompletionItem::sortText
std::string sortText
A string that should be used when comparing this item with other items.
Definition: Protocol.h:1202
clang::clangd::InsertTextFormat::Missing
@ Missing
clang::clangd::toString
static const char * toString(OffsetEncoding OE)
Definition: Protocol.cpp:1339
clang::clangd::Position::character
int character
Character offset on a line in a document (zero-based).
Definition: Protocol.h:160
clang::clangd::ReferenceParams::context
ReferenceContext context
Definition: Protocol.h:1565
clang::clangd::CompletionContext::triggerKind
CompletionTriggerKind triggerKind
How the completion was triggered.
Definition: Protocol.h:1134
clang::clangd::CompletionItemKind::Struct
@ Struct
clang::clangd::TextDocumentPositionParams::position
Position position
The position inside the text document.
Definition: Protocol.h:1116
clang::clangd::Range::end
Position end
The range's end position.
Definition: Protocol.h:187
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:1011
clang::clangd::SemanticTokensOrDelta::tokens
llvm::Optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
Definition: Protocol.h:1649
clang::clangd::URIForFile
Definition: Protocol.h:81
clang::clangd::SemanticToken::length
unsigned length
the length of the token. A token cannot be multiline
Definition: Protocol.h:1591
clang::clangd::URIForFile::uri
std::string uri() const
Definition: Protocol.h:104
clang::clangd::DidChangeConfigurationParams
Definition: Protocol.h:758
clang::clangd::SymbolKind::Enum
@ Enum
clang::clangd::DidChangeWatchedFilesParams::changes
std::vector< FileEvent > changes
The actual file events.
Definition: Protocol.h:753
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:1409
clang::clangd::SelectionRange
Definition: Protocol.h:1663
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:2155
clang::clangd::CodeAction::command
llvm::Optional< Command > command
A command this code action executes.
Definition: Protocol.h:1003
clang::clangd::DocumentFormattingParams::textDocument
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:797
clang::clangd::CompletionItemKind
CompletionItemKind
The kind of a completion entry.
Definition: Protocol.h:291
clang::clangd::TypeHierarchyItem::uri
URIForFile uri
The URI of the text document where this type hierarchy item belongs to.
Definition: Protocol.h:1388
clang::clangd::DocumentHighlightKind::Write
@ Write
clang::clangd::SymbolDetails
Represents information about identifier.
Definition: Protocol.h:1068
clang::clangd::ConfigurationSettings
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Definition: Protocol.h:508
clang::clangd::DocumentLinkParams
Parameters for the document link request.
Definition: Protocol.h:1677
clang::clangd::ClientCapabilities::DiagnosticRelatedInformation
bool DiagnosticRelatedInformation
Whether the client accepts diagnostics with related locations.
Definition: Protocol.h:413
clang::clangd::SymbolDetails::USR
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol.
Definition: Protocol.h:1078
clang::clangd::ExecuteCommandParams
Definition: Protocol.h:956
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:1302
clang::clangd::TextDocumentItem::text
std::string text
The content of the opened text document.
Definition: Protocol.h:258
clang::clangd::InitializeParams::initializationOptions
InitializationOptions initializationOptions
User-provided initialization options.
Definition: Protocol.h:565
clang::clangd::encodeTokens
static llvm::json::Value encodeTokens(llvm::ArrayRef< SemanticToken > Toks)
Definition: Protocol.cpp:1079
clang::clangd::SymbolInformation::score
llvm::Optional< float > score
The score that clangd calculates to rank the returned symbols.
Definition: Protocol.h:1061
clang::clangd::CallHierarchyIncomingCallsParams
The parameter of a callHierarchy/incomingCalls request.
Definition: Protocol.h:1474
Entry
Definition: Modularize.cpp:428
clang::clangd::TypeHierarchyParams::resolve
int resolve
The hierarchy levels to resolve. 0 indicates no level.
Definition: Protocol.h:1365
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:909
clang::clangd::SelectionRangeParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1655
clang::clangd::WorkDoneProgressReport
Reporting progress is done using the following payload.
Definition: Protocol.h:613
clang::clangd::PublishDiagnosticsParams
Definition: Protocol.h:892
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:476
clang::clangd::HighlightingKind::Parameter
@ Parameter
clang::clangd::MarkupKind
MarkupKind
Definition: Protocol.h:392
clang::clangd::CodeAction::diagnostics
llvm::Optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Definition: Protocol.h:989
clang::clangd::MessageType
MessageType
Definition: Protocol.h:652
clang::clangd::TypeHierarchyDirection
TypeHierarchyDirection
Definition: Protocol.h:1356
clang::clangd::TypeHierarchyParams
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
Definition: Protocol.h:1363
clang::clangd::SymbolKind::Variable
@ Variable
clang::clangd::TypeHierarchyItem
Definition: Protocol.h:1373
clang::clangd::DidChangeTextDocumentParams
Definition: Protocol.h:708
clang::clangd::CompletionTriggerKind
CompletionTriggerKind
Definition: Protocol.h:1121
clang::clangd::ConfigurationSettings::compilationDatabaseChanges
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
Definition: Protocol.h:511
clang::clangd::TypeHierarchyItem::detail
llvm::Optional< std::string > detail
Optional detail for the hierarchy item.
Definition: Protocol.h:1379
clang::clangd::TypeHierarchyItem::deprecated
bool deprecated
true if the hierarchy item is deprecated. Otherwise, false.
Definition: Protocol.h:1385
clang::clangd::SignatureInformation
Represents the signature of something callable.
Definition: Protocol.h:1280
clang::clangd::ClientCapabilities::SemanticTokenRefreshSupport
bool SemanticTokenRefreshSupport
Whether the client implementation supports a refresh request sent from the server to the client.
Definition: Protocol.h:490
clang::clangd::ClientCapabilities::CodeActionStructure
bool CodeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
Definition: Protocol.h:451
clang::clangd::ASTParams
Payload for textDocument/ast request.
Definition: Protocol.h:1751
Info
FunctionInfo Info
Definition: FunctionSizeCheck.cpp:120
clang::clangd::DocumentSymbol::kind
SymbolKind kind
The kind of this symbol.
Definition: Protocol.h:1019
clang::clangd::CompletionItemKind::EnumMember
@ EnumMember
clang::clangd::WorkDoneProgressBegin::percentage
bool percentage
Optional progress percentage to display (value 100 is considered 100%).
Definition: Protocol.h:608
clang::clangd::DidChangeTextDocumentParams::contentChanges
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
Definition: Protocol.h:715
clang::clangd::DidChangeTextDocumentParams::textDocument
VersionedTextDocumentIdentifier textDocument
The document that did change.
Definition: Protocol.h:712
clang::clangd::TypeHierarchyParams::direction
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition: Protocol.h:1368
clang::clangd::TextDocumentPositionParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1113
clang::clangd::DidSaveTextDocumentParams::textDocument
TextDocumentIdentifier textDocument
The document that was saved.
Definition: Protocol.h:690
clang::clangd::InlayHintKind::ParameterHint
@ ParameterHint
The hint corresponds to parameter information.
clang::clangd::WorkspaceSymbolParams
The parameters of a Workspace Symbol Request.
Definition: Protocol.h:1087
clang::clangd::CompletionParams
Definition: Protocol.h:1141
clang::clangd::ClangdCompileCommand::compilationCommand
std::vector< std::string > compilationCommand
Definition: Protocol.h:500
clang::clangd::Range
Definition: Protocol.h:182
clang::clangd::FileEvent::type
FileChangeType type
The change type.
Definition: Protocol.h:747
clang::clangd::SignatureHelp
Represents the signature of a callable.
Definition: Protocol.h:1296
clang::clangd::FileChangeType
FileChangeType
Definition: Protocol.h:732
clang::clangd::SemanticTokens
A versioned set of tokens.
Definition: Protocol.h:1600
clang::clangd::VersionedTextDocumentIdentifier::version
llvm::Optional< std::int64_t > version
The version number of this document.
Definition: Protocol.h:147
C
const Criteria C
Definition: FunctionCognitiveComplexityCheck.cpp:93
clang::clangd::ShowMessageParams::message
std::string message
The actual message.
Definition: Protocol.h:670
clang::clangd::Diagnostic::message
std::string message
The diagnostic's message.
Definition: Protocol.h:850
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:1104
clang::clangd::Diagnostic::severity
int severity
The diagnostic's severity.
Definition: Protocol.h:840
clang::clangd::ParameterInformation::labelString
std::string labelString
The label of this parameter. Ignored when labelOffsets is set.
Definition: Protocol.h:1266
clang::clangd::InitializeParams::trace
llvm::Optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
Definition: Protocol.h:562
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:898
clang::clangd::WorkDoneProgressReport::percentage
llvm::Optional< unsigned > percentage
Optional progress percentage to display (value 100 is considered 100%).
Definition: Protocol.h:640
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:1719
clang::clangd::CodeAction::REFACTOR_KIND
const static llvm::StringLiteral REFACTOR_KIND
Definition: Protocol.h:985
clang::clangd::DidSaveTextDocumentParams
Definition: Protocol.h:688
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:1404
clang::clangd::CallHierarchyItem::range
Range range
The range enclosing this symbol not including leading / trailing whitespace but everything else,...
Definition: Protocol.h:1459
clang::clangd::OffsetEncoding
OffsetEncoding
Definition: Protocol.h:376
clang::clangd::TextDocumentContentChangeEvent::range
llvm::Optional< Range > range
The range of the document that changed.
Definition: Protocol.h:697
clang::clangd::FileStatus
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
Definition: Protocol.h:1571
clang::clangd::TextDocumentContentChangeEvent
Definition: Protocol.h:695
clang::clangd::WorkspaceSymbolParams::query
std::string query
A query string to filter symbols by.
Definition: Protocol.h:1090
clang::clangd::DocumentSymbol::deprecated
bool deprecated
Indicates if this symbol is deprecated.
Definition: Protocol.h:1022
clang::clangd::ClientCapabilities::TheiaSemanticHighlighting
bool TheiaSemanticHighlighting
Client supports Theia semantic highlighting extension.
Definition: Protocol.h:461
clang::clangd::CodeActionParams
Definition: Protocol.h:919
clang::clangd::operator<
bool operator<(const Ref &L, const Ref &R)
Definition: Ref.h:97
clang::clangd::TextDocumentPositionParams
Definition: Protocol.h:1111
clang::clangd::InitializeParams::rootPath
llvm::Optional< std::string > rootPath
The rootPath of the workspace.
Definition: Protocol.h:546
clang::clangd::InitializationOptions
Clangd extension: parameters configurable at initialize time.
Definition: Protocol.h:518
clang::clangd::DidCloseTextDocumentParams::textDocument
TextDocumentIdentifier textDocument
The document that was closed.
Definition: Protocol.h:683
clang::clangd::CallHierarchyItem
Represents programming constructs like functions or constructors in the context of call hierarchy.
Definition: Protocol.h:1441
clang::clangd::Diagnostic::code
std::string code
The diagnostic's code. Can be omitted.
Definition: Protocol.h:843
clang::clangd::SymbolKind::EnumMember
@ EnumMember
clang::clangd::RenameParams::textDocument
TextDocumentIdentifier textDocument
The document that was opened.
Definition: Protocol.h:1318
clang::clangd::DocumentOnTypeFormattingParams
Definition: Protocol.h:782
clang::clangd::TextEdit
Definition: Protocol.h:228
clang::clangd::SignatureHelp::activeParameter
int activeParameter
The active parameter of the active signature.
Definition: Protocol.h:1305
clang::clangd::OffsetEncoding::UnsupportedEncoding
@ UnsupportedEncoding
clang::clangd::SymbolInformation::containerName
std::string containerName
The name of the symbol containing this symbol.
Definition: Protocol.h:1053
clang::clangd::RenameParams
Definition: Protocol.h:1316
clang::clangd::ApplyWorkspaceEditParams
Definition: Protocol.h:1099
clang::clangd::CompletionParams::limit
llvm::Optional< int > limit
Max results to return, overriding global default.
Definition: Protocol.h:1146
clang::clangd::TraceLevel::Off
@ Off
clang::clangd::SymbolKind::Namespace
@ Namespace
clang::clangd::operator==
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
Definition: Headers.cpp:294
clang::clangd::ClientCapabilities::ImplicitProgressCreation
bool ImplicitProgressCreation
The client supports implicit $/progress work-done progress streams, without a preceding window/workDo...
Definition: Protocol.h:482
clang::clangd::DidOpenTextDocumentParams
Definition: Protocol.h:674
clang::clangd::TraceLevel::Verbose
@ Verbose
clang::clangd::DocumentSymbol::name
std::string name
The name of this symbol.
Definition: Protocol.h:1013
clang::clangd::CompletionItemKind::Missing
@ Missing
clang::clangd::DocumentHighlightKind::Read
@ Read
clang::clangd::CompletionParams::context
CompletionContext context
Definition: Protocol.h:1142
clang::clangd::ClientCapabilities::SemanticTokens
bool SemanticTokens
Client advertises support for the semanticTokens feature.
Definition: Protocol.h:456
clang::clangd::ReferenceParams
Definition: Protocol.h:1564
clang::clangd::InlayHintKind
InlayHintKind
A set of predefined hint kinds.
Definition: Protocol.h:1518
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:1779
clang::clangd::ParameterInformation
A single parameter of a particular signature.
Definition: Protocol.h:1263
clang::clangd::DocumentLinkParams::textDocument
TextDocumentIdentifier textDocument
The document to provide document links for.
Definition: Protocol.h:1679
clang::clangd::LSPError::ID
static char ID
Definition: Protocol.h:67
clang::clangd::InlayHintsParams::textDocument
TextDocumentIdentifier textDocument
The text document for which inlay hints are requested.
Definition: Protocol.h:1513
clang::clangd::TextEdit::newText
std::string newText
The string to be inserted.
Definition: Protocol.h:235
ns1::ns2::B
@ B
Definition: CategoricalFeature.h:3
clang::clangd::SymbolInformation::location
Location location
The location of this symbol.
Definition: Protocol.h:1050
Out
CompiledFragmentImpl & Out
Definition: ConfigCompile.cpp:100
clang::clangd::ClientCapabilities::CancelsStaleRequests
bool CancelsStaleRequests
Whether the client claims to cancel stale requests.
Definition: Protocol.h:486
clang::clangd::SemanticTokensDeltaParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1624
clang::clangd::elog
void elog(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:62
clang::clangd::MarkupContent
Definition: Protocol.h:1150
clang::clangd::ASTNode::children
std::vector< ASTNode > children
Nodes nested within this one, such as the operands of a BinaryOperator.
Definition: Protocol.h:1784
clang::clangd::InitializeParams::rootUri
llvm::Optional< URIForFile > rootUri
The rootUri of the workspace.
Definition: Protocol.h:551
clang::clangd::DiagnosticRelatedInformation
Represents a related message and source code location for a diagnostic.
Definition: Protocol.h:812
clang::clangd::ResolveTypeHierarchyItemParams::direction
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition: Protocol.h:1428
clang::clangd::CompletionContext
Definition: Protocol.h:1132
clang::clangd::TextDocumentContentChangeEvent::text
std::string text
The new text of the range/document.
Definition: Protocol.h:703
clang::clangd::ASTParams::textDocument
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:1753
Tag
HTMLTag Tag
Definition: HTMLGenerator.cpp:90
clang::clangd::CallHierarchyOutgoingCallsParams
The parameter of a callHierarchy/outgoingCalls request.
Definition: Protocol.h:1492
clang::clangd::CompletionItemKind::TypeParameter
@ TypeParameter
clang::clangd::ASTNode
Simplified description of a clang AST node.
Definition: Protocol.h:1764
clang::clangd::CompletionItemKindMin
constexpr auto CompletionItemKindMin
Definition: Protocol.h:321
clang::clangd::ResolveTypeHierarchyItemParams::item
TypeHierarchyItem item
The item to resolve.
Definition: Protocol.h:1422
clang::clangd::ApplyWorkspaceEditParams::edit
WorkspaceEdit edit
Definition: Protocol.h:1100
clang::clangd::TextEdit::range
Range range
The range of the text document to be manipulated.
Definition: Protocol.h:231
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:666
clang::clangd::CodeAction::INFO_KIND
const static llvm::StringLiteral INFO_KIND
Definition: Protocol.h:986
clang::clangd::SymbolKind::Constructor
@ Constructor
clang::clangd::CodeActionContext
Definition: Protocol.h:902
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:1047
clang::clangd::ClientCapabilities::HasSignatureHelp
bool HasSignatureHelp
Client supports signature help.
Definition: Protocol.h:435
clang::clangd::VersionedTextDocumentIdentifier
Definition: Protocol.h:136
clang::clangd::WorkDoneProgressBegin::title
std::string title
Mandatory title of the progress operation.
Definition: Protocol.h:592
clang::clangd::CodeActionParams::range
Range range
The range for which the command was invoked.
Definition: Protocol.h:924
clang::clangd::SymbolKind::String
@ String
clang::clangd::DiagnosticRelatedInformation::message
std::string message
The message of this related diagnostic information.
Definition: Protocol.h:816
Value
static constexpr bool Value
Definition: SuspiciousCallArgumentCheck.cpp:72
clang::clangd::CallHierarchyItem::name
std::string name
The name of this item.
Definition: Protocol.h:1443
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:1413
clang::clangd::RenameParams::newName
std::string newName
The new name of the symbol.
Definition: Protocol.h:1324
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:1511
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:700
clang::clangd::CallHierarchyItem::kind
SymbolKind kind
The kind of this item.
Definition: Protocol.h:1446
clang::clangd::CodeAction::QUICKFIX_KIND
const static llvm::StringLiteral QUICKFIX_KIND
Definition: Protocol.h:984
clang::clangd::ResolveTypeHierarchyItemParams
Parameters for the typeHierarchy/resolve request.
Definition: Protocol.h:1420
clang::clangd::WorkDoneProgressCreateParams
Definition: Protocol.h:569