clang-tools 23.0.0git
Protocol.cpp
Go to the documentation of this file.
1//===--- Protocol.cpp - Language Server Protocol Implementation -----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the serialization code for the LSP structs.
10//
11//===----------------------------------------------------------------------===//
12
13#include "Protocol.h"
14#include "URI.h"
15#include "support/Logger.h"
16#include "clang/Basic/LLVM.h"
17#include "clang/Index/IndexSymbol.h"
18#include "llvm/ADT/StringExtras.h"
19#include "llvm/ADT/StringRef.h"
20#include "llvm/ADT/StringSwitch.h"
21#include "llvm/Support/ErrorHandling.h"
22#include "llvm/Support/JSON.h"
23#include "llvm/Support/Path.h"
24#include "llvm/Support/raw_ostream.h"
25
26namespace clang {
27namespace clangd {
28namespace {
29
30// Helper that doesn't treat `null` and absent fields as failures.
31template <typename T>
32bool mapOptOrNull(const llvm::json::Value &Params, llvm::StringLiteral Prop,
33 T &Out, llvm::json::Path P) {
34 auto *O = Params.getAsObject();
35 assert(O);
36 auto *V = O->get(Prop);
37 // Field is missing or null.
38 if (!V || V->getAsNull())
39 return true;
40 return fromJSON(*V, Out, P.field(Prop));
41}
42} // namespace
43
44char LSPError::ID;
45
46URIForFile URIForFile::canonicalize(llvm::StringRef AbsPath,
47 llvm::StringRef TUPath) {
48 assert(llvm::sys::path::is_absolute(AbsPath) && "the path is relative");
49 auto Resolved = URI::resolvePath(AbsPath, TUPath);
50 if (!Resolved) {
51 elog("URIForFile: failed to resolve path {0} with TU path {1}: "
52 "{2}.\nUsing unresolved path.",
53 AbsPath, TUPath, Resolved.takeError());
54 return URIForFile(std::string(AbsPath));
55 }
56 return URIForFile(std::move(*Resolved));
57}
58
59llvm::Expected<URIForFile> URIForFile::fromURI(const URI &U,
60 llvm::StringRef HintPath) {
61 auto Resolved = URI::resolve(U, HintPath);
62 if (!Resolved)
63 return Resolved.takeError();
64 return URIForFile(std::move(*Resolved));
65}
66
67bool fromJSON(const llvm::json::Value &E, URIForFile &R, llvm::json::Path P) {
68 if (auto S = E.getAsString()) {
69 auto Parsed = URI::parse(*S);
70 if (!Parsed) {
71 consumeError(Parsed.takeError());
72 P.report("failed to parse URI");
73 return false;
74 }
75 if (Parsed->scheme() != "file" && Parsed->scheme() != "test") {
76 P.report("clangd only supports 'file' URI scheme for workspace files");
77 return false;
78 }
79 // "file" and "test" schemes do not require hint path.
80 auto U = URIForFile::fromURI(*Parsed, /*HintPath=*/"");
81 if (!U) {
82 P.report("unresolvable URI");
83 consumeError(U.takeError());
84 return false;
85 }
86 R = std::move(*U);
87 return true;
88 }
89 return false;
90}
91
92llvm::json::Value toJSON(const URIForFile &U) { return U.uri(); }
93
94llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URIForFile &U) {
95 return OS << U.uri();
96}
97
98llvm::json::Value toJSON(const TextDocumentIdentifier &R) {
99 return llvm::json::Object{{"uri", R.uri}};
100}
101
102bool fromJSON(const llvm::json::Value &Params, TextDocumentIdentifier &R,
103 llvm::json::Path P) {
104 llvm::json::ObjectMapper O(Params, P);
105 return O && O.map("uri", R.uri);
106}
107
108llvm::json::Value toJSON(const VersionedTextDocumentIdentifier &R) {
109 auto Result = toJSON(static_cast<const TextDocumentIdentifier &>(R));
110 Result.getAsObject()->try_emplace("version", R.version);
111 return Result;
112}
113
114bool fromJSON(const llvm::json::Value &Params,
115 VersionedTextDocumentIdentifier &R, llvm::json::Path P) {
116 llvm::json::ObjectMapper O(Params, P);
117 return fromJSON(Params, static_cast<TextDocumentIdentifier &>(R), P) && O &&
118 O.map("version", R.version);
119}
120
121bool fromJSON(const llvm::json::Value &Params, Position &R,
122 llvm::json::Path P) {
123 llvm::json::ObjectMapper O(Params, P);
124 return O && O.map("line", R.line) && O.map("character", R.character);
125}
126
127llvm::json::Value toJSON(const Position &P) {
128 return llvm::json::Object{
129 {"line", P.line},
130 {"character", P.character},
131 };
132}
133
134llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Position &P) {
135 return OS << P.line << ':' << P.character;
136}
137
138bool fromJSON(const llvm::json::Value &Params, Range &R, llvm::json::Path P) {
139 llvm::json::ObjectMapper O(Params, P);
140 return O && O.map("start", R.start) && O.map("end", R.end);
141}
142
143llvm::json::Value toJSON(const Range &P) {
144 return llvm::json::Object{
145 {"start", P.start},
146 {"end", P.end},
147 };
148}
149
150llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Range &R) {
151 return OS << R.start << '-' << R.end;
152}
153
154llvm::json::Value toJSON(const Location &P) {
155 return llvm::json::Object{
156 {"uri", P.uri},
157 {"range", P.range},
158 };
159}
160
161llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Location &L) {
162 return OS << L.range << '@' << L.uri;
163}
164
165llvm::json::Value toJSON(const ReferenceLocation &P) {
166 llvm::json::Object Result{
167 {"uri", P.uri},
168 {"range", P.range},
169 };
170 if (P.containerName)
171 Result.insert({"containerName", P.containerName});
172 return Result;
173}
174
175llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
176 const ReferenceLocation &L) {
177 return OS << L.range << '@' << L.uri << " (container: " << L.containerName
178 << ")";
179}
180
181bool fromJSON(const llvm::json::Value &Params, TextDocumentItem &R,
182 llvm::json::Path P) {
183 llvm::json::ObjectMapper O(Params, P);
184 return O && O.map("uri", R.uri) && O.map("languageId", R.languageId) &&
185 O.map("version", R.version) && O.map("text", R.text);
186}
187
188bool fromJSON(const llvm::json::Value &Params, TextEdit &R,
189 llvm::json::Path P) {
190 llvm::json::ObjectMapper O(Params, P);
191 return O && O.map("range", R.range) && O.map("newText", R.newText) &&
192 O.mapOptional("annotationId", R.annotationId);
193}
194
195llvm::json::Value toJSON(const TextEdit &P) {
196 llvm::json::Object Result{
197 {"range", P.range},
198 {"newText", P.newText},
199 };
200 if (!P.annotationId.empty())
201 Result["annotationId"] = P.annotationId;
202 return Result;
203}
204
205llvm::json::Value toJSON(const InsertReplaceEdit &P) {
206 return llvm::json::Object{
207 {"newText", P.newText},
208 {"insert", P.insert},
209 {"replace", P.replace},
210 };
211}
212
213bool fromJSON(const llvm::json::Value &Params, ChangeAnnotation &R,
214 llvm::json::Path P) {
215 llvm::json::ObjectMapper O(Params, P);
216 return O && O.map("label", R.label) &&
217 O.map("needsConfirmation", R.needsConfirmation) &&
218 O.mapOptional("description", R.description);
219}
220llvm::json::Value toJSON(const ChangeAnnotation & CA) {
221 llvm::json::Object Result{{"label", CA.label}};
222 if (CA.needsConfirmation)
223 Result["needsConfirmation"] = *CA.needsConfirmation;
224 if (!CA.description.empty())
225 Result["description"] = CA.description;
226 return Result;
227}
228
229bool fromJSON(const llvm::json::Value &Params, TextDocumentEdit &R,
230 llvm::json::Path P) {
231 llvm::json::ObjectMapper O(Params, P);
232 return O && O.map("textDocument", R.textDocument) && O.map("edits", R.edits);
233}
234llvm::json::Value toJSON(const TextDocumentEdit &P) {
235 llvm::json::Object Result{{"textDocument", P.textDocument},
236 {"edits", P.edits}};
237 return Result;
238}
239
240llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TextEdit &TE) {
241 OS << TE.range << " => \"";
242 llvm::printEscapedString(TE.newText, OS);
243 return OS << '"';
244}
245
246bool fromJSON(const llvm::json::Value &E, TraceLevel &Out, llvm::json::Path P) {
247 if (auto S = E.getAsString()) {
248 if (*S == "off") {
249 Out = TraceLevel::Off;
250 return true;
251 }
252 if (*S == "messages") {
254 return true;
255 }
256 if (*S == "verbose") {
258 return true;
259 }
260 }
261 return false;
262}
263
264bool fromJSON(const llvm::json::Value &E, SymbolKind &Out, llvm::json::Path P) {
265 if (auto T = E.getAsInteger()) {
266 if (*T < static_cast<int>(SymbolKind::File) ||
267 *T > static_cast<int>(SymbolKind::TypeParameter))
268 return false;
269 Out = static_cast<SymbolKind>(*T);
270 return true;
271 }
272 return false;
273}
274
275bool fromJSON(const llvm::json::Value &E, SymbolKindBitset &Out,
276 llvm::json::Path P) {
277 if (auto *A = E.getAsArray()) {
278 for (size_t I = 0; I < A->size(); ++I) {
279 SymbolKind KindOut;
280 if (fromJSON((*A)[I], KindOut, P.index(I)))
281 Out.set(size_t(KindOut));
282 }
283 return true;
284 }
285 return false;
286}
287
289 SymbolKindBitset &SupportedSymbolKinds) {
290 auto KindVal = static_cast<size_t>(Kind);
291 if (KindVal >= SymbolKindMin && KindVal <= SupportedSymbolKinds.size() &&
292 SupportedSymbolKinds[KindVal])
293 return Kind;
294
295 switch (Kind) {
296 // Provide some fall backs for common kinds that are close enough.
297 case SymbolKind::Struct:
298 return SymbolKind::Class;
299 case SymbolKind::EnumMember:
300 return SymbolKind::Enum;
301 default:
302 return SymbolKind::String;
303 }
304}
305
306SymbolKind indexSymbolKindToSymbolKind(const index::SymbolInfo &Info) {
307 switch (Info.Kind) {
308 // FIXME: for backwards compatibility, the include directive kind is treated
309 // the same as Unknown
310 case index::SymbolKind::IncludeDirective:
311 case index::SymbolKind::Unknown:
312 return SymbolKind::Variable;
313 case index::SymbolKind::Module:
314 return SymbolKind::Module;
315 case index::SymbolKind::Namespace:
316 return SymbolKind::Namespace;
317 case index::SymbolKind::NamespaceAlias:
318 return SymbolKind::Namespace;
319 case index::SymbolKind::Macro:
320 return SymbolKind::String;
321 case index::SymbolKind::Enum:
322 return SymbolKind::Enum;
323 case index::SymbolKind::Struct:
324 return SymbolKind::Struct;
325 case index::SymbolKind::Class:
326 return SymbolKind::Class;
327 case index::SymbolKind::Protocol:
328 return SymbolKind::Interface;
329 case index::SymbolKind::Extension:
330 return SymbolKind::Interface;
331 case index::SymbolKind::Union:
332 return SymbolKind::Class;
333 case index::SymbolKind::TypeAlias: {
334 switch (Info.SubKind) {
335 case index::SymbolSubKind::UsingStruct:
336 return SymbolKind::Struct;
337 case index::SymbolSubKind::UsingClass:
338 return SymbolKind::Class;
339 default:
340 return SymbolKind::Class;
341 }
342 }
343 case index::SymbolKind::Function:
344 return SymbolKind::Function;
345 case index::SymbolKind::Variable:
346 return SymbolKind::Variable;
347 case index::SymbolKind::Field:
348 return SymbolKind::Field;
349 case index::SymbolKind::EnumConstant:
350 return SymbolKind::EnumMember;
351 case index::SymbolKind::InstanceMethod:
352 case index::SymbolKind::ClassMethod:
353 case index::SymbolKind::StaticMethod:
354 return SymbolKind::Method;
355 case index::SymbolKind::InstanceProperty:
356 case index::SymbolKind::ClassProperty:
357 case index::SymbolKind::StaticProperty:
358 return SymbolKind::Property;
359 case index::SymbolKind::Constructor:
360 case index::SymbolKind::Destructor:
361 return SymbolKind::Constructor;
362 case index::SymbolKind::ConversionFunction:
363 return SymbolKind::Function;
364 case index::SymbolKind::Parameter:
365 case index::SymbolKind::NonTypeTemplateParm:
366 return SymbolKind::Variable;
367 case index::SymbolKind::Using:
368 return SymbolKind::Namespace;
369 case index::SymbolKind::TemplateTemplateParm:
370 case index::SymbolKind::TemplateTypeParm:
371 return SymbolKind::TypeParameter;
372 case index::SymbolKind::Concept:
373 return SymbolKind::Interface;
374 }
375 llvm_unreachable("invalid symbol kind");
376}
377
378bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
379 llvm::json::Path P) {
380 const llvm::json::Object *O = Params.getAsObject();
381 if (!O) {
382 P.report("expected object");
383 return false;
384 }
385 if (auto *TextDocument = O->getObject("textDocument")) {
386 if (auto *SemanticHighlighting =
387 TextDocument->getObject("semanticHighlightingCapabilities")) {
388 if (auto SemanticHighlightingSupport =
389 SemanticHighlighting->getBoolean("semanticHighlighting"))
390 R.TheiaSemanticHighlighting = *SemanticHighlightingSupport;
391 }
392 if (auto *InactiveRegions =
393 TextDocument->getObject("inactiveRegionsCapabilities")) {
394 if (auto InactiveRegionsSupport =
395 InactiveRegions->getBoolean("inactiveRegions")) {
396 R.InactiveRegions = *InactiveRegionsSupport;
397 }
398 }
399 if (TextDocument->getObject("semanticTokens"))
400 R.SemanticTokens = true;
401 if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
402 if (auto CategorySupport = Diagnostics->getBoolean("categorySupport"))
403 R.DiagnosticCategory = *CategorySupport;
404 if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline"))
405 R.DiagnosticFixes = *CodeActions;
406 if (auto RelatedInfo = Diagnostics->getBoolean("relatedInformation"))
407 R.DiagnosticRelatedInformation = *RelatedInfo;
408 }
409 if (auto *References = TextDocument->getObject("references"))
410 if (auto ContainerSupport = References->getBoolean("container"))
411 R.ReferenceContainer = *ContainerSupport;
412 if (auto *Completion = TextDocument->getObject("completion")) {
413 if (auto *Item = Completion->getObject("completionItem")) {
414 if (auto SnippetSupport = Item->getBoolean("snippetSupport"))
415 R.CompletionSnippets = *SnippetSupport;
416 if (auto LabelDetailsSupport = Item->getBoolean("labelDetailsSupport"))
417 R.CompletionLabelDetail = *LabelDetailsSupport;
418 if (const auto *DocumentationFormat =
419 Item->getArray("documentationFormat")) {
420 for (const auto &Format : *DocumentationFormat) {
421 if (fromJSON(Format, R.CompletionDocumentationFormat, P))
422 break;
423 }
424 }
425 if (auto IRSupport = Item->getBoolean("insertReplaceSupport"))
426 R.InsertReplace = *IRSupport;
427 }
428 if (auto *ItemKind = Completion->getObject("completionItemKind")) {
429 if (auto *ValueSet = ItemKind->get("valueSet")) {
430 R.CompletionItemKinds.emplace();
431 if (!fromJSON(*ValueSet, *R.CompletionItemKinds,
432 P.field("textDocument")
433 .field("completion")
434 .field("completionItemKind")
435 .field("valueSet")))
436 return false;
437 }
438 }
439 if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
440 R.CompletionFixes = *EditsNearCursor;
441 }
442 if (auto *CodeAction = TextDocument->getObject("codeAction")) {
443 if (CodeAction->getObject("codeActionLiteralSupport"))
444 R.CodeActionStructure = true;
445 }
446 if (auto *DocumentSymbol = TextDocument->getObject("documentSymbol")) {
447 if (auto HierarchicalSupport =
448 DocumentSymbol->getBoolean("hierarchicalDocumentSymbolSupport"))
449 R.HierarchicalDocumentSymbol = *HierarchicalSupport;
450 }
451 if (auto *Hover = TextDocument->getObject("hover")) {
452 if (auto *ContentFormat = Hover->getArray("contentFormat")) {
453 for (const auto &Format : *ContentFormat) {
454 if (fromJSON(Format, R.HoverContentFormat, P))
455 break;
456 }
457 }
458 }
459 if (auto *Help = TextDocument->getObject("signatureHelp")) {
460 R.HasSignatureHelp = true;
461 if (auto *Info = Help->getObject("signatureInformation")) {
462 if (auto *Parameter = Info->getObject("parameterInformation")) {
463 if (auto OffsetSupport = Parameter->getBoolean("labelOffsetSupport"))
464 R.OffsetsInSignatureHelp = *OffsetSupport;
465 }
466 if (const auto *DocumentationFormat =
467 Info->getArray("documentationFormat")) {
468 for (const auto &Format : *DocumentationFormat) {
470 break;
471 }
472 }
473 }
474 }
475 if (auto *Folding = TextDocument->getObject("foldingRange")) {
476 if (auto LineFolding = Folding->getBoolean("lineFoldingOnly"))
477 R.LineFoldingOnly = *LineFolding;
478 }
479 if (auto *Rename = TextDocument->getObject("rename")) {
480 if (auto RenameSupport = Rename->getBoolean("prepareSupport"))
481 R.RenamePrepareSupport = *RenameSupport;
482 }
483 }
484 if (auto *Workspace = O->getObject("workspace")) {
485 if (auto *Symbol = Workspace->getObject("symbol")) {
486 if (auto *SymbolKind = Symbol->getObject("symbolKind")) {
487 if (auto *ValueSet = SymbolKind->get("valueSet")) {
488 R.WorkspaceSymbolKinds.emplace();
489 if (!fromJSON(*ValueSet, *R.WorkspaceSymbolKinds,
490 P.field("workspace")
491 .field("symbol")
492 .field("symbolKind")
493 .field("valueSet")))
494 return false;
495 }
496 }
497 }
498 if (auto *SemanticTokens = Workspace->getObject("semanticTokens")) {
499 if (auto RefreshSupport = SemanticTokens->getBoolean("refreshSupport"))
500 R.SemanticTokenRefreshSupport = *RefreshSupport;
501 }
502 if (auto *WorkspaceEdit = Workspace->getObject("workspaceEdit")) {
503 if (auto DocumentChanges = WorkspaceEdit->getBoolean("documentChanges"))
504 R.DocumentChanges = *DocumentChanges;
505 if (WorkspaceEdit->getObject("changeAnnotationSupport")) {
506 R.ChangeAnnotation = true;
507 }
508 }
509 }
510 if (auto *Window = O->getObject("window")) {
511 if (auto WorkDoneProgress = Window->getBoolean("workDoneProgress"))
512 R.WorkDoneProgress = *WorkDoneProgress;
513 if (auto Implicit = Window->getBoolean("implicitWorkDoneProgressCreate"))
514 R.ImplicitProgressCreation = *Implicit;
515 }
516 if (auto *General = O->getObject("general")) {
517 if (auto *StaleRequestSupport = General->getObject("staleRequestSupport")) {
518 if (auto Cancel = StaleRequestSupport->getBoolean("cancel"))
519 R.CancelsStaleRequests = *Cancel;
520 }
521 if (auto *PositionEncodings = General->get("positionEncodings")) {
522 R.PositionEncodings.emplace();
523 if (!fromJSON(*PositionEncodings, *R.PositionEncodings,
524 P.field("general").field("positionEncodings")))
525 return false;
526 }
527 }
528 if (auto *OffsetEncoding = O->get("offsetEncoding")) {
529 R.PositionEncodings.emplace();
530 elog("offsetEncoding capability is a deprecated clangd extension that'll "
531 "go away with clangd 23. Migrate to standard positionEncodings "
532 "capability introduced by LSP 3.17");
534 P.field("offsetEncoding")))
535 return false;
536 }
537
538 if (auto *Experimental = O->getObject("experimental")) {
539 if (auto *TextDocument = Experimental->getObject("textDocument")) {
540 if (auto *Completion = TextDocument->getObject("completion")) {
541 if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
542 R.CompletionFixes |= *EditsNearCursor;
543 }
544 if (auto *References = TextDocument->getObject("references")) {
545 if (auto ContainerSupport = References->getBoolean("container")) {
546 R.ReferenceContainer |= *ContainerSupport;
547 }
548 }
549 if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
550 if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline")) {
551 R.DiagnosticFixes |= *CodeActions;
552 }
553 }
554 if (auto *InactiveRegions =
555 TextDocument->getObject("inactiveRegionsCapabilities")) {
556 if (auto InactiveRegionsSupport =
557 InactiveRegions->getBoolean("inactiveRegions")) {
558 R.InactiveRegions |= *InactiveRegionsSupport;
559 }
560 }
561 }
562 if (auto *Window = Experimental->getObject("window")) {
563 if (auto Implicit =
564 Window->getBoolean("implicitWorkDoneProgressCreate")) {
565 R.ImplicitProgressCreation |= *Implicit;
566 }
567 }
568 if (auto *OffsetEncoding = Experimental->get("offsetEncoding")) {
569 R.PositionEncodings.emplace();
570 elog("offsetEncoding capability is a deprecated clangd extension that'll "
571 "go away with clangd 23. Migrate to standard positionEncodings "
572 "capability introduced by LSP 3.17");
574 P.field("offsetEncoding")))
575 return false;
576 }
577 }
578
579 return true;
580}
581
582bool fromJSON(const llvm::json::Value &Params, InitializeParams &R,
583 llvm::json::Path P) {
584 llvm::json::ObjectMapper O(Params, P);
585 if (!O)
586 return false;
587 // We deliberately don't fail if we can't parse individual fields.
588 // Failing to handle a slightly malformed initialize would be a disaster.
589 O.map("processId", R.processId);
590 O.map("rootUri", R.rootUri);
591 O.map("rootPath", R.rootPath);
592 O.map("capabilities", R.capabilities);
593 if (auto *RawCaps = Params.getAsObject()->getObject("capabilities"))
594 R.rawCapabilities = *RawCaps;
595 O.map("trace", R.trace);
596 O.map("initializationOptions", R.initializationOptions);
597 return true;
598}
599
600llvm::json::Value toJSON(const WorkDoneProgressCreateParams &P) {
601 return llvm::json::Object{{"token", P.token}};
602}
603
604llvm::json::Value toJSON(const WorkDoneProgressBegin &P) {
605 llvm::json::Object Result{
606 {"kind", "begin"},
607 {"title", P.title},
608 };
609 if (P.cancellable)
610 Result["cancellable"] = true;
611 if (P.percentage)
612 Result["percentage"] = 0;
613
614 // FIXME: workaround for older gcc/clang
615 return std::move(Result);
616}
617
618llvm::json::Value toJSON(const WorkDoneProgressReport &P) {
619 llvm::json::Object Result{{"kind", "report"}};
620 if (P.cancellable)
621 Result["cancellable"] = *P.cancellable;
622 if (P.message)
623 Result["message"] = *P.message;
624 if (P.percentage)
625 Result["percentage"] = *P.percentage;
626 // FIXME: workaround for older gcc/clang
627 return std::move(Result);
628}
629
630llvm::json::Value toJSON(const WorkDoneProgressEnd &P) {
631 llvm::json::Object Result{{"kind", "end"}};
632 if (P.message)
633 Result["message"] = *P.message;
634 // FIXME: workaround for older gcc/clang
635 return std::move(Result);
636}
637
638llvm::json::Value toJSON(const MessageType &R) {
639 return static_cast<int64_t>(R);
640}
641
642llvm::json::Value toJSON(const ShowMessageParams &R) {
643 return llvm::json::Object{{"type", R.type}, {"message", R.message}};
644}
645
646bool fromJSON(const llvm::json::Value &Params, DidOpenTextDocumentParams &R,
647 llvm::json::Path P) {
648 llvm::json::ObjectMapper O(Params, P);
649 return O && O.map("textDocument", R.textDocument);
650}
651
652bool fromJSON(const llvm::json::Value &Params, DidCloseTextDocumentParams &R,
653 llvm::json::Path P) {
654 llvm::json::ObjectMapper O(Params, P);
655 return O && O.map("textDocument", R.textDocument);
656}
657
658bool fromJSON(const llvm::json::Value &Params, DidSaveTextDocumentParams &R,
659 llvm::json::Path P) {
660 llvm::json::ObjectMapper O(Params, P);
661 return O && O.map("textDocument", R.textDocument);
662}
663
664bool fromJSON(const llvm::json::Value &Params, DidChangeTextDocumentParams &R,
665 llvm::json::Path P) {
666 llvm::json::ObjectMapper O(Params, P);
667 return O && O.map("textDocument", R.textDocument) &&
668 O.map("contentChanges", R.contentChanges) &&
669 O.map("wantDiagnostics", R.wantDiagnostics) &&
670 mapOptOrNull(Params, "forceRebuild", R.forceRebuild, P);
671}
672
673bool fromJSON(const llvm::json::Value &E, FileChangeType &Out,
674 llvm::json::Path P) {
675 if (auto T = E.getAsInteger()) {
676 if (*T < static_cast<int>(FileChangeType::Created) ||
677 *T > static_cast<int>(FileChangeType::Deleted))
678 return false;
679 Out = static_cast<FileChangeType>(*T);
680 return true;
681 }
682 return false;
683}
684
685bool fromJSON(const llvm::json::Value &Params, FileEvent &R,
686 llvm::json::Path P) {
687 llvm::json::ObjectMapper O(Params, P);
688 return O && O.map("uri", R.uri) && O.map("type", R.type);
689}
690
691bool fromJSON(const llvm::json::Value &Params, DidChangeWatchedFilesParams &R,
692 llvm::json::Path P) {
693 llvm::json::ObjectMapper O(Params, P);
694 return O && O.map("changes", R.changes);
695}
696
697bool fromJSON(const llvm::json::Value &Params,
698 TextDocumentContentChangeEvent &R, llvm::json::Path P) {
699 llvm::json::ObjectMapper O(Params, P);
700 return O && O.map("range", R.range) && O.map("rangeLength", R.rangeLength) &&
701 O.map("text", R.text);
702}
703
704bool fromJSON(const llvm::json::Value &Params, DocumentRangeFormattingParams &R,
705 llvm::json::Path P) {
706 llvm::json::ObjectMapper O(Params, P);
707 return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
708 ;
709}
710
711bool fromJSON(const llvm::json::Value &Params,
712 DocumentRangesFormattingParams &R, llvm::json::Path P) {
713 llvm::json::ObjectMapper O(Params, P);
714 return O && O.map("textDocument", R.textDocument) &&
715 O.map("ranges", R.ranges);
716 ;
717}
718
719bool fromJSON(const llvm::json::Value &Params,
720 DocumentOnTypeFormattingParams &R, llvm::json::Path P) {
721 llvm::json::ObjectMapper O(Params, P);
722 return O && O.map("textDocument", R.textDocument) &&
723 O.map("position", R.position) && O.map("ch", R.ch);
724}
725
726bool fromJSON(const llvm::json::Value &Params, DocumentFormattingParams &R,
727 llvm::json::Path P) {
728 llvm::json::ObjectMapper O(Params, P);
729 return O && O.map("textDocument", R.textDocument);
730}
731
732bool fromJSON(const llvm::json::Value &Params, DocumentSymbolParams &R,
733 llvm::json::Path P) {
734 llvm::json::ObjectMapper O(Params, P);
735 return O && O.map("textDocument", R.textDocument);
736}
737
738llvm::json::Value toJSON(const DiagnosticRelatedInformation &DRI) {
739 return llvm::json::Object{
740 {"location", DRI.location},
741 {"message", DRI.message},
742 };
743}
744
745llvm::json::Value toJSON(DiagnosticTag Tag) { return static_cast<int>(Tag); }
746
747llvm::json::Value toJSON(const CodeDescription &D) {
748 return llvm::json::Object{{"href", D.href}};
749}
750
751llvm::json::Value toJSON(const Diagnostic &D) {
752 llvm::json::Object Diag{
753 {"range", D.range},
754 {"severity", D.severity},
755 {"message", D.message},
756 };
757 if (D.category)
758 Diag["category"] = *D.category;
759 if (D.codeActions)
760 Diag["codeActions"] = D.codeActions;
761 if (!D.code.empty())
762 Diag["code"] = D.code;
763 if (D.codeDescription)
764 Diag["codeDescription"] = *D.codeDescription;
765 if (!D.source.empty())
766 Diag["source"] = D.source;
767 if (D.relatedInformation)
768 Diag["relatedInformation"] = *D.relatedInformation;
769 if (!D.data.empty())
770 Diag["data"] = llvm::json::Object(D.data);
771 if (!D.tags.empty())
772 Diag["tags"] = llvm::json::Array{D.tags};
773 // FIXME: workaround for older gcc/clang
774 return std::move(Diag);
775}
776
777bool fromJSON(const llvm::json::Value &Params, Diagnostic &R,
778 llvm::json::Path P) {
779 llvm::json::ObjectMapper O(Params, P);
780 if (!O)
781 return false;
782 if (auto *Data = Params.getAsObject()->getObject("data"))
783 R.data = *Data;
784 return O.map("range", R.range) && O.map("message", R.message) &&
785 mapOptOrNull(Params, "severity", R.severity, P) &&
786 mapOptOrNull(Params, "category", R.category, P) &&
787 mapOptOrNull(Params, "code", R.code, P) &&
788 mapOptOrNull(Params, "source", R.source, P);
789}
790
791llvm::json::Value toJSON(const PublishDiagnosticsParams &PDP) {
792 llvm::json::Object Result{
793 {"uri", PDP.uri},
794 {"diagnostics", PDP.diagnostics},
795 };
796 if (PDP.version)
797 Result["version"] = PDP.version;
798 return std::move(Result);
799}
800
801bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R,
802 llvm::json::Path P) {
803 llvm::json::ObjectMapper O(Params, P);
804 if (!O || !O.map("diagnostics", R.diagnostics))
805 return false;
806 O.map("only", R.only);
807 return true;
808}
809
810llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diagnostic &D) {
811 OS << D.range << " [";
812 switch (D.severity) {
813 case 1:
814 OS << "error";
815 break;
816 case 2:
817 OS << "warning";
818 break;
819 case 3:
820 OS << "note";
821 break;
822 case 4:
823 OS << "remark";
824 break;
825 default:
826 OS << "diagnostic";
827 break;
828 }
829 return OS << '(' << D.severity << "): " << D.message << "]";
830}
831
832bool fromJSON(const llvm::json::Value &Params, CodeActionParams &R,
833 llvm::json::Path P) {
834 llvm::json::ObjectMapper O(Params, P);
835 return O && O.map("textDocument", R.textDocument) &&
836 O.map("range", R.range) && O.map("context", R.context);
837}
838
839bool fromJSON(const llvm::json::Value &Params, WorkspaceEdit &R,
840 llvm::json::Path P) {
841 llvm::json::ObjectMapper O(Params, P);
842 return O && O.map("changes", R.changes) &&
843 O.map("documentChanges", R.documentChanges) &&
844 O.mapOptional("changeAnnotations", R.changeAnnotations);
845}
846
847bool fromJSON(const llvm::json::Value &Params, ExecuteCommandParams &R,
848 llvm::json::Path P) {
849 llvm::json::ObjectMapper O(Params, P);
850 if (!O || !O.map("command", R.command))
851 return false;
852
853 const auto *Args = Params.getAsObject()->get("arguments");
854 if (!Args)
855 return true; // Missing args is ok, argument is null.
856 const auto *ArgsArray = Args->getAsArray();
857 if (!ArgsArray) {
858 P.field("arguments").report("expected array");
859 return false;
860 }
861 if (ArgsArray->size() > 1) {
862 P.field("arguments").report("Command should have 0 or 1 argument");
863 return false;
864 }
865 if (ArgsArray->size() == 1) {
866 R.argument = ArgsArray->front();
867 }
868 return true;
869}
870
871llvm::json::Value toJSON(const SymbolInformation &P) {
872 llvm::json::Object O{
873 {"name", P.name},
874 {"kind", static_cast<int>(P.kind)},
875 {"location", P.location},
876 {"containerName", P.containerName},
877 };
878 if (P.score)
879 O["score"] = *P.score;
880 return std::move(O);
881}
882
883llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
884 const SymbolInformation &SI) {
885 O << SI.containerName << "::" << SI.name << " - " << toJSON(SI);
886 return O;
887}
888
889bool operator==(const SymbolDetails &LHS, const SymbolDetails &RHS) {
890 return LHS.name == RHS.name && LHS.containerName == RHS.containerName &&
891 LHS.USR == RHS.USR && LHS.ID == RHS.ID &&
894}
895
896llvm::json::Value toJSON(const SymbolDetails &P) {
897 llvm::json::Object Result{{"name", llvm::json::Value(nullptr)},
898 {"containerName", llvm::json::Value(nullptr)},
899 {"usr", llvm::json::Value(nullptr)},
900 {"id", llvm::json::Value(nullptr)}};
901
902 if (!P.name.empty())
903 Result["name"] = P.name;
904
905 if (!P.containerName.empty())
906 Result["containerName"] = P.containerName;
907
908 if (!P.USR.empty())
909 Result["usr"] = P.USR;
910
911 if (P.ID)
912 Result["id"] = P.ID.str();
913
914 if (P.declarationRange)
915 Result["declarationRange"] = *P.declarationRange;
916
917 if (P.definitionRange)
918 Result["definitionRange"] = *P.definitionRange;
919
920 // FIXME: workaround for older gcc/clang
921 return std::move(Result);
922}
923
924llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const SymbolDetails &S) {
925 if (!S.containerName.empty()) {
926 O << S.containerName;
927 llvm::StringRef ContNameRef;
928 if (!ContNameRef.ends_with("::")) {
929 O << " ";
930 }
931 }
932 O << S.name << " - " << toJSON(S);
933 return O;
934}
935
936bool fromJSON(const llvm::json::Value &Params, WorkspaceSymbolParams &R,
937 llvm::json::Path P) {
938 llvm::json::ObjectMapper O(Params, P);
939 return O && O.map("query", R.query) &&
940 mapOptOrNull(Params, "limit", R.limit, P);
941}
942
943llvm::json::Value toJSON(const Command &C) {
944 auto Cmd = llvm::json::Object{{"title", C.title}, {"command", C.command}};
945 if (!C.argument.getAsNull())
946 Cmd["arguments"] = llvm::json::Array{C.argument};
947 return std::move(Cmd);
948}
949
950const llvm::StringLiteral CodeAction::QUICKFIX_KIND = "quickfix";
951const llvm::StringLiteral CodeAction::REFACTOR_KIND = "refactor";
952const llvm::StringLiteral CodeAction::INFO_KIND = "info";
953
954llvm::json::Value toJSON(const CodeAction &CA) {
955 auto CodeAction = llvm::json::Object{{"title", CA.title}};
956 if (CA.kind)
957 CodeAction["kind"] = *CA.kind;
958 if (CA.diagnostics)
959 CodeAction["diagnostics"] = llvm::json::Array(*CA.diagnostics);
960 if (CA.isPreferred)
961 CodeAction["isPreferred"] = true;
962 if (CA.edit)
963 CodeAction["edit"] = *CA.edit;
964 if (CA.command)
965 CodeAction["command"] = *CA.command;
966 return std::move(CodeAction);
967}
968
969llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S) {
970 return O << S.name << " - " << toJSON(S);
971}
972
973llvm::json::Value toJSON(const DocumentSymbol &S) {
974 llvm::json::Object Result{{"name", S.name},
975 {"kind", static_cast<int>(S.kind)},
976 {"range", S.range},
977 {"selectionRange", S.selectionRange}};
978
979 if (!S.detail.empty())
980 Result["detail"] = S.detail;
981 if (!S.children.empty())
982 Result["children"] = S.children;
983 if (S.deprecated)
984 Result["deprecated"] = true;
985 if (!S.tags.empty())
986 Result["tags"] = S.tags;
987 // FIXME: workaround for older gcc/clang
988 return std::move(Result);
989}
990
991llvm::json::Value toJSON(const WorkspaceEdit &WE) {
992 llvm::json::Object Result;
993 if (WE.changes) {
994 llvm::json::Object FileChanges;
995 for (auto &Change : *WE.changes)
996 FileChanges[Change.first] = llvm::json::Array(Change.second);
997 Result["changes"] = std::move(FileChanges);
998 }
999 if (WE.documentChanges)
1000 Result["documentChanges"] = *WE.documentChanges;
1001 if (!WE.changeAnnotations.empty()) {
1002 llvm::json::Object ChangeAnnotations;
1003 for (auto &Annotation : WE.changeAnnotations)
1004 ChangeAnnotations[Annotation.first] = Annotation.second;
1005 Result["changeAnnotations"] = std::move(ChangeAnnotations);
1006 }
1007 return Result;
1008}
1009
1010bool fromJSON(const llvm::json::Value &Params, TweakArgs &A,
1011 llvm::json::Path P) {
1012 llvm::json::ObjectMapper O(Params, P);
1013 return O && O.map("file", A.file) && O.map("selection", A.selection) &&
1014 O.map("tweakID", A.tweakID);
1015}
1016
1017llvm::json::Value toJSON(const TweakArgs &A) {
1018 return llvm::json::Object{
1019 {"tweakID", A.tweakID}, {"selection", A.selection}, {"file", A.file}};
1020}
1021
1022llvm::json::Value toJSON(const ApplyWorkspaceEditParams &Params) {
1023 return llvm::json::Object{{"edit", Params.edit}};
1024}
1025
1026bool fromJSON(const llvm::json::Value &Response, ApplyWorkspaceEditResponse &R,
1027 llvm::json::Path P) {
1028 llvm::json::ObjectMapper O(Response, P);
1029 return O && O.map("applied", R.applied) &&
1030 O.map("failureReason", R.failureReason);
1031}
1032
1033bool fromJSON(const llvm::json::Value &Params, TextDocumentPositionParams &R,
1034 llvm::json::Path P) {
1035 llvm::json::ObjectMapper O(Params, P);
1036 return O && O.map("textDocument", R.textDocument) &&
1037 O.map("position", R.position);
1038}
1039
1040bool fromJSON(const llvm::json::Value &Params, CompletionContext &R,
1041 llvm::json::Path P) {
1042 llvm::json::ObjectMapper O(Params, P);
1043 int TriggerKind;
1044 if (!O || !O.map("triggerKind", TriggerKind) ||
1045 !mapOptOrNull(Params, "triggerCharacter", R.triggerCharacter, P))
1046 return false;
1047 R.triggerKind = static_cast<CompletionTriggerKind>(TriggerKind);
1048 return true;
1049}
1050
1051bool fromJSON(const llvm::json::Value &Params, CompletionParams &R,
1052 llvm::json::Path P) {
1053 if (!fromJSON(Params, static_cast<TextDocumentPositionParams &>(R), P) ||
1054 !mapOptOrNull(Params, "limit", R.limit, P))
1055 return false;
1056 if (auto *Context = Params.getAsObject()->get("context"))
1057 return fromJSON(*Context, R.context, P.field("context"));
1058 return true;
1059}
1060
1061static llvm::StringRef toTextKind(MarkupKind Kind) {
1062 switch (Kind) {
1064 return "plaintext";
1066 return "markdown";
1067 }
1068 llvm_unreachable("Invalid MarkupKind");
1069}
1070
1071bool fromJSON(const llvm::json::Value &V, MarkupKind &K, llvm::json::Path P) {
1072 auto Str = V.getAsString();
1073 if (!Str) {
1074 P.report("expected string");
1075 return false;
1076 }
1077 if (*Str == "plaintext")
1079 else if (*Str == "markdown")
1081 else {
1082 P.report("unknown markup kind");
1083 return false;
1084 }
1085 return true;
1086}
1087
1088llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, MarkupKind K) {
1089 return OS << toTextKind(K);
1090}
1091
1092llvm::json::Value toJSON(const MarkupContent &MC) {
1093 if (MC.value.empty())
1094 return nullptr;
1095
1096 return llvm::json::Object{
1097 {"kind", toTextKind(MC.kind)},
1098 {"value", MC.value},
1099 };
1100}
1101
1102llvm::json::Value toJSON(const Hover &H) {
1103 llvm::json::Object Result{{"contents", toJSON(H.contents)}};
1104
1105 if (H.range)
1106 Result["range"] = toJSON(*H.range);
1107
1108 return std::move(Result);
1109}
1110
1111bool fromJSON(const llvm::json::Value &E, CompletionItemKind &Out,
1112 llvm::json::Path P) {
1113 if (auto T = E.getAsInteger()) {
1114 if (*T < static_cast<int>(CompletionItemKind::Text) ||
1115 *T > static_cast<int>(CompletionItemKind::TypeParameter))
1116 return false;
1117 Out = static_cast<CompletionItemKind>(*T);
1118 return true;
1119 }
1120 return false;
1121}
1122
1123CompletionItemKind
1125 CompletionItemKindBitset &SupportedCompletionItemKinds) {
1126 auto KindVal = static_cast<size_t>(Kind);
1127 if (KindVal >= CompletionItemKindMin &&
1128 KindVal <= SupportedCompletionItemKinds.size() &&
1129 SupportedCompletionItemKinds[KindVal])
1130 return Kind;
1131
1132 switch (Kind) {
1133 // Provide some fall backs for common kinds that are close enough.
1140 default:
1142 }
1143}
1144
1145bool fromJSON(const llvm::json::Value &E, CompletionItemKindBitset &Out,
1146 llvm::json::Path P) {
1147 if (auto *A = E.getAsArray()) {
1148 for (size_t I = 0; I < A->size(); ++I) {
1149 CompletionItemKind KindOut;
1150 if (fromJSON((*A)[I], KindOut, P.index(I)))
1151 Out.set(size_t(KindOut));
1152 }
1153 return true;
1154 }
1155 return false;
1156}
1157
1158llvm::json::Value toJSON(const CompletionItemLabelDetails &CD) {
1159 llvm::json::Object Result;
1160 if (!CD.detail.empty())
1161 Result["detail"] = CD.detail;
1162 if (!CD.description.empty())
1163 Result["description"] = CD.description;
1164 return Result;
1165}
1166
1168 if (!C.labelDetails)
1169 return;
1170 if (!C.labelDetails->detail.empty())
1171 C.label += C.labelDetails->detail;
1172 if (!C.labelDetails->description.empty())
1173 C.label = C.labelDetails->description + C.label;
1174 C.labelDetails.reset();
1175}
1176
1177llvm::json::Value toJSON(const CompletionItem &CI) {
1178 assert(!CI.label.empty() && "completion item label is required");
1179 llvm::json::Object Result{{"label", CI.label}};
1181 Result["kind"] = static_cast<int>(CI.kind);
1182 if (!CI.detail.empty())
1183 Result["detail"] = CI.detail;
1184 if (CI.labelDetails)
1185 Result["labelDetails"] = *CI.labelDetails;
1186 if (CI.documentation)
1187 Result["documentation"] = CI.documentation;
1188 if (!CI.sortText.empty())
1189 Result["sortText"] = CI.sortText;
1190 if (!CI.filterText.empty())
1191 Result["filterText"] = CI.filterText;
1192 if (!CI.insertText.empty())
1193 Result["insertText"] = CI.insertText;
1195 Result["insertTextFormat"] = static_cast<int>(CI.insertTextFormat);
1196 if (CI.textEdit)
1197 Result["textEdit"] = std::visit(
1198 [](const auto &V) { return llvm::json::Value(V); }, *CI.textEdit);
1199 if (!CI.additionalTextEdits.empty())
1200 Result["additionalTextEdits"] = llvm::json::Array(CI.additionalTextEdits);
1201 if (CI.deprecated)
1202 Result["deprecated"] = CI.deprecated;
1203 Result["score"] = CI.score;
1204 return std::move(Result);
1205}
1206
1207llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const CompletionItem &I) {
1208 O << I.label << " - " << toJSON(I);
1209 return O;
1210}
1211
1212bool operator<(const CompletionItem &L, const CompletionItem &R) {
1213 return (L.sortText.empty() ? L.label : L.sortText) <
1214 (R.sortText.empty() ? R.label : R.sortText);
1215}
1216
1217llvm::json::Value toJSON(const CompletionList &L) {
1218 return llvm::json::Object{
1219 {"isIncomplete", L.isIncomplete},
1220 {"items", llvm::json::Array(L.items)},
1221 };
1222}
1223
1224llvm::json::Value toJSON(const ParameterInformation &PI) {
1225 assert((PI.labelOffsets || !PI.labelString.empty()) &&
1226 "parameter information label is required");
1227 llvm::json::Object Result;
1228 if (PI.labelOffsets)
1229 Result["label"] =
1230 llvm::json::Array({PI.labelOffsets->first, PI.labelOffsets->second});
1231 else
1232 Result["label"] = PI.labelString;
1233 if (!PI.documentation.empty())
1234 Result["documentation"] = PI.documentation;
1235 return std::move(Result);
1236}
1237
1238llvm::json::Value toJSON(const SignatureInformation &SI) {
1239 assert(!SI.label.empty() && "signature information label is required");
1240 llvm::json::Object Result{
1241 {"label", SI.label},
1242 {"parameters", llvm::json::Array(SI.parameters)},
1243 };
1244 if (!SI.documentation.value.empty())
1245 Result["documentation"] = SI.documentation;
1246 return std::move(Result);
1247}
1248
1249llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1250 const SignatureInformation &I) {
1251 O << I.label << " - " << toJSON(I);
1252 return O;
1253}
1254
1255llvm::json::Value toJSON(const SignatureHelp &SH) {
1256 assert(SH.activeSignature >= 0 &&
1257 "Unexpected negative value for number of active signatures.");
1258 assert(SH.activeParameter >= 0 &&
1259 "Unexpected negative value for active parameter index");
1260 return llvm::json::Object{
1261 {"activeSignature", SH.activeSignature},
1262 {"activeParameter", SH.activeParameter},
1263 {"signatures", llvm::json::Array(SH.signatures)},
1264 };
1265}
1266
1267bool fromJSON(const llvm::json::Value &Params, RenameParams &R,
1268 llvm::json::Path P) {
1269 llvm::json::ObjectMapper O(Params, P);
1270 return O && O.map("textDocument", R.textDocument) &&
1271 O.map("position", R.position) && O.map("newName", R.newName);
1272}
1273
1274llvm::json::Value toJSON(const RenameParams &R) {
1275 return llvm::json::Object{
1276 {"textDocument", R.textDocument},
1277 {"position", R.position},
1278 {"newName", R.newName},
1279 };
1280}
1281
1282llvm::json::Value toJSON(const PrepareRenameResult &PRR) {
1283 if (PRR.placeholder.empty())
1284 return toJSON(PRR.range);
1285 return llvm::json::Object{
1286 {"range", toJSON(PRR.range)},
1287 {"placeholder", PRR.placeholder},
1288 };
1289}
1290
1291llvm::json::Value toJSON(const DocumentHighlight &DH) {
1292 return llvm::json::Object{
1293 {"range", toJSON(DH.range)},
1294 {"kind", static_cast<int>(DH.kind)},
1295 };
1296}
1297
1298llvm::json::Value toJSON(const FileStatus &FStatus) {
1299 return llvm::json::Object{
1300 {"uri", FStatus.uri},
1301 {"state", FStatus.state},
1302 };
1303}
1304
1305constexpr unsigned SemanticTokenEncodingSize = 5;
1306static llvm::json::Value encodeTokens(llvm::ArrayRef<SemanticToken> Toks) {
1307 llvm::json::Array Result;
1308 Result.reserve(SemanticTokenEncodingSize * Toks.size());
1309 for (const auto &Tok : Toks) {
1310 Result.push_back(Tok.deltaLine);
1311 Result.push_back(Tok.deltaStart);
1312 Result.push_back(Tok.length);
1313 Result.push_back(Tok.tokenType);
1314 Result.push_back(Tok.tokenModifiers);
1315 }
1316 assert(Result.size() == SemanticTokenEncodingSize * Toks.size());
1317 return std::move(Result);
1318}
1319
1320bool operator==(const SemanticToken &L, const SemanticToken &R) {
1321 return std::tie(L.deltaLine, L.deltaStart, L.length, L.tokenType,
1322 L.tokenModifiers) == std::tie(R.deltaLine, R.deltaStart,
1323 R.length, R.tokenType,
1324 R.tokenModifiers);
1325}
1326
1327llvm::json::Value toJSON(const SemanticTokens &Tokens) {
1328 return llvm::json::Object{{"resultId", Tokens.resultId},
1329 {"data", encodeTokens(Tokens.tokens)}};
1330}
1331
1332llvm::json::Value toJSON(const SemanticTokensEdit &Edit) {
1333 return llvm::json::Object{
1334 {"start", SemanticTokenEncodingSize * Edit.startToken},
1335 {"deleteCount", SemanticTokenEncodingSize * Edit.deleteTokens},
1336 {"data", encodeTokens(Edit.tokens)}};
1337}
1338
1339llvm::json::Value toJSON(const SemanticTokensOrDelta &TE) {
1340 llvm::json::Object Result{{"resultId", TE.resultId}};
1341 if (TE.edits)
1342 Result["edits"] = *TE.edits;
1343 if (TE.tokens)
1344 Result["data"] = encodeTokens(*TE.tokens);
1345 return std::move(Result);
1346}
1347
1348bool fromJSON(const llvm::json::Value &Params, SemanticTokensParams &R,
1349 llvm::json::Path P) {
1350 llvm::json::ObjectMapper O(Params, P);
1351 return O && O.map("textDocument", R.textDocument);
1352}
1353
1354bool fromJSON(const llvm::json::Value &Params, SemanticTokensDeltaParams &R,
1355 llvm::json::Path P) {
1356 llvm::json::ObjectMapper O(Params, P);
1357 return O && O.map("textDocument", R.textDocument) &&
1358 O.map("previousResultId", R.previousResultId);
1359}
1360
1361llvm::json::Value toJSON(const InactiveRegionsParams &InactiveRegions) {
1362 return llvm::json::Object{
1363 {"textDocument", InactiveRegions.TextDocument},
1364 {"regions", std::move(InactiveRegions.InactiveRegions)}};
1365}
1366
1367llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1368 const DocumentHighlight &V) {
1369 O << V.range;
1371 O << "(r)";
1373 O << "(w)";
1374 return O;
1375}
1376
1377bool fromJSON(const llvm::json::Value &Params,
1378 DidChangeConfigurationParams &CCP, llvm::json::Path P) {
1379 llvm::json::ObjectMapper O(Params, P);
1380 return O && O.map("settings", CCP.settings);
1381}
1382
1383bool fromJSON(const llvm::json::Value &Params, ClangdCompileCommand &CDbUpdate,
1384 llvm::json::Path P) {
1385 llvm::json::ObjectMapper O(Params, P);
1386 return O && O.map("workingDirectory", CDbUpdate.workingDirectory) &&
1387 O.map("compilationCommand", CDbUpdate.compilationCommand);
1388}
1389
1390bool fromJSON(const llvm::json::Value &Params, ConfigurationSettings &S,
1391 llvm::json::Path P) {
1392 llvm::json::ObjectMapper O(Params, P);
1393 if (!O)
1394 return true; // 'any' type in LSP.
1395 return mapOptOrNull(Params, "compilationDatabaseChanges",
1397}
1398
1399bool fromJSON(const llvm::json::Value &Params, InitializationOptions &Opts,
1400 llvm::json::Path P) {
1401 llvm::json::ObjectMapper O(Params, P);
1402 if (!O)
1403 return true; // 'any' type in LSP.
1404
1405 return fromJSON(Params, Opts.ConfigSettings, P) &&
1406 O.map("compilationDatabasePath", Opts.compilationDatabasePath) &&
1407 mapOptOrNull(Params, "fallbackFlags", Opts.fallbackFlags, P) &&
1408 mapOptOrNull(Params, "clangdFileStatus", Opts.FileStatus, P);
1409}
1410
1411bool fromJSON(const llvm::json::Value &E, TypeHierarchyDirection &Out,
1412 llvm::json::Path P) {
1413 auto T = E.getAsInteger();
1414 if (!T)
1415 return false;
1416 if (*T < static_cast<int>(TypeHierarchyDirection::Children) ||
1417 *T > static_cast<int>(TypeHierarchyDirection::Both))
1418 return false;
1419 Out = static_cast<TypeHierarchyDirection>(*T);
1420 return true;
1421}
1422
1423bool fromJSON(const llvm::json::Value &Params, TypeHierarchyPrepareParams &R,
1424 llvm::json::Path P) {
1425 llvm::json::ObjectMapper O(Params, P);
1426 return O && O.map("textDocument", R.textDocument) &&
1427 O.map("position", R.position) &&
1428 mapOptOrNull(Params, "resolve", R.resolve, P) &&
1429 mapOptOrNull(Params, "direction", R.direction, P);
1430}
1431
1432llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
1433 const TypeHierarchyItem &I) {
1434 return O << I.name << " - " << toJSON(I);
1435}
1436
1437llvm::json::Value toJSON(const TypeHierarchyItem::ResolveParams &RP) {
1438 llvm::json::Object Result{{"symbolID", RP.symbolID}};
1439 if (RP.parents)
1440 Result["parents"] = RP.parents;
1441 return std::move(Result);
1442}
1443bool fromJSON(const llvm::json::Value &Params,
1444 TypeHierarchyItem::ResolveParams &RP, llvm::json::Path P) {
1445 llvm::json::ObjectMapper O(Params, P);
1446 return O && O.map("symbolID", RP.symbolID) &&
1447 mapOptOrNull(Params, "parents", RP.parents, P);
1448}
1449
1450llvm::json::Value toJSON(const TypeHierarchyItem &I) {
1451 llvm::json::Object Result{
1452 {"name", I.name}, {"kind", static_cast<int>(I.kind)},
1453 {"range", I.range}, {"selectionRange", I.selectionRange},
1454 {"uri", I.uri}, {"data", I.data},
1455 };
1456
1457 if (I.detail)
1458 Result["detail"] = I.detail;
1459 return std::move(Result);
1460}
1461
1462bool fromJSON(const llvm::json::Value &Params, TypeHierarchyItem &I,
1463 llvm::json::Path P) {
1464 llvm::json::ObjectMapper O(Params, P);
1465
1466 // Required fields.
1467 return O && O.map("name", I.name) && O.map("kind", I.kind) &&
1468 O.map("uri", I.uri) && O.map("range", I.range) &&
1469 O.map("selectionRange", I.selectionRange) &&
1470 mapOptOrNull(Params, "detail", I.detail, P) &&
1471 mapOptOrNull(Params, "deprecated", I.deprecated, P) &&
1472 mapOptOrNull(Params, "parents", I.parents, P) &&
1473 mapOptOrNull(Params, "children", I.children, P) &&
1474 mapOptOrNull(Params, "data", I.data, P);
1475}
1476
1477bool fromJSON(const llvm::json::Value &Params,
1478 ResolveTypeHierarchyItemParams &R, llvm::json::Path P) {
1479 llvm::json::ObjectMapper O(Params, P);
1480 return O && O.map("item", R.item) &&
1481 mapOptOrNull(Params, "resolve", R.resolve, P) &&
1482 mapOptOrNull(Params, "direction", R.direction, P);
1483}
1484
1485bool fromJSON(const llvm::json::Value &Params, ReferenceContext &R,
1486 llvm::json::Path P) {
1487 llvm::json::ObjectMapper O(Params, P);
1488 return O && O.mapOptional("includeDeclaration", R.includeDeclaration);
1489}
1490
1491bool fromJSON(const llvm::json::Value &Params, ReferenceParams &R,
1492 llvm::json::Path P) {
1494 llvm::json::ObjectMapper O(Params, P);
1495 return fromJSON(Params, Base, P) && O && O.mapOptional("context", R.context);
1496}
1497
1498llvm::json::Value toJSON(SymbolTag Tag) {
1499 return llvm::json::Value(static_cast<int>(Tag));
1500}
1501
1502llvm::json::Value toJSON(const CallHierarchyItem &I) {
1503 llvm::json::Object Result{{"name", I.name},
1504 {"kind", static_cast<int>(I.kind)},
1505 {"range", I.range},
1506 {"selectionRange", I.selectionRange},
1507 {"uri", I.uri}};
1508 if (!I.tags.empty())
1509 Result["tags"] = I.tags;
1510 if (!I.detail.empty())
1511 Result["detail"] = I.detail;
1512 if (!I.data.empty())
1513 Result["data"] = I.data;
1514 return std::move(Result);
1515}
1516
1517bool fromJSON(const llvm::json::Value &Params, CallHierarchyItem &I,
1518 llvm::json::Path P) {
1519 llvm::json::ObjectMapper O(Params, P);
1520
1521 // Populate the required fields only. We don't care about the
1522 // optional fields `Tags` and `Detail` for the purpose of
1523 // client --> server communication.
1524 return O && O.map("name", I.name) && O.map("kind", I.kind) &&
1525 O.map("uri", I.uri) && O.map("range", I.range) &&
1526 O.map("selectionRange", I.selectionRange) &&
1527 mapOptOrNull(Params, "data", I.data, P);
1528}
1529
1530bool fromJSON(const llvm::json::Value &Params,
1531 CallHierarchyIncomingCallsParams &C, llvm::json::Path P) {
1532 llvm::json::ObjectMapper O(Params, P);
1533 return O && O.map("item", C.item);
1534}
1535
1536llvm::json::Value toJSON(const CallHierarchyIncomingCall &C) {
1537 return llvm::json::Object{{"from", C.from}, {"fromRanges", C.fromRanges}};
1538}
1539
1540bool fromJSON(const llvm::json::Value &Params,
1541 CallHierarchyOutgoingCallsParams &C, llvm::json::Path P) {
1542 llvm::json::ObjectMapper O(Params, P);
1543 return O && O.map("item", C.item);
1544}
1545
1546llvm::json::Value toJSON(const CallHierarchyOutgoingCall &C) {
1547 return llvm::json::Object{{"to", C.to}, {"fromRanges", C.fromRanges}};
1548}
1549
1550bool fromJSON(const llvm::json::Value &Params, InlayHintsParams &R,
1551 llvm::json::Path P) {
1552 llvm::json::ObjectMapper O(Params, P);
1553 return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
1554}
1555
1556llvm::json::Value toJSON(const InlayHintKind &Kind) {
1557 switch (Kind) {
1559 return 1;
1561 return 2;
1565 // This is an extension, don't serialize.
1566 return nullptr;
1567 }
1568 llvm_unreachable("Unknown clang.clangd.InlayHintKind");
1569}
1570
1571llvm::json::Value toJSON(const InlayHint &H) {
1572 llvm::json::Object Result{{"position", H.position},
1573 {"label", H.label},
1574 {"paddingLeft", H.paddingLeft},
1575 {"paddingRight", H.paddingRight}};
1576 auto K = toJSON(H.kind);
1577 if (!K.getAsNull())
1578 Result["kind"] = std::move(K);
1579 return std::move(Result);
1580}
1581bool operator==(const InlayHint &A, const InlayHint &B) {
1582 return std::tie(A.position, A.range, A.kind, A.label) ==
1583 std::tie(B.position, B.range, B.kind, B.label);
1584}
1585bool operator<(const InlayHint &A, const InlayHint &B) {
1586 return std::tie(A.position, A.range, A.kind, A.label) <
1587 std::tie(B.position, B.range, B.kind, B.label);
1588}
1589std::string InlayHint::joinLabels() const {
1590 return llvm::join(llvm::map_range(label, [](auto &L) { return L.value; }),
1591 "");
1592}
1593
1594llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, InlayHintKind Kind) {
1595 auto ToString = [](InlayHintKind K) {
1596 switch (K) {
1598 return "parameter";
1600 return "type";
1602 return "designator";
1604 return "block-end";
1606 return "default-argument";
1607 }
1608 llvm_unreachable("Unknown clang.clangd.InlayHintKind");
1609 };
1610 return OS << ToString(Kind);
1611}
1612
1613llvm::json::Value toJSON(const InlayHintLabelPart &L) {
1614 llvm::json::Object Result{{"value", L.value}};
1615 if (L.tooltip)
1616 Result["tooltip"] = *L.tooltip;
1617 if (L.location)
1618 Result["location"] = *L.location;
1619 if (L.command)
1620 Result["command"] = *L.command;
1621 return Result;
1622}
1623
1625 return std::tie(LHS.value, LHS.location) == std::tie(RHS.value, RHS.location);
1626}
1627
1629 return std::tie(LHS.value, LHS.location) < std::tie(RHS.value, RHS.location);
1630}
1631
1632llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
1633 const InlayHintLabelPart &L) {
1634 OS << L.value;
1635 if (L.location)
1636 OS << " (" << L.location << ")";
1637 return OS;
1638}
1639
1640static const char *toString(OffsetEncoding OE) {
1641 switch (OE) {
1643 return "utf-8";
1645 return "utf-16";
1647 return "utf-32";
1649 return "unknown";
1650 }
1651 llvm_unreachable("Unknown clang.clangd.OffsetEncoding");
1652}
1653llvm::json::Value toJSON(const OffsetEncoding &OE) { return toString(OE); }
1654bool fromJSON(const llvm::json::Value &V, OffsetEncoding &OE,
1655 llvm::json::Path P) {
1656 auto Str = V.getAsString();
1657 if (!Str)
1658 return false;
1659 OE = llvm::StringSwitch<OffsetEncoding>(*Str)
1660 .Case("utf-8", OffsetEncoding::UTF8)
1661 .Case("utf-16", OffsetEncoding::UTF16)
1662 .Case("utf-32", OffsetEncoding::UTF32)
1664 return true;
1665}
1666llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, OffsetEncoding Enc) {
1667 return OS << toString(Enc);
1668}
1669
1670bool fromJSON(const llvm::json::Value &Params, SelectionRangeParams &S,
1671 llvm::json::Path P) {
1672 llvm::json::ObjectMapper O(Params, P);
1673 return O && O.map("textDocument", S.textDocument) &&
1674 O.map("positions", S.positions);
1675}
1676
1677llvm::json::Value toJSON(const SelectionRange &Out) {
1678 if (Out.parent) {
1679 return llvm::json::Object{{"range", Out.range},
1680 {"parent", toJSON(*Out.parent)}};
1681 }
1682 return llvm::json::Object{{"range", Out.range}};
1683}
1684
1685bool fromJSON(const llvm::json::Value &Params, DocumentLinkParams &R,
1686 llvm::json::Path P) {
1687 llvm::json::ObjectMapper O(Params, P);
1688 return O && O.map("textDocument", R.textDocument);
1689}
1690
1691llvm::json::Value toJSON(const DocumentLink &DocumentLink) {
1692 return llvm::json::Object{
1693 {"range", DocumentLink.range},
1694 {"target", DocumentLink.target},
1695 };
1696}
1697
1698bool fromJSON(const llvm::json::Value &Params, FoldingRangeParams &R,
1699 llvm::json::Path P) {
1700 llvm::json::ObjectMapper O(Params, P);
1701 return O && O.map("textDocument", R.textDocument);
1702}
1703
1704const llvm::StringLiteral FoldingRange::REGION_KIND = "region";
1705const llvm::StringLiteral FoldingRange::COMMENT_KIND = "comment";
1706const llvm::StringLiteral FoldingRange::IMPORT_KIND = "import";
1707
1708llvm::json::Value toJSON(const FoldingRange &Range) {
1709 llvm::json::Object Result{
1710 {"startLine", Range.startLine},
1711 {"endLine", Range.endLine},
1712 };
1713 if (Range.startCharacter)
1714 Result["startCharacter"] = Range.startCharacter;
1715 if (Range.endCharacter)
1716 Result["endCharacter"] = Range.endCharacter;
1717 if (!Range.kind.empty())
1718 Result["kind"] = Range.kind;
1719 return Result;
1720}
1721
1722llvm::json::Value toJSON(const MemoryTree &MT) {
1723 llvm::json::Object Out;
1724 int64_t Total = MT.self();
1725 Out["_self"] = Total;
1726 for (const auto &Entry : MT.children()) {
1727 auto Child = toJSON(Entry.getSecond());
1728 Total += *Child.getAsObject()->getInteger("_total");
1729 Out[Entry.first] = std::move(Child);
1730 }
1731 Out["_total"] = Total;
1732 return Out;
1733}
1734
1735bool fromJSON(const llvm::json::Value &Params, ASTParams &R,
1736 llvm::json::Path P) {
1737 llvm::json::ObjectMapper O(Params, P);
1738 return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
1739}
1740
1741llvm::json::Value toJSON(const ASTNode &N) {
1742 llvm::json::Object Result{
1743 {"role", N.role},
1744 {"kind", N.kind},
1745 };
1746 if (!N.children.empty())
1747 Result["children"] = N.children;
1748 if (!N.detail.empty())
1749 Result["detail"] = N.detail;
1750 if (!N.arcana.empty())
1751 Result["arcana"] = N.arcana;
1752 if (N.range)
1753 Result["range"] = *N.range;
1754 return Result;
1755}
1756
1757llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ASTNode &Root) {
1758 std::function<void(const ASTNode &, unsigned)> Print = [&](const ASTNode &N,
1759 unsigned Level) {
1760 OS.indent(2 * Level) << N.role << ": " << N.kind;
1761 if (!N.detail.empty())
1762 OS << " - " << N.detail;
1763 OS << "\n";
1764 for (const ASTNode &C : N.children)
1765 Print(C, Level + 1);
1766 };
1767 Print(Root, 0);
1768 return OS;
1769}
1770
1771bool fromJSON(const llvm::json::Value &E, SymbolID &S, llvm::json::Path P) {
1772 auto Str = E.getAsString();
1773 if (!Str) {
1774 P.report("expected a string");
1775 return false;
1776 }
1777 auto ID = SymbolID::fromStr(*Str);
1778 if (!ID) {
1779 elog("Malformed symbolid: {0}", ID.takeError());
1780 P.report("malformed symbolid");
1781 return false;
1782 }
1783 S = *ID;
1784 return true;
1785}
1786llvm::json::Value toJSON(const SymbolID &S) { return S.str(); }
1787
1788} // namespace clangd
1789} // namespace clang
A context is an immutable container for per-request data that must be propagated through layers that ...
Definition Context.h:69
const Type * get(const Key< Type > &Key) const
Get data stored for a typed Key.
Definition Context.h:98
static llvm::Expected< SymbolID > fromStr(llvm::StringRef)
Definition SymbolID.cpp:37
std::string str() const
Definition SymbolID.cpp:35
A URI describes the location of a source file.
Definition URI.h:28
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:252
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
Resolves the absolute path of U.
Definition URI.cpp:244
static llvm::Expected< URI > parse(llvm::StringRef Uri)
Parse a URI string "<scheme>:[//<authority>/]<path>".
Definition URI.cpp:176
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
Definition AST.cpp:44
@ Created
The file got created.
Definition Protocol.h:831
@ Deleted
The file got deleted.
Definition Protocol.h:835
@ Info
An information message.
Definition Protocol.h:755
constexpr auto CompletionItemKindMin
Definition Protocol.h:381
SymbolTag
Symbol tags are extra annotations that can be attached to a symbol.
Definition Protocol.h:1126
constexpr auto SymbolKindMin
Definition Protocol.h:422
CompletionItemKind
The kind of a completion entry.
Definition Protocol.h:351
static const char * toString(OffsetEncoding OE)
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
Definition Headers.cpp:356
constexpr unsigned SemanticTokenEncodingSize
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
std::bitset< SymbolKindMax+1 > SymbolKindBitset
Definition Protocol.h:424
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
Definition Index.cpp:45
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
Definition Protocol.cpp:288
void removeCompletionLabelDetails(CompletionItem &C)
Remove the labelDetails field (for clients that don't support it).
bool operator<(const Ref &L, const Ref &R)
Definition Ref.h:98
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
Definition Protocol.h:385
static llvm::StringRef toTextKind(MarkupKind Kind)
InlayHintKind
Inlay hint kinds.
Definition Protocol.h:1725
@ BlockEnd
A hint after function, type or namespace definition, indicating the defined symbol name of the defini...
Definition Protocol.h:1755
@ DefaultArgument
An inlay hint that is for a default argument.
Definition Protocol.h:1764
@ Parameter
An inlay hint that is for a parameter.
Definition Protocol.h:1738
@ Type
An inlay hint that for a type annotation.
Definition Protocol.h:1731
@ Designator
A hint before an element of an aggregate braced initializer list, indicating what it is initializing.
Definition Protocol.h:1745
static llvm::json::Value encodeTokens(llvm::ArrayRef< SemanticToken > Toks)
SymbolKind indexSymbolKindToSymbolKind(const index::SymbolInfo &Info)
Definition Protocol.cpp:306
void elog(const char *Fmt, Ts &&... Vals)
Definition Logger.h:61
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request, llvm::json::Path P)
Definition Index.cpp:30
SymbolKind
A symbol kind.
Definition Protocol.h:393
cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccessCheck P
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Simplified description of a clang AST node.
Definition Protocol.h:2079
std::optional< Range > range
The range of the original source file covered by this node.
Definition Protocol.h:2097
std::vector< ASTNode > children
Nodes nested within this one, such as the operands of a BinaryOperator.
Definition Protocol.h:2099
std::string role
The general kind of node, such as "expression" Corresponds to the base AST node type such as Expr.
Definition Protocol.h:2082
std::string kind
The specific kind of node this is, such as "BinaryOperator".
Definition Protocol.h:2086
std::string detail
Brief additional information, such as "||" for the particular operator.
Definition Protocol.h:2089
std::string arcana
A one-line dump of detailed information about the node.
Definition Protocol.h:2094
Payload for textDocument/ast request.
Definition Protocol.h:2066
std::optional< Range > range
The position of the node to be dumped.
Definition Protocol.h:2073
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:2068
std::optional< std::string > failureReason
Definition Protocol.h:1262
Represents an incoming call, e.g. a caller of a method or constructor.
Definition Protocol.h:1676
The parameter of a callHierarchy/incomingCalls request.
Definition Protocol.h:1669
Represents programming constructs like functions or constructors in the context of call hierarchy.
Definition Protocol.h:1636
std::string name
The name of this item.
Definition Protocol.h:1638
URIForFile uri
The resource identifier of this item.
Definition Protocol.h:1650
Range range
The range enclosing this symbol not including leading / trailing whitespace but everything else,...
Definition Protocol.h:1654
SymbolKind kind
The kind of this item.
Definition Protocol.h:1641
std::vector< SymbolTag > tags
Tags for this item.
Definition Protocol.h:1644
std::string data
An optional 'data' field, which can be used to identify a call hierarchy item in an incomingCalls or ...
Definition Protocol.h:1663
std::string detail
More detaill for this item, e.g. the signature of a function.
Definition Protocol.h:1647
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition Protocol.h:1659
Represents an outgoing call, e.g.
Definition Protocol.h:1701
The parameter of a callHierarchy/outgoingCalls request.
Definition Protocol.h:1693
std::string description
A human-readable string which is rendered less prominent in the user interface.
Definition Protocol.h:288
std::string label
A human-readable string describing the actual change.
Definition Protocol.h:280
std::optional< bool > needsConfirmation
A flag which indicates that user confirmation is needed before applying the change.
Definition Protocol.h:284
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
Definition Protocol.h:595
std::vector< std::string > compilationCommand
Definition Protocol.h:597
bool HierarchicalDocumentSymbol
Client supports hierarchical document symbols.
Definition Protocol.h:497
bool WorkDoneProgress
The client supports progress notifications.
Definition Protocol.h:562
bool DiagnosticCategory
Whether the client accepts diagnostics with category attached to it using the "category" extension.
Definition Protocol.h:479
bool CompletionLabelDetail
The client has support for completion item label details.
Definition Protocol.h:532
MarkupKind HoverContentFormat
The content format that should be used for Hover requests.
Definition Protocol.h:554
bool CodeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
Definition Protocol.h:536
bool OffsetsInSignatureHelp
Client supports processing label offsets instead of a simple label string.
Definition Protocol.h:511
bool DiagnosticFixes
Whether the client accepts diagnostics with codeActions attached inline.
Definition Protocol.h:470
bool HasSignatureHelp
Client supports signature help.
Definition Protocol.h:501
bool TheiaSemanticHighlighting
Client supports Theia semantic highlighting extension.
Definition Protocol.h:546
bool SemanticTokenRefreshSupport
Whether the client implementation supports a refresh request sent from the server to the client.
Definition Protocol.h:576
bool DocumentChanges
The client supports versioned document changes for WorkspaceEdit.
Definition Protocol.h:579
bool ImplicitProgressCreation
The client supports implicit $/progress work-done progress streams, without a preceding window/workDo...
Definition Protocol.h:568
MarkupKind SignatureHelpDocumentationFormat
The documentation format that should be used for textDocument/signatureHelp.
Definition Protocol.h:516
bool DiagnosticRelatedInformation
Whether the client accepts diagnostics with related locations.
Definition Protocol.h:474
bool CompletionFixes
Client supports completions with additionalTextEdit near the cursor.
Definition Protocol.h:488
bool RenamePrepareSupport
The client supports testing for validity of rename operations before execution.
Definition Protocol.h:558
bool InsertReplace
Client supports insert replace edit to control different behavior if a completion item is inserted in...
Definition Protocol.h:528
std::optional< std::vector< OffsetEncoding > > PositionEncodings
Supported encodings for LSP character offsets.
Definition Protocol.h:550
bool CancelsStaleRequests
Whether the client claims to cancel stale requests.
Definition Protocol.h:572
std::optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
Definition Protocol.h:520
bool CompletionSnippets
Client supports snippets as insert text.
Definition Protocol.h:483
MarkupKind CompletionDocumentationFormat
The documentation format that should be used for textDocument/completion.
Definition Protocol.h:524
bool SemanticTokens
Client advertises support for the semanticTokens feature.
Definition Protocol.h:541
bool ChangeAnnotation
The client supports change annotations on text edits,.
Definition Protocol.h:582
bool LineFoldingOnly
Client signals that it only supports folding complete lines.
Definition Protocol.h:507
bool InactiveRegions
Whether the client supports the textDocument/inactiveRegions notification.
Definition Protocol.h:587
std::optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
Definition Protocol.h:465
bool ReferenceContainer
Client supports displaying a container string for results of textDocument/reference (clangd extension...
Definition Protocol.h:493
std::vector< Diagnostic > diagnostics
An array of diagnostics known on the client side overlapping the range provided to the textDocument/c...
Definition Protocol.h:1016
std::vector< std::string > only
Requested kind of actions to return.
Definition Protocol.h:1022
CodeActionContext context
Context carrying additional information.
Definition Protocol.h:1034
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Definition Protocol.h:1028
Range range
The range for which the command was invoked.
Definition Protocol.h:1031
A code action represents a change that can be performed in code, e.g.
Definition Protocol.h:1094
static const llvm::StringLiteral INFO_KIND
Definition Protocol.h:1103
bool isPreferred
Marks this as a preferred action.
Definition Protocol.h:1113
static const llvm::StringLiteral REFACTOR_KIND
Definition Protocol.h:1102
std::optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
Definition Protocol.h:1106
static const llvm::StringLiteral QUICKFIX_KIND
Definition Protocol.h:1101
std::optional< WorkspaceEdit > edit
The workspace edit this code action performs.
Definition Protocol.h:1116
std::optional< Command > command
A command this code action executes.
Definition Protocol.h:1120
std::optional< std::string > kind
The kind of the code action.
Definition Protocol.h:1100
std::string title
A short, human-readable, title for this code action.
Definition Protocol.h:1096
Structure to capture a description for an error code.
Definition Protocol.h:941
CompletionTriggerKind triggerKind
How the completion was triggered.
Definition Protocol.h:1290
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
Definition Protocol.h:1293
Additional details for a completion item label.
Definition Protocol.h:1341
std::string detail
An optional string which is rendered less prominently directly after label without any spacing.
Definition Protocol.h:1345
std::string description
An optional string which is rendered less prominently after CompletionItemLabelDetails....
Definition Protocol.h:1350
std::string sortText
A string that should be used when comparing this item with other items.
Definition Protocol.h:1375
std::string filterText
A string that should be used when filtering a set of completion items.
Definition Protocol.h:1379
std::string detail
A human-readable string with additional information about this item, like type or symbol information.
Definition Protocol.h:1368
InsertTextFormat insertTextFormat
The format of the insert text.
Definition Protocol.h:1387
CompletionItemKind kind
The kind of this completion item.
Definition Protocol.h:1364
std::vector< TextEdit > additionalTextEdits
An optional array of additional text edits that are applied when selecting this completion.
Definition Protocol.h:1403
std::optional< MarkupContent > documentation
A human-readable string that represents a doc-comment.
Definition Protocol.h:1371
std::string insertText
A string that should be inserted to a document when selecting this completion.
Definition Protocol.h:1383
bool deprecated
Indicates if this item is deprecated.
Definition Protocol.h:1406
std::optional< CompletionItemLabelDetails > labelDetails
Additional details for the label.
Definition Protocol.h:1360
std::optional< std::variant< TextEdit, InsertReplaceEdit > > textEdit
An edit which is applied to a document when selecting this completion.
Definition Protocol.h:1398
float score
The score that clangd calculates to rank the returned completions.
Definition Protocol.h:1413
std::string label
The label of this completion item.
Definition Protocol.h:1357
Represents a collection of completion items to be presented in the editor.
Definition Protocol.h:1433
std::vector< CompletionItem > items
The completion items.
Definition Protocol.h:1439
bool isIncomplete
The list is not complete.
Definition Protocol.h:1436
std::optional< int > limit
Max results to return, overriding global default.
Definition Protocol.h:1302
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Definition Protocol.h:605
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
Definition Protocol.h:608
A top-level diagnostic that may have Notes and Fixes.
Definition Diagnostics.h:98
Represents a related message and source code location for a diagnostic.
Definition Protocol.h:919
std::string message
The message of this related diagnostic information.
Definition Protocol.h:923
Location location
The location of this related diagnostic information.
Definition Protocol.h:921
llvm::json::Object data
A data entry field that is preserved between a textDocument/publishDiagnostics notification and textD...
Definition Protocol.h:992
std::string code
The diagnostic's code. Can be omitted.
Definition Protocol.h:957
Range range
The range at which the message applies.
Definition Protocol.h:950
std::string source
A human-readable string describing the source of this diagnostic, e.g.
Definition Protocol.h:964
std::string message
The diagnostic's message.
Definition Protocol.h:967
int severity
The diagnostic's severity.
Definition Protocol.h:954
std::optional< std::string > category
The diagnostic's category.
Definition Protocol.h:980
bool forceRebuild
Force a complete rebuild of the file, ignoring all cached state.
Definition Protocol.h:824
VersionedTextDocumentIdentifier textDocument
The document that did change.
Definition Protocol.h:809
std::optional< bool > wantDiagnostics
Forces diagnostics to be generated, or to not be generated, for this version of the file.
Definition Protocol.h:818
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
Definition Protocol.h:812
std::vector< FileEvent > changes
The actual file events.
Definition Protocol.h:850
TextDocumentIdentifier textDocument
The document that was closed.
Definition Protocol.h:780
TextDocumentItem textDocument
The document that was opened.
Definition Protocol.h:773
TextDocumentIdentifier textDocument
The document that was saved.
Definition Protocol.h:787
TextDocumentIdentifier textDocument
The document to format.
Definition Protocol.h:904
A document highlight is a range inside a text document which deserves special attention.
Definition Protocol.h:1524
Range range
The range this highlight applies to.
Definition Protocol.h:1526
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
Definition Protocol.h:1529
Parameters for the document link request.
Definition Protocol.h:1988
TextDocumentIdentifier textDocument
The document to provide document links for.
Definition Protocol.h:1990
Position position
The position at which this request was sent.
Definition Protocol.h:894
std::string ch
The character that has been typed.
Definition Protocol.h:897
TextDocumentIdentifier textDocument
The document to format.
Definition Protocol.h:891
TextDocumentIdentifier textDocument
The document to format.
Definition Protocol.h:871
TextDocumentIdentifier textDocument
The document to format.
Definition Protocol.h:881
std::vector< Range > ranges
The list of ranges to format.
Definition Protocol.h:884
TextDocumentIdentifier textDocument
Definition Protocol.h:911
Represents programming constructs like variables, classes, interfaces etc.
Definition Protocol.h:1157
std::vector< SymbolTag > tags
The tags for this symbol.
Definition Protocol.h:1171
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition Protocol.h:1181
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
Definition Protocol.h:1184
std::string detail
More detail for this symbol, e.g the signature of a function.
Definition Protocol.h:1162
std::string name
The name of this symbol.
Definition Protocol.h:1159
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
Definition Protocol.h:1177
bool deprecated
Indicates if this symbol is deprecated.
Definition Protocol.h:1168
SymbolKind kind
The kind of this symbol.
Definition Protocol.h:1165
A set of edits generated for a single file.
Definition SourceCode.h:189
std::string command
The identifier of the actual command handler.
Definition Protocol.h:1075
FileChangeType type
The change type.
Definition Protocol.h:844
URIForFile uri
The file's URI.
Definition Protocol.h:842
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
Definition Protocol.h:1872
URIForFile uri
The text document's URI.
Definition Protocol.h:1874
std::string state
The human-readable string presents the current state of the file, can be shown in the UI (e....
Definition Protocol.h:1877
TextDocumentIdentifier textDocument
Definition Protocol.h:2024
Stores information about a region of code that can be folded.
Definition Protocol.h:2030
static const llvm::StringLiteral REGION_KIND
Definition Protocol.h:2036
static const llvm::StringLiteral COMMENT_KIND
Definition Protocol.h:2037
static const llvm::StringLiteral IMPORT_KIND
Definition Protocol.h:2038
std::optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover,...
Definition Protocol.h:1318
MarkupContent contents
The hover's content.
Definition Protocol.h:1314
Parameters for the inactive regions (server-side) push notification.
Definition Protocol.h:1956
TextDocumentIdentifier TextDocument
The textdocument these inactive regions belong to.
Definition Protocol.h:1958
std::vector< Range > InactiveRegions
The inactive regions that should be sent.
Definition Protocol.h:1960
Clangd extension: parameters configurable at initialize time.
Definition Protocol.h:615
std::optional< std::string > compilationDatabasePath
Definition Protocol.h:620
bool FileStatus
Clients supports show file status for textDocument/clangd.fileStatus.
Definition Protocol.h:627
std::vector< std::string > fallbackFlags
Definition Protocol.h:624
ConfigurationSettings ConfigSettings
Definition Protocol.h:618
llvm::json::Object rawCapabilities
The same data as capabilities, but not parsed (to expose to modules).
Definition Protocol.h:656
InitializationOptions initializationOptions
User-provided initialization options.
Definition Protocol.h:662
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
Definition Protocol.h:654
std::optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
Definition Protocol.h:659
std::optional< int > processId
The process Id of the parent process that started the server.
Definition Protocol.h:637
std::optional< std::string > rootPath
The rootPath of the workspace.
Definition Protocol.h:643
std::optional< URIForFile > rootUri
The rootUri of the workspace.
Definition Protocol.h:648
An inlay hint label part allows for interactive and composite labels of inlay hints.
Definition Protocol.h:1776
std::optional< Location > location
An optional source code location that represents this label part.
Definition Protocol.h:1803
std::optional< MarkupContent > tooltip
The tooltip text when you hover over this label part.
Definition Protocol.h:1790
std::optional< Command > command
An optional command for this label part.
Definition Protocol.h:1809
std::string value
The value of this label part.
Definition Protocol.h:1785
Inlay hint information.
Definition Protocol.h:1817
InlayHintKind kind
The kind of this hint.
Definition Protocol.h:1829
std::string joinLabels() const
Join the label[].value together.
bool paddingRight
Render padding after the hint.
Definition Protocol.h:1843
bool paddingLeft
Render padding before the hint.
Definition Protocol.h:1836
Position position
The position of this hint.
Definition Protocol.h:1819
std::vector< InlayHintLabelPart > label
The label of this hint.
Definition Protocol.h:1825
A parameter literal used in inlay hint requests.
Definition Protocol.h:1712
std::optional< Range > range
The visible document range for which inlay hints should be computed.
Definition Protocol.h:1720
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1714
URIForFile uri
The text document's URI.
Definition Protocol.h:214
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
Definition MemoryTree.h:30
const llvm::DenseMap< llvm::StringRef, MemoryTree > & children() const
Returns edges to direct children of this node.
size_t self() const
Returns total number of bytes used by this node only.
Definition MemoryTree.h:65
A single parameter of a particular signature.
Definition Protocol.h:1444
std::string labelString
The label of this parameter. Ignored when labelOffsets is set.
Definition Protocol.h:1447
std::string documentation
The documentation of this parameter. Optional.
Definition Protocol.h:1456
std::optional< std::pair< unsigned, unsigned > > labelOffsets
Inclusive start and exclusive end offsets withing the containing signature label.
Definition Protocol.h:1453
int line
Line position in a document (zero-based).
Definition Protocol.h:159
int character
Character offset on a line in a document (zero-based).
Definition Protocol.h:164
std::string placeholder
Placeholder text to use in the editor if non-empty.
Definition Protocol.h:1514
Range range
Range of the string to rename.
Definition Protocol.h:1512
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
Definition Protocol.h:1003
std::optional< int64_t > version
The version number of the document the diagnostics are published for.
Definition Protocol.h:1005
URIForFile uri
The URI for which diagnostic information is reported.
Definition Protocol.h:1001
Position start
The range's start position.
Definition Protocol.h:188
Position end
The range's end position.
Definition Protocol.h:191
bool includeDeclaration
Include the declaration of the current symbol.
Definition Protocol.h:1862
Extends Locations returned by textDocument/references with extra info.
Definition Protocol.h:234
std::optional< std::string > containerName
clangd extension: contains the name of the function or class in which the reference occurs
Definition Protocol.h:237
TextDocumentIdentifier textDocument
The document that was opened.
Definition Protocol.h:1499
Position position
The position at which this request was sent.
Definition Protocol.h:1502
std::string newName
The new name of the symbol.
Definition Protocol.h:1505
Parameters for the typeHierarchy/resolve request.
Definition Protocol.h:1618
TypeHierarchyItem item
The item to resolve.
Definition Protocol.h:1620
int resolve
The hierarchy levels to resolve. 0 indicates no level.
Definition Protocol.h:1623
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition Protocol.h:1626
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1966
std::vector< Position > positions
The positions inside the text document.
Definition Protocol.h:1969
std::unique_ptr< SelectionRange > parent
The parent selection range containing this range.
Definition Protocol.h:1983
Range range
The range of this selection range.
Definition Protocol.h:1978
Specifies a single semantic token in the document.
Definition Protocol.h:1885
unsigned length
the length of the token. A token cannot be multiline
Definition Protocol.h:1892
unsigned deltaStart
token start character, relative to the previous token (relative to 0 or the previous token's start if...
Definition Protocol.h:1890
unsigned deltaLine
token line number, relative to the previous token
Definition Protocol.h:1887
unsigned tokenType
will be looked up in SemanticTokensLegend.tokenTypes
Definition Protocol.h:1894
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
Definition Protocol.h:1896
Body of textDocument/semanticTokens/full/delta request.
Definition Protocol.h:1923
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1925
std::string previousResultId
The previous result id.
Definition Protocol.h:1927
Describes a replacement of a contiguous range of semanticTokens.
Definition Protocol.h:1933
This models LSP SemanticTokensDelta | SemanticTokens, which is the result of textDocument/semanticTok...
Definition Protocol.h:1945
std::optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
Definition Protocol.h:1950
std::optional< std::vector< SemanticTokensEdit > > edits
Set if we computed edits relative to a previous set of tokens.
Definition Protocol.h:1948
Body of textDocument/semanticTokens/full request.
Definition Protocol.h:1914
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1916
A versioned set of tokens.
Definition Protocol.h:1901
std::vector< SemanticToken > tokens
The actual tokens.
Definition Protocol.h:1909
The show message notification is sent from a server to a client to ask the client to display a partic...
Definition Protocol.h:763
MessageType type
The message type.
Definition Protocol.h:765
std::string message
The actual message.
Definition Protocol.h:767
Represents the signature of a callable.
Definition Protocol.h:1477
int activeSignature
The active signature.
Definition Protocol.h:1483
std::vector< SignatureInformation > signatures
The resulting signatures.
Definition Protocol.h:1480
int activeParameter
The active parameter of the active signature.
Definition Protocol.h:1486
Represents the signature of something callable.
Definition Protocol.h:1461
MarkupContent documentation
The documentation of this signature. Optional.
Definition Protocol.h:1467
std::vector< ParameterInformation > parameters
The parameters of this signature.
Definition Protocol.h:1470
std::string label
The label of this signature. Mandatory.
Definition Protocol.h:1464
Represents information about identifier.
Definition Protocol.h:1220
std::optional< Location > definitionRange
Definition Protocol.h:1236
std::optional< Location > declarationRange
Definition Protocol.h:1234
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol.
Definition Protocol.h:1230
Represents information about programming constructs like variables, classes, interfaces etc.
Definition Protocol.h:1191
std::string containerName
The name of the symbol containing this symbol.
Definition Protocol.h:1205
std::string name
The name of this symbol.
Definition Protocol.h:1193
The class presents a C++ symbol, e.g.
Definition Symbol.h:39
std::optional< Range > range
The range of the document that changed.
Definition Protocol.h:794
std::string text
The new text of the range/document.
Definition Protocol.h:800
std::optional< int > rangeLength
The length of the range that got replaced.
Definition Protocol.h:797
VersionedTextDocumentIdentifier textDocument
The text document to change.
Definition Protocol.h:295
std::vector< TextEdit > edits
The edits to be applied.
Definition Protocol.h:299
URIForFile uri
The text document's URI.
Definition Protocol.h:134
std::string languageId
The text document's language identifier.
Definition Protocol.h:309
std::optional< int64_t > version
The version number of this document (it will strictly increase after each change, including undo/redo...
Definition Protocol.h:315
URIForFile uri
The text document's URI.
Definition Protocol.h:306
std::string text
The content of the opened text document.
Definition Protocol.h:318
TextDocumentIdentifier textDocument
The text document.
Definition Protocol.h:1269
Position position
The position inside the text document.
Definition Protocol.h:1272
std::string newText
The string to be inserted.
Definition Protocol.h:251
ChangeAnnotationIdentifier annotationId
The actual annotation identifier (optional) If empty, then this field is nullopt.
Definition Protocol.h:255
Range range
The range of the text document to be manipulated.
Definition Protocol.h:247
Arguments for the 'applyTweak' command.
Definition Protocol.h:1062
Used to resolve a client provided item back.
Definition Protocol.h:1587
std::optional< std::vector< ResolveParams > > parents
std::nullopt means parents aren't resolved and empty is no parents.
Definition Protocol.h:1590
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else,...
Definition Protocol.h:1580
URIForFile uri
The resource identifier of this item.
Definition Protocol.h:1576
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Definition Protocol.h:1584
SymbolKind kind
The kind of this item.
Definition Protocol.h:1570
std::optional< std::vector< TypeHierarchyItem > > children
If this type hierarchy item is resolved, it contains the direct children of the current item.
Definition Protocol.h:1609
std::optional< std::vector< TypeHierarchyItem > > parents
This is a clangd exntesion.
Definition Protocol.h:1603
bool deprecated
true if the hierarchy item is deprecated.
Definition Protocol.h:1600
std::optional< std::string > detail
More detail for this item, e.g. the signature of a function.
Definition Protocol.h:1573
ResolveParams data
A data entry field that is preserved between a type hierarchy prepare and supertypes or subtypes requ...
Definition Protocol.h:1596
std::string name
The name of this item.
Definition Protocol.h:1567
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
Definition Protocol.h:1553
int resolve
The hierarchy levels to resolve.
Definition Protocol.h:1556
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
Definition Protocol.h:1560
std::string uri() const
Definition Protocol.h:108
static llvm::Expected< URIForFile > fromURI(const URI &U, llvm::StringRef HintPath)
Definition Protocol.cpp:59
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
Canonicalizes AbsPath via URI.
Definition Protocol.cpp:46
std::optional< std::int64_t > version
The version number of this document.
Definition Protocol.h:151
To start progress reporting a $/progress notification with the following payload must be sent.
Definition Protocol.h:684
Signals the end of progress reporting.
Definition Protocol.h:742
Reporting progress is done using the following payload.
Definition Protocol.h:710
The edit should either provide changes or documentChanges.
Definition Protocol.h:1041
std::optional< std::vector< TextDocumentEdit > > documentChanges
Versioned document edits.
Definition Protocol.h:1049
std::map< std::string, ChangeAnnotation > changeAnnotations
A map of change annotations that can be referenced in AnnotatedTextEdit.
Definition Protocol.h:1053
std::optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
Definition Protocol.h:1043
The parameters of a Workspace Symbol Request.
Definition Protocol.h:1243
std::string query
A query string to filter symbols by.
Definition Protocol.h:1246
std::optional< int > limit
Max results to return, overriding global default.
Definition Protocol.h:1250