clang-tools  7.0.0
Protocol.cpp
Go to the documentation of this file.
1 //===--- Protocol.cpp - Language Server Protocol Implementation -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the serialization code for the LSP structs.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "Protocol.h"
15 #include "Logger.h"
16 #include "URI.h"
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/SmallString.h"
19 #include "llvm/Support/Format.h"
20 #include "llvm/Support/FormatVariadic.h"
21 #include "llvm/Support/Path.h"
22 #include "llvm/Support/raw_ostream.h"
23 
24 namespace clang {
25 namespace clangd {
26 using namespace llvm;
27 
28 URIForFile::URIForFile(std::string AbsPath) {
29  assert(llvm::sys::path::is_absolute(AbsPath) && "the path is relative");
30  File = std::move(AbsPath);
31 }
32 
33 bool fromJSON(const json::Value &E, URIForFile &R) {
34  if (auto S = E.getAsString()) {
35  auto U = URI::parse(*S);
36  if (!U) {
37  elog("Failed to parse URI {0}: {1}", *S, U.takeError());
38  return false;
39  }
40  if (U->scheme() != "file" && U->scheme() != "test") {
41  elog("Clangd only supports 'file' URI scheme for workspace files: {0}",
42  *S);
43  return false;
44  }
45  auto Path = URI::resolve(*U);
46  if (!Path) {
47  log("{0}", Path.takeError());
48  return false;
49  }
50  R = URIForFile(*Path);
51  return true;
52  }
53  return false;
54 }
55 
56 json::Value toJSON(const URIForFile &U) { return U.uri(); }
57 
58 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URIForFile &U) {
59  return OS << U.uri();
60 }
61 
63  return json::Object{{"uri", R.uri}};
64 }
65 
66 bool fromJSON(const json::Value &Params, TextDocumentIdentifier &R) {
67  json::ObjectMapper O(Params);
68  return O && O.map("uri", R.uri);
69 }
70 
71 bool fromJSON(const json::Value &Params, Position &R) {
72  json::ObjectMapper O(Params);
73  return O && O.map("line", R.line) && O.map("character", R.character);
74 }
75 
77  return json::Object{
78  {"line", P.line},
79  {"character", P.character},
80  };
81 }
82 
83 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Position &P) {
84  return OS << P.line << ':' << P.character;
85 }
86 
87 bool fromJSON(const json::Value &Params, Range &R) {
88  json::ObjectMapper O(Params);
89  return O && O.map("start", R.start) && O.map("end", R.end);
90 }
91 
93  return json::Object{
94  {"start", P.start},
95  {"end", P.end},
96  };
97 }
98 
99 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Range &R) {
100  return OS << R.start << '-' << R.end;
101 }
102 
104  return json::Object{
105  {"uri", P.uri},
106  {"range", P.range},
107  };
108 }
109 
110 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Location &L) {
111  return OS << L.range << '@' << L.uri;
112 }
113 
114 bool fromJSON(const json::Value &Params, TextDocumentItem &R) {
115  json::ObjectMapper O(Params);
116  return O && O.map("uri", R.uri) && O.map("languageId", R.languageId) &&
117  O.map("version", R.version) && O.map("text", R.text);
118 }
119 
120 bool fromJSON(const json::Value &Params, Metadata &R) {
121  json::ObjectMapper O(Params);
122  if (!O)
123  return false;
124  O.map("extraFlags", R.extraFlags);
125  return true;
126 }
127 
128 bool fromJSON(const json::Value &Params, TextEdit &R) {
129  json::ObjectMapper O(Params);
130  return O && O.map("range", R.range) && O.map("newText", R.newText);
131 }
132 
134  return json::Object{
135  {"range", P.range},
136  {"newText", P.newText},
137  };
138 }
139 
140 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TextEdit &TE) {
141  OS << TE.range << " => \"";
142  printEscapedString(TE.newText, OS);
143  return OS << '"';
144 }
145 
146 bool fromJSON(const json::Value &E, TraceLevel &Out) {
147  if (auto S = E.getAsString()) {
148  if (*S == "off") {
149  Out = TraceLevel::Off;
150  return true;
151  } else if (*S == "messages") {
152  Out = TraceLevel::Messages;
153  return true;
154  } else if (*S == "verbose") {
155  Out = TraceLevel::Verbose;
156  return true;
157  }
158  }
159  return false;
160 }
161 
163  json::ObjectMapper O(Params);
164  if (!O)
165  return false;
166  O.map("snippetSupport", R.snippetSupport);
167  O.map("commitCharacterSupport", R.commitCharacterSupport);
168  return true;
169 }
170 
172  json::ObjectMapper O(Params);
173  if (!O)
174  return false;
175  O.map("dynamicRegistration", R.dynamicRegistration);
176  O.map("completionItem", R.completionItem);
177  O.map("contextSupport", R.contextSupport);
178  return true;
179 }
180 
181 bool fromJSON(const json::Value &E, SymbolKind &Out) {
182  if (auto T = E.getAsInteger()) {
183  if (*T < static_cast<int>(SymbolKind::File) ||
184  *T > static_cast<int>(SymbolKind::TypeParameter))
185  return false;
186  Out = static_cast<SymbolKind>(*T);
187  return true;
188  }
189  return false;
190 }
191 
192 bool fromJSON(const json::Value &E, std::vector<SymbolKind> &Out) {
193  if (auto *A = E.getAsArray()) {
194  Out.clear();
195  for (size_t I = 0; I < A->size(); ++I) {
196  SymbolKind KindOut;
197  if (fromJSON((*A)[I], KindOut))
198  Out.push_back(KindOut);
199  }
200  return true;
201  }
202  return false;
203 }
204 
205 bool fromJSON(const json::Value &Params, SymbolKindCapabilities &R) {
206  json::ObjectMapper O(Params);
207  return O && O.map("valueSet", R.valueSet);
208 }
209 
211  SymbolKindBitset &SupportedSymbolKinds) {
212  auto KindVal = static_cast<size_t>(Kind);
213  if (KindVal >= SymbolKindMin && KindVal <= SupportedSymbolKinds.size() &&
214  SupportedSymbolKinds[KindVal])
215  return Kind;
216 
217  switch (Kind) {
218  // Provide some fall backs for common kinds that are close enough.
219  case SymbolKind::Struct:
220  return SymbolKind::Class;
222  return SymbolKind::Enum;
223  default:
224  return SymbolKind::String;
225  }
226 }
227 
229  json::ObjectMapper O(Params);
230  return O && O.map("symbolKind", R.symbolKind);
231 }
232 
234  json::ObjectMapper O(Params);
235  return O && O.map("symbol", R.symbol);
236 }
237 
239  json::ObjectMapper O(Params);
240  if (!O)
241  return false;
242  O.map("completion", R.completion);
243  return true;
244 }
245 
246 bool fromJSON(const json::Value &Params, ClientCapabilities &R) {
247  json::ObjectMapper O(Params);
248  if (!O)
249  return false;
250  O.map("textDocument", R.textDocument);
251  O.map("workspace", R.workspace);
252  return true;
253 }
254 
255 bool fromJSON(const json::Value &Params, InitializeParams &R) {
256  json::ObjectMapper O(Params);
257  if (!O)
258  return false;
259  // We deliberately don't fail if we can't parse individual fields.
260  // Failing to handle a slightly malformed initialize would be a disaster.
261  O.map("processId", R.processId);
262  O.map("rootUri", R.rootUri);
263  O.map("rootPath", R.rootPath);
264  O.map("capabilities", R.capabilities);
265  O.map("trace", R.trace);
266  O.map("initializationOptions", R.initializationOptions);
267  return true;
268 }
269 
271  json::ObjectMapper O(Params);
272  return O && O.map("textDocument", R.textDocument) &&
273  O.map("metadata", R.metadata);
274 }
275 
277  json::ObjectMapper O(Params);
278  return O && O.map("textDocument", R.textDocument);
279 }
280 
282  json::ObjectMapper O(Params);
283  return O && O.map("textDocument", R.textDocument) &&
284  O.map("contentChanges", R.contentChanges) &&
285  O.map("wantDiagnostics", R.wantDiagnostics);
286 }
287 
288 bool fromJSON(const json::Value &E, FileChangeType &Out) {
289  if (auto T = E.getAsInteger()) {
290  if (*T < static_cast<int>(FileChangeType::Created) ||
291  *T > static_cast<int>(FileChangeType::Deleted))
292  return false;
293  Out = static_cast<FileChangeType>(*T);
294  return true;
295  }
296  return false;
297 }
298 
299 bool fromJSON(const json::Value &Params, FileEvent &R) {
300  json::ObjectMapper O(Params);
301  return O && O.map("uri", R.uri) && O.map("type", R.type);
302 }
303 
305  json::ObjectMapper O(Params);
306  return O && O.map("changes", R.changes);
307 }
308 
310  json::ObjectMapper O(Params);
311  return O && O.map("range", R.range) && O.map("rangeLength", R.rangeLength) &&
312  O.map("text", R.text);
313 }
314 
315 bool fromJSON(const json::Value &Params, FormattingOptions &R) {
316  json::ObjectMapper O(Params);
317  return O && O.map("tabSize", R.tabSize) &&
318  O.map("insertSpaces", R.insertSpaces);
319 }
320 
322  return json::Object{
323  {"tabSize", P.tabSize},
324  {"insertSpaces", P.insertSpaces},
325  };
326 }
327 
329  json::ObjectMapper O(Params);
330  return O && O.map("textDocument", R.textDocument) &&
331  O.map("range", R.range) && O.map("options", R.options);
332 }
333 
335  json::ObjectMapper O(Params);
336  return O && O.map("textDocument", R.textDocument) &&
337  O.map("position", R.position) && O.map("ch", R.ch) &&
338  O.map("options", R.options);
339 }
340 
342  json::ObjectMapper O(Params);
343  return O && O.map("textDocument", R.textDocument) &&
344  O.map("options", R.options);
345 }
346 
347 bool fromJSON(const json::Value &Params, DocumentSymbolParams &R) {
348  json::ObjectMapper O(Params);
349  return O && O.map("textDocument", R.textDocument);
350 }
351 
352 bool fromJSON(const json::Value &Params, Diagnostic &R) {
353  json::ObjectMapper O(Params);
354  if (!O || !O.map("range", R.range) || !O.map("message", R.message))
355  return false;
356  O.map("severity", R.severity);
357  return true;
358 }
359 
360 bool fromJSON(const json::Value &Params, CodeActionContext &R) {
361  json::ObjectMapper O(Params);
362  return O && O.map("diagnostics", R.diagnostics);
363 }
364 
365 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diagnostic &D) {
366  OS << D.range << " [";
367  switch (D.severity) {
368  case 1:
369  OS << "error";
370  break;
371  case 2:
372  OS << "warning";
373  break;
374  case 3:
375  OS << "note";
376  break;
377  case 4:
378  OS << "remark";
379  break;
380  default:
381  OS << "diagnostic";
382  break;
383  }
384  return OS << '(' << D.severity << "): " << D.message << "]";
385 }
386 
387 bool fromJSON(const json::Value &Params, CodeActionParams &R) {
388  json::ObjectMapper O(Params);
389  return O && O.map("textDocument", R.textDocument) &&
390  O.map("range", R.range) && O.map("context", R.context);
391 }
392 
393 bool fromJSON(const json::Value &Params, WorkspaceEdit &R) {
394  json::ObjectMapper O(Params);
395  return O && O.map("changes", R.changes);
396 }
397 
398 const llvm::StringLiteral ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND =
399  "clangd.applyFix";
400 bool fromJSON(const json::Value &Params, ExecuteCommandParams &R) {
401  json::ObjectMapper O(Params);
402  if (!O || !O.map("command", R.command))
403  return false;
404 
405  auto Args = Params.getAsObject()->getArray("arguments");
406  if (R.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND) {
407  return Args && Args->size() == 1 &&
408  fromJSON(Args->front(), R.workspaceEdit);
409  }
410  return false; // Unrecognized command.
411 }
412 
414  return json::Object{
415  {"name", P.name},
416  {"kind", static_cast<int>(P.kind)},
417  {"location", P.location},
418  {"containerName", P.containerName},
419  };
420 }
421 
422 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
423  const SymbolInformation &SI) {
424  O << SI.containerName << "::" << SI.name << " - " << toJSON(SI);
425  return O;
426 }
427 
428 bool fromJSON(const json::Value &Params, WorkspaceSymbolParams &R) {
429  json::ObjectMapper O(Params);
430  return O && O.map("query", R.query);
431 }
432 
434  auto Cmd = json::Object{{"title", C.title}, {"command", C.command}};
435  if (C.workspaceEdit)
436  Cmd["arguments"] = {*C.workspaceEdit};
437  return std::move(Cmd);
438 }
439 
441  if (!WE.changes)
442  return json::Object{};
443  json::Object FileChanges;
444  for (auto &Change : *WE.changes)
445  FileChanges[Change.first] = json::Array(Change.second);
446  return json::Object{{"changes", std::move(FileChanges)}};
447 }
448 
450  return json::Object{{"edit", Params.edit}};
451 }
452 
454  json::ObjectMapper O(Params);
455  return O && O.map("textDocument", R.textDocument) &&
456  O.map("position", R.position);
457 }
458 
459 static StringRef toTextKind(MarkupKind Kind) {
460  switch (Kind) {
462  return "plaintext";
464  return "markdown";
465  }
466  llvm_unreachable("Invalid MarkupKind");
467 }
468 
470  if (MC.value.empty())
471  return nullptr;
472 
473  return json::Object{
474  {"kind", toTextKind(MC.kind)},
475  {"value", MC.value},
476  };
477 }
478 
480  json::Object Result{{"contents", toJSON(H.contents)}};
481 
482  if (H.range.hasValue())
483  Result["range"] = toJSON(*H.range);
484 
485  return std::move(Result);
486 }
487 
489  assert(!CI.label.empty() && "completion item label is required");
490  json::Object Result{{"label", CI.label}};
492  Result["kind"] = static_cast<int>(CI.kind);
493  if (!CI.detail.empty())
494  Result["detail"] = CI.detail;
495  if (!CI.documentation.empty())
496  Result["documentation"] = CI.documentation;
497  if (!CI.sortText.empty())
498  Result["sortText"] = CI.sortText;
499  if (!CI.filterText.empty())
500  Result["filterText"] = CI.filterText;
501  if (!CI.insertText.empty())
502  Result["insertText"] = CI.insertText;
504  Result["insertTextFormat"] = static_cast<int>(CI.insertTextFormat);
505  if (CI.textEdit)
506  Result["textEdit"] = *CI.textEdit;
507  if (!CI.additionalTextEdits.empty())
508  Result["additionalTextEdits"] = json::Array(CI.additionalTextEdits);
509  return std::move(Result);
510 }
511 
512 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const CompletionItem &I) {
513  O << I.label << " - " << toJSON(I);
514  return O;
515 }
516 
517 bool operator<(const CompletionItem &L, const CompletionItem &R) {
518  return (L.sortText.empty() ? L.label : L.sortText) <
519  (R.sortText.empty() ? R.label : R.sortText);
520 }
521 
523  return json::Object{
524  {"isIncomplete", L.isIncomplete},
525  {"items", json::Array(L.items)},
526  };
527 }
528 
530  assert(!PI.label.empty() && "parameter information label is required");
531  json::Object Result{{"label", PI.label}};
532  if (!PI.documentation.empty())
533  Result["documentation"] = PI.documentation;
534  return std::move(Result);
535 }
536 
538  assert(!SI.label.empty() && "signature information label is required");
539  json::Object Result{
540  {"label", SI.label},
541  {"parameters", json::Array(SI.parameters)},
542  };
543  if (!SI.documentation.empty())
544  Result["documentation"] = SI.documentation;
545  return std::move(Result);
546 }
547 
548 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
549  const SignatureInformation &I) {
550  O << I.label << " - " << toJSON(I);
551  return O;
552 }
553 
555  assert(SH.activeSignature >= 0 &&
556  "Unexpected negative value for number of active signatures.");
557  assert(SH.activeParameter >= 0 &&
558  "Unexpected negative value for active parameter index");
559  return json::Object{
560  {"activeSignature", SH.activeSignature},
561  {"activeParameter", SH.activeParameter},
562  {"signatures", json::Array(SH.signatures)},
563  };
564 }
565 
566 bool fromJSON(const json::Value &Params, RenameParams &R) {
567  json::ObjectMapper O(Params);
568  return O && O.map("textDocument", R.textDocument) &&
569  O.map("position", R.position) && O.map("newName", R.newName);
570 }
571 
573  return json::Object{
574  {"range", toJSON(DH.range)},
575  {"kind", static_cast<int>(DH.kind)},
576  };
577 }
578 
579 llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
580  const DocumentHighlight &V) {
581  O << V.range;
583  O << "(r)";
585  O << "(w)";
586  return O;
587 }
588 
590  json::ObjectMapper O(Params);
591  return O && O.map("settings", CCP.settings);
592 }
593 
594 bool fromJSON(const json::Value &Params,
596  json::ObjectMapper O(Params);
597  return O && O.map("compilationDatabasePath", CCPC.compilationDatabasePath);
598 }
599 
600 } // namespace clangd
601 } // namespace clang
std::string insertText
A string that should be inserted to a document when selecting this completion.
Definition: Protocol.h:710
Range range
The range to format.
Definition: Protocol.h:458
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:482
URIForFile uri
The file&#39;s URI.
Definition: Protocol.h:424
CompletionClientCapabilities completion
Capabilities specific to the textDocument/completion
Definition: Protocol.h:311
static StringRef toTextKind(MarkupKind Kind)
Definition: Protocol.cpp:459
Location location
The location of this symbol.
Definition: Protocol.h:593
llvm::Optional< TextEdit > textEdit
An edit which is applied to a document when selecting this completion.
Definition: Protocol.h:721
Exact commands are not specified in the protocol so we define the ones supported by Clangd here...
Definition: Protocol.h:565
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:467
Some operations such as code completion produce a set of candidates.
llvm::Optional< URIForFile > rootUri
The rootUri of the workspace.
Definition: Protocol.h:351
Position start
The range&#39;s start position.
Definition: Protocol.h:120
llvm::Optional< SymbolKindCapabilities > symbolKind
Capabilities SymbolKind.
Definition: Protocol.h:295
Represents a collection of completion items to be presented in the editor.
Definition: Protocol.h:740
Range range
The range this highlight applies to.
Definition: Protocol.h:811
std::string label
The label of this parameter. Mandatory.
Definition: Protocol.h:754
llvm::Optional< bool > wantDiagnostics
Forces diagnostics to be generated, or to not be generated, for this version of the file...
Definition: Protocol.h:408
Range range
The range for which the command was invoked.
Definition: Protocol.h:540
CodeActionContext context
Context carrying additional information.
Definition: Protocol.h:543
static const llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND
Definition: Protocol.h:567
CompletionItemKind kind
The kind of this completion item.
Definition: Protocol.h:691
Clangd extension to set clangd-specific "initializationOptions" in the "initialize" request and for t...
Definition: Protocol.h:328
std::string ch
The character that has been typed.
Definition: Protocol.h:473
llvm::Optional< WorkspaceSymbolCapabilities > symbol
Capabilities specific to workspace/symbol.
Definition: Protocol.h:303
std::vector< CompletionItem > items
The completion items.
Definition: Protocol.h:746
std::vector< std::string > extraFlags
Definition: Protocol.h:162
bool snippetSupport
Client supports snippets as insert text.
Definition: Protocol.h:222
llvm::Optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
Definition: Protocol.h:549
llvm::Optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover, e.g.
Definition: Protocol.h:639
TextDocumentIdentifier textDocument
The document that was closed.
Definition: Protocol.h:379
llvm::Optional< ClangdInitializationOptions > initializationOptions
Definition: Protocol.h:364
std::string label
The label of this signature. Mandatory.
Definition: Protocol.h:765
URIForFile uri
The text document&#39;s URI.
Definition: Protocol.h:143
std::string text
The new text of the range/document.
Definition: Protocol.h:391
llvm::Optional< WorkspaceClientCapabilities > workspace
Definition: Protocol.h:317
constexpr auto SymbolKindMin
Definition: Protocol.h:276
std::string sortText
A string that should be used when comparing this item with other items.
Definition: Protocol.h:702
std::string title
Definition: Protocol.h:578
std::vector< ParameterInformation > parameters
The parameters of this signature.
Definition: Protocol.h:771
bool isIncomplete
The list is not complete.
Definition: Protocol.h:743
llvm::Optional< Metadata > metadata
Extension storing per-file metadata, such as compilation flags.
Definition: Protocol.h:373
std::string documentation
A human-readable string that represents a doc-comment.
Definition: Protocol.h:698
FormattingOptions options
The format options.
Definition: Protocol.h:476
std::vector< TextEdit > additionalTextEdits
An optional array of additional text edits that are applied when selecting this completion.
Definition: Protocol.h:726
void elog(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:56
int tabSize
Size of a tab in spaces.
Definition: Protocol.h:445
llvm::Optional< int > processId
The process Id of the parent process that started the server.
Definition: Protocol.h:340
bool contextSupport
The client supports to send additional context information for a textDocument/completion request...
Definition: Protocol.h:242
std::string uri() const
Definition: Protocol.h:60
BindArgumentKind Kind
MarkupContent contents
The hover&#39;s content.
Definition: Protocol.h:635
A document highlight is a range inside a text document which deserves special attention.
Definition: Protocol.h:809
TextDocumentClientCapabilities textDocument
Definition: Protocol.h:320
URIForFile uri
The text document&#39;s URI.
Definition: Protocol.h:181
std::string detail
A human-readable string with additional information about this item, like type or symbol information...
Definition: Protocol.h:695
TextDocumentIdentifier textDocument
The document that was opened.
Definition: Protocol.h:793
std::string newText
The string to be inserted.
Definition: Protocol.h:173
std::string newName
The new name of the symbol.
Definition: Protocol.h:799
Represents the signature of something callable.
Definition: Protocol.h:762
std::string command
The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND.
Definition: Protocol.h:570
TextDocumentIdentifier textDocument
Definition: Protocol.h:491
std::string filterText
A string that should be used when filtering a set of completion items.
Definition: Protocol.h:706
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Definition: Protocol.h:537
Range range
The range of the text document to be manipulated.
Definition: Protocol.h:169
CompletionItemClientCapabilities completionItem
The client supports the following CompletionItem specific capabilities.
Definition: Protocol.h:236
int activeSignature
The active signature.
Definition: Protocol.h:784
void log(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:62
int activeParameter
The active parameter of the active signature.
Definition: Protocol.h:787
llvm::Optional< Range > range
The range of the document that changed.
Definition: Protocol.h:385
std::string Path
A typedef to represent a file path.
Definition: Path.h:21
Position position
The position inside the text document.
Definition: Protocol.h:618
std::string documentation
The documentation of this parameter. Optional.
Definition: Protocol.h:757
SymbolKind kind
The kind of this symbol.
Definition: Protocol.h:590
std::vector< SignatureInformation > signatures
The resulting signatures.
Definition: Protocol.h:781
llvm::Optional< int > rangeLength
The length of the range that got replaced.
Definition: Protocol.h:388
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
Definition: Protocol.h:357
TextDocumentItem textDocument
The document that was opened.
Definition: Protocol.h:370
TextDocumentIdentifier textDocument
The document that did change.
Definition: Protocol.h:399
std::vector< FileEvent > changes
The actual file events.
Definition: Protocol.h:432
FormattingOptions options
The format options.
Definition: Protocol.h:461
bool commitCharacterSupport
Client supports commit characters on a completion item.
Definition: Protocol.h:224
std::string languageId
The text document&#39;s language identifier.
Definition: Protocol.h:184
llvm::Optional< std::string > rootPath
The rootPath of the workspace.
Definition: Protocol.h:346
Position position
The position at which this request was sent.
Definition: Protocol.h:470
A single parameter of a particular signature.
Definition: Protocol.h:751
FormattingOptions options
The format options.
Definition: Protocol.h:485
int line
Line position in a document (zero-based).
Definition: Protocol.h:91
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
Definition: Protocol.h:402
int character
Character offset on a line in a document (zero-based).
Definition: Protocol.h:96
llvm::Optional< std::vector< SymbolKind > > valueSet
The SymbolKinds that the client supports.
Definition: Protocol.h:286
Represents the signature of a callable.
Definition: Protocol.h:778
std::string query
A non-empty query string.
Definition: Protocol.h:604
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::bitset< SymbolKindMax+1 > SymbolKindBitset
Definition: Protocol.h:278
SymbolKind
A symbol kind.
Definition: Protocol.h:247
std::string message
The diagnostic&#39;s code.
Definition: Protocol.h:513
TextDocumentIdentifier textDocument
The text document.
Definition: Protocol.h:615
json::Value toJSON(const URIForFile &U)
Serialize/deserialize URIForFile to/from a string URI.
Definition: Protocol.cpp:56
std::string label
The label of this completion item.
Definition: Protocol.h:687
bool dynamicRegistration
Whether completion supports dynamic registration.
Definition: Protocol.h:234
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
Definition: Protocol.h:814
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
Definition: Protocol.cpp:210
std::vector< Diagnostic > diagnostics
An array of diagnostics.
Definition: Protocol.h:531
int severity
The diagnostic&#39;s severity.
Definition: Protocol.h:501
The parameters of a Workspace Symbol Request.
Definition: Protocol.h:602
FileChangeType type
The change type.
Definition: Protocol.h:426
std::string text
The content of the opened text document.
Definition: Protocol.h:190
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
Resolves the absolute path of U.
Definition: URI.cpp:191
std::string containerName
The name of the symbol containing this symbol.
Definition: Protocol.h:596
Position position
The position at which this request was sent.
Definition: Protocol.h:796
URIForFile uri
The text document&#39;s URI.
Definition: Protocol.h:84
static llvm::Expected< URI > parse(llvm::StringRef Uri)
Parse a URI string "<scheme>:[//<authority>/]<path>".
Definition: URI.cpp:156
Range range
The range at which the message applies.
Definition: Protocol.h:497
int version
The version number of this document (it will strictly increase after each.
Definition: Protocol.h:187
TextDocumentIdentifier textDocument
The document to format.
Definition: Protocol.h:455
Position end
The range&#39;s end position.
Definition: Protocol.h:123
llvm::Optional< WorkspaceEdit > workspaceEdit
Definition: Protocol.h:573
std::string name
The name of this symbol.
Definition: Protocol.h:587
InsertTextFormat insertTextFormat
The format of the insert text.
Definition: Protocol.h:714
ClangdConfigurationParamsChange settings
Definition: Protocol.h:439
bool operator<(const CompletionItem &L, const CompletionItem &R)
Definition: Protocol.cpp:517
bool fromJSON(const json::Value &E, URIForFile &R)
Definition: Protocol.cpp:33
llvm::Optional< std::string > compilationDatabasePath
Definition: Protocol.h:329
raw_ostream & operator<<(raw_ostream &OS, const CodeCompletion &C)
bool insertSpaces
Prefer spaces over tabs.
Definition: Protocol.h:448
llvm::Optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled (&#39;off&#39;).
Definition: Protocol.h:360
std::string documentation
The documentation of this signature. Optional.
Definition: Protocol.h:768
Represents information about programming constructs like variables, classes, interfaces etc...
Definition: Protocol.h:585