clang-tools 10.0.0

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