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"
32bool mapOptOrNull(
const llvm::json::Value &Params, llvm::StringLiteral Prop,
33 T &Out, llvm::json::Path P) {
34 auto *O = Params.getAsObject();
36 auto *V = O->get(Prop);
38 if (!V || V->getAsNull())
47 llvm::StringRef TUPath) {
48 assert(llvm::sys::path::is_absolute(AbsPath) &&
"the path is relative");
51 elog(
"URIForFile: failed to resolve path {0} with TU path {1}: "
52 "{2}.\nUsing unresolved path.",
53 AbsPath, TUPath, Resolved.takeError());
60 llvm::StringRef HintPath) {
63 return Resolved.takeError();
68 if (
auto S = E.getAsString()) {
71 consumeError(Parsed.takeError());
72 P.report(
"failed to parse URI");
75 if (Parsed->scheme() !=
"file" && Parsed->scheme() !=
"test") {
76 P.report(
"clangd only supports 'file' URI scheme for workspace files");
82 P.report(
"unresolvable URI");
83 consumeError(U.takeError());
99 return llvm::json::Object{{
"uri", R.
uri}};
103 llvm::json::Path P) {
104 llvm::json::ObjectMapper O(Params, P);
105 return O && O.map(
"uri", R.
uri);
110 Result.getAsObject()->try_emplace(
"version", R.
version);
116 llvm::json::ObjectMapper O(Params, P);
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);
128 return llvm::json::Object{
130 {
"character", P.character},
135 return OS << P.line <<
':' << P.character;
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);
144 return llvm::json::Object{
151 return OS << R.
start <<
'-' << R.
end;
155 return llvm::json::Object{
162 return OS << L.
range <<
'@' << L.
uri;
166 llvm::json::Object Result{
171 Result.insert({
"containerName", P.containerName});
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);
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) &&
196 llvm::json::Object Result{
198 {
"newText", P.newText},
200 if (!P.annotationId.empty())
201 Result[
"annotationId"] = P.annotationId;
206 return llvm::json::Object{
207 {
"newText", P.newText},
208 {
"insert", P.insert},
209 {
"replace", P.replace},
214 llvm::json::Path P) {
215 llvm::json::ObjectMapper O(Params, P);
216 return O && O.map(
"label", R.
label) &&
221 llvm::json::Object Result{{
"label", CA.
label}};
230 llvm::json::Path P) {
231 llvm::json::ObjectMapper O(Params, P);
235 llvm::json::Object Result{{
"textDocument", P.textDocument},
241 OS << TE.
range <<
" => \"";
242 llvm::printEscapedString(TE.
newText, OS);
247 if (
auto S = E.getAsString()) {
252 if (*S ==
"messages") {
256 if (*S ==
"verbose") {
265 if (
auto T = E.getAsInteger()) {
266 if (*T <
static_cast<int>(SymbolKind::File) ||
267 *T >
static_cast<int>(SymbolKind::TypeParameter))
276 llvm::json::Path P) {
277 if (
auto *A = E.getAsArray()) {
278 for (
size_t I = 0; I < A->size(); ++I) {
280 if (
fromJSON((*A)[I], KindOut, P.index(I)))
281 Out.set(
size_t(KindOut));
290 auto KindVal =
static_cast<size_t>(Kind);
291 if (KindVal >=
SymbolKindMin && KindVal <= SupportedSymbolKinds.size() &&
292 SupportedSymbolKinds[KindVal])
297 case SymbolKind::Struct:
298 return SymbolKind::Class;
299 case SymbolKind::EnumMember:
300 return SymbolKind::Enum;
302 return SymbolKind::String;
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;
340 return SymbolKind::Class;
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;
375 llvm_unreachable(
"invalid symbol kind");
379 llvm::json::Path P) {
380 const llvm::json::Object *O = Params.getAsObject();
382 P.report(
"expected object");
385 if (
auto *TextDocument = O->getObject(
"textDocument")) {
386 if (
auto *SemanticHighlighting =
387 TextDocument->getObject(
"semanticHighlightingCapabilities")) {
388 if (
auto SemanticHighlightingSupport =
389 SemanticHighlighting->getBoolean(
"semanticHighlighting"))
392 if (
auto *InactiveRegions =
393 TextDocument->getObject(
"inactiveRegionsCapabilities")) {
394 if (
auto InactiveRegionsSupport =
395 InactiveRegions->getBoolean(
"inactiveRegions")) {
399 if (TextDocument->getObject(
"semanticTokens"))
401 if (
auto *Diagnostics = TextDocument->getObject(
"publishDiagnostics")) {
402 if (
auto CategorySupport = Diagnostics->getBoolean(
"categorySupport"))
404 if (
auto CodeActions = Diagnostics->getBoolean(
"codeActionsInline"))
406 if (
auto RelatedInfo = Diagnostics->getBoolean(
"relatedInformation"))
409 if (
auto *
References = TextDocument->getObject(
"references"))
410 if (
auto ContainerSupport =
References->getBoolean(
"container"))
412 if (
auto *Completion = TextDocument->getObject(
"completion")) {
413 if (
auto *Item = Completion->getObject(
"completionItem")) {
414 if (
auto SnippetSupport = Item->getBoolean(
"snippetSupport"))
416 if (
auto LabelDetailsSupport = Item->getBoolean(
"labelDetailsSupport"))
418 if (
const auto *DocumentationFormat =
419 Item->getArray(
"documentationFormat")) {
420 for (
const auto &Format : *DocumentationFormat) {
425 if (
auto IRSupport = Item->getBoolean(
"insertReplaceSupport"))
428 if (
auto *ItemKind = Completion->getObject(
"completionItemKind")) {
429 if (
auto *ValueSet = ItemKind->get(
"valueSet")) {
432 P.field(
"textDocument")
434 .field(
"completionItemKind")
439 if (
auto EditsNearCursor = Completion->getBoolean(
"editsNearCursor"))
442 if (
auto *
CodeAction = TextDocument->getObject(
"codeAction")) {
443 if (
CodeAction->getObject(
"codeActionLiteralSupport"))
446 if (
auto *
DocumentSymbol = TextDocument->getObject(
"documentSymbol")) {
447 if (
auto HierarchicalSupport =
451 if (
auto *
Hover = TextDocument->getObject(
"hover")) {
452 if (
auto *ContentFormat =
Hover->getArray(
"contentFormat")) {
453 for (
const auto &Format : *ContentFormat) {
459 if (
auto *Help = TextDocument->getObject(
"signatureHelp")) {
461 if (
auto *
Info = Help->getObject(
"signatureInformation")) {
462 if (
auto *
Parameter =
Info->getObject(
"parameterInformation")) {
463 if (
auto OffsetSupport =
Parameter->getBoolean(
"labelOffsetSupport"))
466 if (
const auto *DocumentationFormat =
467 Info->getArray(
"documentationFormat")) {
468 for (
const auto &Format : *DocumentationFormat) {
475 if (
auto *Folding = TextDocument->getObject(
"foldingRange")) {
476 if (
auto LineFolding = Folding->getBoolean(
"lineFoldingOnly"))
479 if (
auto *Rename = TextDocument->getObject(
"rename")) {
480 if (
auto RenameSupport = Rename->getBoolean(
"prepareSupport"))
484 if (
auto *Workspace = O->getObject(
"workspace")) {
485 if (
auto *
Symbol = Workspace->getObject(
"symbol")) {
487 if (
auto *ValueSet =
SymbolKind->get(
"valueSet")) {
498 if (
auto *
SemanticTokens = Workspace->getObject(
"semanticTokens")) {
499 if (
auto RefreshSupport =
SemanticTokens->getBoolean(
"refreshSupport"))
502 if (
auto *
WorkspaceEdit = Workspace->getObject(
"workspaceEdit")) {
503 if (
auto DocumentChanges =
WorkspaceEdit->getBoolean(
"documentChanges"))
510 if (
auto *Window = O->getObject(
"window")) {
511 if (
auto WorkDoneProgress = Window->getBoolean(
"workDoneProgress"))
513 if (
auto Implicit = Window->getBoolean(
"implicitWorkDoneProgressCreate"))
516 if (
auto *General = O->getObject(
"general")) {
517 if (
auto *StaleRequestSupport = General->getObject(
"staleRequestSupport")) {
518 if (
auto Cancel = StaleRequestSupport->getBoolean(
"cancel"))
521 if (
auto *PositionEncodings = General->get(
"positionEncodings")) {
524 P.field(
"general").field(
"positionEncodings")))
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")))
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"))
544 if (
auto *
References = TextDocument->getObject(
"references")) {
545 if (
auto ContainerSupport =
References->getBoolean(
"container")) {
549 if (
auto *Diagnostics = TextDocument->getObject(
"publishDiagnostics")) {
550 if (
auto CodeActions = Diagnostics->getBoolean(
"codeActionsInline")) {
554 if (
auto *InactiveRegions =
555 TextDocument->getObject(
"inactiveRegionsCapabilities")) {
556 if (
auto InactiveRegionsSupport =
557 InactiveRegions->getBoolean(
"inactiveRegions")) {
562 if (
auto *Window = Experimental->getObject(
"window")) {
564 Window->getBoolean(
"implicitWorkDoneProgressCreate")) {
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")))
583 llvm::json::Path P) {
584 llvm::json::ObjectMapper O(Params, P);
593 if (
auto *RawCaps = Params.getAsObject()->getObject(
"capabilities"))
595 O.map(
"trace", R.
trace);
601 return llvm::json::Object{{
"token", P.token}};
605 llvm::json::Object Result{
610 Result[
"cancellable"] =
true;
612 Result[
"percentage"] = 0;
615 return std::move(Result);
619 llvm::json::Object Result{{
"kind",
"report"}};
621 Result[
"cancellable"] = *P.cancellable;
623 Result[
"message"] = *P.message;
625 Result[
"percentage"] = *P.percentage;
627 return std::move(Result);
631 llvm::json::Object Result{{
"kind",
"end"}};
633 Result[
"message"] = *P.message;
635 return std::move(Result);
639 return static_cast<int64_t
>(R);
643 return llvm::json::Object{{
"type", R.
type}, {
"message", R.
message}};
647 llvm::json::Path P) {
648 llvm::json::ObjectMapper O(Params, P);
653 llvm::json::Path P) {
654 llvm::json::ObjectMapper O(Params, P);
659 llvm::json::Path P) {
660 llvm::json::ObjectMapper O(Params, P);
665 llvm::json::Path P) {
666 llvm::json::ObjectMapper O(Params, P);
670 mapOptOrNull(Params,
"forceRebuild", R.
forceRebuild, P);
674 llvm::json::Path P) {
675 if (
auto T = E.getAsInteger()) {
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);
692 llvm::json::Path P) {
693 llvm::json::ObjectMapper O(Params, P);
694 return O && O.map(
"changes", R.
changes);
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);
705 llvm::json::Path P) {
706 llvm::json::ObjectMapper O(Params, P);
713 llvm::json::ObjectMapper O(Params, P);
715 O.map(
"ranges", R.
ranges);
721 llvm::json::ObjectMapper O(Params, P);
723 O.map(
"position", R.
position) && O.map(
"ch", R.
ch);
727 llvm::json::Path P) {
728 llvm::json::ObjectMapper O(Params, P);
733 llvm::json::Path P) {
734 llvm::json::ObjectMapper O(Params, P);
739 return llvm::json::Object{
748 return llvm::json::Object{{
"href", D.href}};
752 llvm::json::Object
Diag{
754 {
"severity", D.severity},
755 {
"message", D.message},
758 Diag[
"category"] = *D.category;
760 Diag[
"codeActions"] = D.codeActions;
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;
770 Diag[
"data"] = llvm::json::Object(D.data);
772 Diag[
"tags"] = llvm::json::Array{D.tags};
774 return std::move(
Diag);
778 llvm::json::Path P) {
779 llvm::json::ObjectMapper O(Params, P);
782 if (
auto *Data = Params.getAsObject()->getObject(
"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);
792 llvm::json::Object Result{
797 Result[
"version"] = PDP.
version;
798 return std::move(Result);
802 llvm::json::Path P) {
803 llvm::json::ObjectMapper O(Params, P);
806 O.map(
"only", R.
only);
811 OS << D.range <<
" [";
812 switch (D.severity) {
829 return OS <<
'(' << D.severity <<
"): " << D.message <<
"]";
833 llvm::json::Path P) {
834 llvm::json::ObjectMapper O(Params, P);
840 llvm::json::Path P) {
841 llvm::json::ObjectMapper O(Params, P);
842 return O && O.map(
"changes", R.
changes) &&
848 llvm::json::Path P) {
849 llvm::json::ObjectMapper O(Params, P);
850 if (!O || !O.map(
"command", R.
command))
853 const auto *Args = Params.getAsObject()->get(
"arguments");
856 const auto *ArgsArray = Args->getAsArray();
858 P.field(
"arguments").report(
"expected array");
861 if (ArgsArray->size() > 1) {
862 P.field(
"arguments").report(
"Command should have 0 or 1 argument");
865 if (ArgsArray->size() == 1) {
872 llvm::json::Object O{
874 {
"kind",
static_cast<int>(P.kind)},
875 {
"location", P.location},
876 {
"containerName", P.containerName},
879 O[
"score"] = *P.score;
899 llvm::json::Object Result{{
"name", llvm::json::Value(
nullptr)},
900 {
"containerName", llvm::json::Value(
nullptr)},
901 {
"usr", llvm::json::Value(
nullptr)},
902 {
"id", llvm::json::Value(
nullptr)}};
905 Result[
"name"] = P.name;
907 if (!P.containerName.empty())
908 Result[
"containerName"] = P.containerName;
911 Result[
"usr"] = P.USR;
914 Result[
"id"] = P.ID.str();
916 if (P.declarationRange)
917 Result[
"declarationRange"] = *P.declarationRange;
919 if (P.definitionRange)
920 Result[
"definitionRange"] = *P.definitionRange;
923 return std::move(Result);
929 llvm::StringRef ContNameRef;
930 if (!ContNameRef.ends_with(
"::")) {
939 llvm::json::Path P) {
940 llvm::json::ObjectMapper O(Params, P);
941 return O && O.map(
"query", R.
query) &&
942 mapOptOrNull(Params,
"limit", R.
limit, P);
945llvm::json::Value
toJSON(
const Command &C) {
946 auto Cmd = llvm::json::Object{{
"title", C.title}, {
"command", C.command}};
947 if (!C.argument.getAsNull())
948 Cmd[
"arguments"] = llvm::json::Array{C.argument};
949 return std::move(Cmd);
976 llvm::json::Object Result{{
"name", S.
name},
977 {
"kind",
static_cast<int>(S.
kind)},
982 Result[
"detail"] = S.
detail;
986 Result[
"deprecated"] =
true;
988 Result[
"tags"] = S.
tags;
990 return std::move(Result);
994 llvm::json::Object Result;
996 llvm::json::Object FileChanges;
997 for (
auto &Change : *WE.
changes)
998 FileChanges[Change.first] = llvm::json::Array(Change.second);
999 Result[
"changes"] = std::move(FileChanges);
1004 llvm::json::Object ChangeAnnotations;
1006 ChangeAnnotations[Annotation.first] = Annotation.second;
1007 Result[
"changeAnnotations"] = std::move(ChangeAnnotations);
1013 llvm::json::Path P) {
1014 llvm::json::ObjectMapper O(Params, P);
1015 return O && O.map(
"file", A.file) && O.map(
"selection", A.selection) &&
1016 O.map(
"tweakID", A.tweakID);
1020 return llvm::json::Object{
1021 {
"tweakID", A.tweakID}, {
"selection", A.selection}, {
"file", A.file}};
1025 return llvm::json::Object{{
"edit", Params.
edit}};
1029 llvm::json::Path P) {
1030 llvm::json::ObjectMapper O(Response, P);
1031 return O && O.map(
"applied", R.
applied) &&
1036 llvm::json::Path P) {
1037 llvm::json::ObjectMapper O(Params, P);
1043 llvm::json::Path P) {
1044 llvm::json::ObjectMapper O(Params, P);
1046 if (!O || !O.map(
"triggerKind", TriggerKind) ||
1054 llvm::json::Path P) {
1056 !mapOptOrNull(Params,
"limit", R.
limit, P))
1058 if (
auto *
Context = Params.getAsObject()->
get(
"context"))
1070 llvm_unreachable(
"Invalid MarkupKind");
1074 auto Str = V.getAsString();
1076 P.report(
"expected string");
1079 if (*Str ==
"plaintext")
1081 else if (*Str ==
"markdown")
1084 P.report(
"unknown markup kind");
1095 if (MC.
value.empty())
1098 return llvm::json::Object{
1100 {
"value", MC.
value},
1110 return std::move(Result);
1114 llvm::json::Path P) {
1115 if (
auto T = E.getAsInteger()) {
1128 auto KindVal =
static_cast<size_t>(Kind);
1130 KindVal <= SupportedCompletionItemKinds.size() &&
1131 SupportedCompletionItemKinds[KindVal])
1148 llvm::json::Path P) {
1149 if (
auto *A = E.getAsArray()) {
1150 for (
size_t I = 0; I < A->size(); ++I) {
1152 if (
fromJSON((*A)[I], KindOut, P.index(I)))
1153 Out.set(
size_t(KindOut));
1161 llvm::json::Object Result;
1163 Result[
"detail"] = CD.
detail;
1170 if (!C.labelDetails)
1172 if (!C.labelDetails->detail.empty())
1173 C.label += C.labelDetails->detail;
1174 if (!C.labelDetails->description.empty())
1175 C.label = C.labelDetails->description + C.label;
1176 C.labelDetails.reset();
1180 assert(!CI.
label.empty() &&
"completion item label is required");
1181 llvm::json::Object Result{{
"label", CI.
label}};
1183 Result[
"kind"] =
static_cast<int>(CI.
kind);
1185 Result[
"detail"] = CI.
detail;
1199 Result[
"textEdit"] = std::visit(
1200 [](
const auto &V) {
return llvm::json::Value(V); }, *CI.
textEdit);
1205 Result[
"score"] = CI.
score;
1206 return std::move(Result);
1220 return llvm::json::Object{
1222 {
"items", llvm::json::Array(L.
items)},
1228 "parameter information label is required");
1229 llvm::json::Object Result;
1237 return std::move(Result);
1241 assert(!SI.
label.empty() &&
"signature information label is required");
1242 llvm::json::Object Result{
1243 {
"label", SI.
label},
1244 {
"parameters", llvm::json::Array(SI.
parameters)},
1248 return std::move(Result);
1259 "Unexpected negative value for number of active signatures.");
1261 "Unexpected negative value for active parameter index");
1262 return llvm::json::Object{
1265 {
"signatures", llvm::json::Array(SH.
signatures)},
1270 llvm::json::Path P) {
1271 llvm::json::ObjectMapper O(Params, P);
1277 return llvm::json::Object{
1287 return llvm::json::Object{
1294 return llvm::json::Object{
1296 {
"kind",
static_cast<int>(DH.
kind)},
1301 return llvm::json::Object{
1302 {
"uri", FStatus.
uri},
1303 {
"state", FStatus.
state},
1309 llvm::json::Array Result;
1311 for (
const auto &Tok : Toks) {
1312 Result.push_back(Tok.deltaLine);
1313 Result.push_back(Tok.deltaStart);
1314 Result.push_back(Tok.length);
1315 Result.push_back(Tok.tokenType);
1316 Result.push_back(Tok.tokenModifiers);
1319 return std::move(Result);
1330 return llvm::json::Object{{
"resultId", Tokens.
resultId},
1335 return llvm::json::Object{
1342 llvm::json::Object Result{{
"resultId", TE.
resultId}};
1344 Result[
"edits"] = *TE.
edits;
1347 return std::move(Result);
1351 llvm::json::Path P) {
1352 llvm::json::ObjectMapper O(Params, P);
1357 llvm::json::Path P) {
1358 llvm::json::ObjectMapper O(Params, P);
1364 return llvm::json::Object{
1381 llvm::json::ObjectMapper O(Params, P);
1382 return O && O.map(
"settings", CCP.
settings);
1386 llvm::json::Path P) {
1387 llvm::json::ObjectMapper O(Params, P);
1393 llvm::json::Path P) {
1394 llvm::json::ObjectMapper O(Params, P);
1397 return mapOptOrNull(Params,
"compilationDatabaseChanges",
1402 llvm::json::Path P) {
1403 llvm::json::ObjectMapper O(Params, P);
1409 mapOptOrNull(Params,
"fallbackFlags", Opts.
fallbackFlags, P) &&
1410 mapOptOrNull(Params,
"clangdFileStatus", Opts.
FileStatus, P);
1414 llvm::json::Path P) {
1415 auto T = E.getAsInteger();
1426 llvm::json::Path P) {
1427 llvm::json::ObjectMapper O(Params, P);
1430 mapOptOrNull(Params,
"resolve", R.
resolve, P) &&
1431 mapOptOrNull(Params,
"direction", R.
direction, P);
1440 llvm::json::Object Result{{
"symbolID", RP.
symbolID}};
1442 Result[
"parents"] = RP.
parents;
1443 return std::move(Result);
1447 llvm::json::ObjectMapper O(Params, P);
1448 return O && O.map(
"symbolID", RP.
symbolID) &&
1449 mapOptOrNull(Params,
"parents", RP.
parents, P);
1453 llvm::json::Object Result{
1454 {
"name", I.
name}, {
"kind",
static_cast<int>(I.
kind)},
1456 {
"uri", I.
uri}, {
"data", I.
data},
1460 Result[
"detail"] = I.
detail;
1461 if (!I.
tags.empty())
1462 Result[
"tags"] = I.
tags;
1463 return std::move(Result);
1467 llvm::json::Path P) {
1468 llvm::json::ObjectMapper O(Params, P);
1471 return O && O.map(
"name", I.
name) && O.map(
"kind", I.
kind) &&
1472 O.map(
"uri", I.
uri) && O.map(
"range", I.
range) &&
1474 mapOptOrNull(Params,
"detail", I.
detail, P) &&
1475 mapOptOrNull(Params,
"deprecated", I.
deprecated, P) &&
1476 mapOptOrNull(Params,
"parents", I.
parents, P) &&
1477 mapOptOrNull(Params,
"children", I.
children, P) &&
1478 mapOptOrNull(Params,
"data", I.
data, P);
1483 llvm::json::ObjectMapper O(Params, P);
1484 return O && O.map(
"item", R.
item) &&
1485 mapOptOrNull(Params,
"resolve", R.
resolve, P) &&
1486 mapOptOrNull(Params,
"direction", R.
direction, P);
1490 llvm::json::Path P) {
1491 llvm::json::ObjectMapper O(Params, P);
1496 llvm::json::Path P) {
1498 llvm::json::ObjectMapper O(Params, P);
1499 return fromJSON(Params, Base, P) && O && O.mapOptional(
"context", R.
context);
1503 return llvm::json::Value(
static_cast<int>(Tag));
1507 llvm::json::Object Result{{
"name", I.
name},
1508 {
"kind",
static_cast<int>(I.
kind)},
1512 if (!I.
tags.empty())
1513 Result[
"tags"] = I.
tags;
1515 Result[
"detail"] = I.
detail;
1516 if (!I.
data.empty())
1517 Result[
"data"] = I.
data;
1518 return std::move(Result);
1522 llvm::json::Path P) {
1523 llvm::json::ObjectMapper O(Params, P);
1528 return O && O.map(
"name", I.
name) && O.map(
"kind", I.
kind) &&
1529 O.map(
"uri", I.
uri) && O.map(
"range", I.
range) &&
1531 mapOptOrNull(Params,
"data", I.
data, P);
1536 llvm::json::ObjectMapper O(Params, P);
1537 return O && O.map(
"item", C.item);
1541 return llvm::json::Object{{
"from", C.from}, {
"fromRanges", C.fromRanges}};
1546 llvm::json::ObjectMapper O(Params, P);
1547 return O && O.map(
"item", C.item);
1551 return llvm::json::Object{{
"to", C.to}, {
"fromRanges", C.fromRanges}};
1555 llvm::json::Path P) {
1556 llvm::json::ObjectMapper O(Params, P);
1572 llvm_unreachable(
"Unknown clang.clangd.InlayHintKind");
1576 llvm::json::Object Result{{
"position", H.
position},
1582 Result[
"kind"] = std::move(K);
1583 return std::move(Result);
1586 return std::tie(A.position, A.range, A.kind, A.label) ==
1587 std::tie(B.position, B.range, B.kind, B.label);
1590 return std::tie(A.position, A.range, A.kind, A.label) <
1591 std::tie(B.position, B.range, B.kind, B.label);
1594 return llvm::join(llvm::map_range(
label, [](
auto &L) {
return L.value; }),
1606 return "designator";
1610 return "default-argument";
1612 llvm_unreachable(
"Unknown clang.clangd.InlayHintKind");
1614 return OS << ToString(Kind);
1618 llvm::json::Object Result{{
"value", L.
value}};
1620 Result[
"tooltip"] = *L.
tooltip;
1624 Result[
"command"] = *L.
command;
1655 llvm_unreachable(
"Unknown clang.clangd.OffsetEncoding");
1659 llvm::json::Path P) {
1660 auto Str = V.getAsString();
1663 OE = llvm::StringSwitch<OffsetEncoding>(*Str)
1675 llvm::json::Path P) {
1676 llvm::json::ObjectMapper O(Params, P);
1683 return llvm::json::Object{{
"range", Out.
range},
1686 return llvm::json::Object{{
"range", Out.
range}};
1690 llvm::json::Path P) {
1691 llvm::json::ObjectMapper O(Params, P);
1696 return llvm::json::Object{
1703 llvm::json::Path P) {
1704 llvm::json::ObjectMapper O(Params, P);
1713 llvm::json::Object Result{
1714 {
"startLine",
Range.startLine},
1715 {
"endLine",
Range.endLine},
1717 if (
Range.startCharacter)
1718 Result[
"startCharacter"] =
Range.startCharacter;
1719 if (
Range.endCharacter)
1720 Result[
"endCharacter"] =
Range.endCharacter;
1721 if (!
Range.kind.empty())
1722 Result[
"kind"] =
Range.kind;
1727 llvm::json::Object Out;
1728 int64_t Total = MT.
self();
1729 Out[
"_self"] = Total;
1732 Total += *Child.getAsObject()->getInteger(
"_total");
1733 Out[
Entry.first] = std::move(Child);
1735 Out[
"_total"] = Total;
1740 llvm::json::Path P) {
1741 llvm::json::ObjectMapper O(Params, P);
1746 llvm::json::Object Result{
1753 Result[
"detail"] = N.
detail;
1755 Result[
"arcana"] = N.
arcana;
1757 Result[
"range"] = *N.
range;
1763 OS.indent(2 * Level) << N.
role <<
": " << N.
kind;
1777 auto Str = E.getAsString();
1779 P.report(
"expected a string");
1784 elog(
"Malformed symbolid: {0}", ID.takeError());
1785 P.report(
"malformed symbolid");
A context is an immutable container for per-request data that must be propagated through layers that ...
const Type * get(const Key< Type > &Key) const
Get data stored for a typed Key.
static llvm::Expected< SymbolID > fromStr(llvm::StringRef)
A URI describes the location of a source file.
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...
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
Resolves the absolute path of U.
static llvm::Expected< URI > parse(llvm::StringRef Uri)
Parse a URI string "<scheme>:[//<authority>/]<path>".
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
@ Created
The file got created.
@ Deleted
The file got deleted.
@ Info
An information message.
constexpr auto CompletionItemKindMin
SymbolTag
Symbol tags are extra annotations that can be attached to a symbol.
constexpr auto SymbolKindMin
CompletionItemKind
The kind of a completion entry.
static const char * toString(OffsetEncoding OE)
static void printASTNode(llvm::raw_ostream &OS, const ASTNode &N, unsigned Level)
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
constexpr unsigned SemanticTokenEncodingSize
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
std::bitset< SymbolKindMax+1 > SymbolKindBitset
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
void removeCompletionLabelDetails(CompletionItem &C)
Remove the labelDetails field (for clients that don't support it).
bool operator<(const Ref &L, const Ref &R)
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
static llvm::StringRef toTextKind(MarkupKind Kind)
InlayHintKind
Inlay hint kinds.
@ BlockEnd
A hint after function, type or namespace definition, indicating the defined symbol name of the defini...
@ DefaultArgument
An inlay hint that is for a default argument.
@ Parameter
An inlay hint that is for a parameter.
@ Type
An inlay hint that for a type annotation.
@ Designator
A hint before an element of an aggregate braced initializer list, indicating what it is initializing.
static llvm::json::Value encodeTokens(llvm::ArrayRef< SemanticToken > Toks)
SymbolKind indexSymbolKindToSymbolKind(const index::SymbolInfo &Info)
void elog(const char *Fmt, Ts &&... Vals)
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request, llvm::json::Path P)
cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccessCheck P
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Simplified description of a clang AST node.
std::optional< Range > range
The range of the original source file covered by this node.
std::vector< ASTNode > children
Nodes nested within this one, such as the operands of a BinaryOperator.
std::string role
The general kind of node, such as "expression" Corresponds to the base AST node type such as Expr.
std::string kind
The specific kind of node this is, such as "BinaryOperator".
std::string detail
Brief additional information, such as "||" for the particular operator.
std::string arcana
A one-line dump of detailed information about the node.
Payload for textDocument/ast request.
std::optional< Range > range
The position of the node to be dumped.
TextDocumentIdentifier textDocument
The text document.
std::optional< std::string > failureReason
Represents an incoming call, e.g. a caller of a method or constructor.
The parameter of a callHierarchy/incomingCalls request.
Represents programming constructs like functions or constructors in the context of call hierarchy.
std::string name
The name of this item.
URIForFile uri
The resource identifier of this item.
Range range
The range enclosing this symbol not including leading / trailing whitespace but everything else,...
SymbolKind kind
The kind of this item.
std::vector< SymbolTag > tags
Tags for this item.
std::string data
An optional 'data' field, which can be used to identify a call hierarchy item in an incomingCalls or ...
std::string detail
More detaill for this item, e.g. the signature of a function.
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Represents an outgoing call, e.g.
The parameter of a callHierarchy/outgoingCalls request.
std::string description
A human-readable string which is rendered less prominent in the user interface.
std::string label
A human-readable string describing the actual change.
std::optional< bool > needsConfirmation
A flag which indicates that user confirmation is needed before applying the change.
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
std::string workingDirectory
std::vector< std::string > compilationCommand
bool HierarchicalDocumentSymbol
Client supports hierarchical document symbols.
bool WorkDoneProgress
The client supports progress notifications.
bool DiagnosticCategory
Whether the client accepts diagnostics with category attached to it using the "category" extension.
bool CompletionLabelDetail
The client has support for completion item label details.
MarkupKind HoverContentFormat
The content format that should be used for Hover requests.
bool CodeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
bool OffsetsInSignatureHelp
Client supports processing label offsets instead of a simple label string.
bool DiagnosticFixes
Whether the client accepts diagnostics with codeActions attached inline.
bool HasSignatureHelp
Client supports signature help.
bool TheiaSemanticHighlighting
Client supports Theia semantic highlighting extension.
bool SemanticTokenRefreshSupport
Whether the client implementation supports a refresh request sent from the server to the client.
bool DocumentChanges
The client supports versioned document changes for WorkspaceEdit.
bool ImplicitProgressCreation
The client supports implicit $/progress work-done progress streams, without a preceding window/workDo...
MarkupKind SignatureHelpDocumentationFormat
The documentation format that should be used for textDocument/signatureHelp.
bool DiagnosticRelatedInformation
Whether the client accepts diagnostics with related locations.
bool CompletionFixes
Client supports completions with additionalTextEdit near the cursor.
bool RenamePrepareSupport
The client supports testing for validity of rename operations before execution.
bool InsertReplace
Client supports insert replace edit to control different behavior if a completion item is inserted in...
std::optional< std::vector< OffsetEncoding > > PositionEncodings
Supported encodings for LSP character offsets.
bool CancelsStaleRequests
Whether the client claims to cancel stale requests.
std::optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
bool CompletionSnippets
Client supports snippets as insert text.
MarkupKind CompletionDocumentationFormat
The documentation format that should be used for textDocument/completion.
bool SemanticTokens
Client advertises support for the semanticTokens feature.
bool ChangeAnnotation
The client supports change annotations on text edits,.
bool LineFoldingOnly
Client signals that it only supports folding complete lines.
bool InactiveRegions
Whether the client supports the textDocument/inactiveRegions notification.
std::optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
bool ReferenceContainer
Client supports displaying a container string for results of textDocument/reference (clangd extension...
std::vector< Diagnostic > diagnostics
An array of diagnostics known on the client side overlapping the range provided to the textDocument/c...
std::vector< std::string > only
Requested kind of actions to return.
CodeActionContext context
Context carrying additional information.
TextDocumentIdentifier textDocument
The document in which the command was invoked.
Range range
The range for which the command was invoked.
A code action represents a change that can be performed in code, e.g.
static const llvm::StringLiteral INFO_KIND
bool isPreferred
Marks this as a preferred action.
static const llvm::StringLiteral REFACTOR_KIND
std::optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
static const llvm::StringLiteral QUICKFIX_KIND
std::optional< WorkspaceEdit > edit
The workspace edit this code action performs.
std::optional< Command > command
A command this code action executes.
std::optional< std::string > kind
The kind of the code action.
std::string title
A short, human-readable, title for this code action.
Structure to capture a description for an error code.
CompletionTriggerKind triggerKind
How the completion was triggered.
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
Additional details for a completion item label.
std::string detail
An optional string which is rendered less prominently directly after label without any spacing.
std::string description
An optional string which is rendered less prominently after CompletionItemLabelDetails....
std::string sortText
A string that should be used when comparing this item with other items.
std::string filterText
A string that should be used when filtering a set of completion items.
std::string detail
A human-readable string with additional information about this item, like type or symbol information.
InsertTextFormat insertTextFormat
The format of the insert text.
CompletionItemKind kind
The kind of this completion item.
std::vector< TextEdit > additionalTextEdits
An optional array of additional text edits that are applied when selecting this completion.
std::optional< MarkupContent > documentation
A human-readable string that represents a doc-comment.
std::string insertText
A string that should be inserted to a document when selecting this completion.
bool deprecated
Indicates if this item is deprecated.
std::optional< CompletionItemLabelDetails > labelDetails
Additional details for the label.
std::optional< std::variant< TextEdit, InsertReplaceEdit > > textEdit
An edit which is applied to a document when selecting this completion.
float score
The score that clangd calculates to rank the returned completions.
std::string label
The label of this completion item.
Represents a collection of completion items to be presented in the editor.
std::vector< CompletionItem > items
The completion items.
bool isIncomplete
The list is not complete.
std::optional< int > limit
Max results to return, overriding global default.
CompletionContext context
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
A top-level diagnostic that may have Notes and Fixes.
llvm::json::Object data
A data entry field that is preserved between a textDocument/publishDiagnostics notification and textD...
std::string code
The diagnostic's code. Can be omitted.
Range range
The range at which the message applies.
std::string source
A human-readable string describing the source of this diagnostic, e.g.
std::string message
The diagnostic's message.
int severity
The diagnostic's severity.
std::optional< std::string > category
The diagnostic's category.
ConfigurationSettings settings
bool forceRebuild
Force a complete rebuild of the file, ignoring all cached state.
VersionedTextDocumentIdentifier textDocument
The document that did change.
std::optional< bool > wantDiagnostics
Forces diagnostics to be generated, or to not be generated, for this version of the file.
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
std::vector< FileEvent > changes
The actual file events.
TextDocumentIdentifier textDocument
The document that was closed.
TextDocumentItem textDocument
The document that was opened.
TextDocumentIdentifier textDocument
The document that was saved.
A document highlight is a range inside a text document which deserves special attention.
Range range
The range this highlight applies to.
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
Parameters for the document link request.
TextDocumentIdentifier textDocument
The document to provide document links for.
A range in a text document that links to an internal or external resource, like another text document...
Range range
The range this link applies to.
URIForFile target
The uri this link points to. If missing a resolve request is sent later.
TextDocumentIdentifier textDocument
Represents programming constructs like variables, classes, interfaces etc.
std::vector< SymbolTag > tags
The tags for this symbol.
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
std::string detail
More detail for this symbol, e.g the signature of a function.
std::string name
The name of this symbol.
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
bool deprecated
Indicates if this symbol is deprecated.
SymbolKind kind
The kind of this symbol.
A set of edits generated for a single file.
llvm::json::Value argument
std::string command
The identifier of the actual command handler.
FileChangeType type
The change type.
URIForFile uri
The file's URI.
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
URIForFile uri
The text document's URI.
std::string state
The human-readable string presents the current state of the file, can be shown in the UI (e....
TextDocumentIdentifier textDocument
Stores information about a region of code that can be folded.
static const llvm::StringLiteral REGION_KIND
static const llvm::StringLiteral COMMENT_KIND
static const llvm::StringLiteral IMPORT_KIND
std::optional< Range > range
An optional range is a range inside a text document that is used to visualize a hover,...
MarkupContent contents
The hover's content.
Parameters for the inactive regions (server-side) push notification.
TextDocumentIdentifier TextDocument
The textdocument these inactive regions belong to.
std::vector< Range > InactiveRegions
The inactive regions that should be sent.
Clangd extension: parameters configurable at initialize time.
std::optional< std::string > compilationDatabasePath
bool FileStatus
Clients supports show file status for textDocument/clangd.fileStatus.
std::vector< std::string > fallbackFlags
ConfigurationSettings ConfigSettings
llvm::json::Object rawCapabilities
The same data as capabilities, but not parsed (to expose to modules).
InitializationOptions initializationOptions
User-provided initialization options.
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
std::optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
std::optional< int > processId
The process Id of the parent process that started the server.
std::optional< std::string > rootPath
The rootPath of the workspace.
std::optional< URIForFile > rootUri
The rootUri of the workspace.
An inlay hint label part allows for interactive and composite labels of inlay hints.
std::optional< Location > location
An optional source code location that represents this label part.
std::optional< MarkupContent > tooltip
The tooltip text when you hover over this label part.
std::optional< Command > command
An optional command for this label part.
std::string value
The value of this label part.
InlayHintKind kind
The kind of this hint.
std::string joinLabels() const
Join the label[].value together.
bool paddingRight
Render padding after the hint.
bool paddingLeft
Render padding before the hint.
Position position
The position of this hint.
std::vector< InlayHintLabelPart > label
The label of this hint.
A parameter literal used in inlay hint requests.
std::optional< Range > range
The visible document range for which inlay hints should be computed.
TextDocumentIdentifier textDocument
The text document.
URIForFile uri
The text document's URI.
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
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.
int line
Line position in a document (zero-based).
int character
Character offset on a line in a document (zero-based).
std::string placeholder
Placeholder text to use in the editor if non-empty.
Range range
Range of the string to rename.
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
std::optional< int64_t > version
The version number of the document the diagnostics are published for.
URIForFile uri
The URI for which diagnostic information is reported.
Position start
The range's start position.
Position end
The range's end position.
bool includeDeclaration
Include the declaration of the current symbol.
Extends Locations returned by textDocument/references with extra info.
std::optional< std::string > containerName
clangd extension: contains the name of the function or class in which the reference occurs
TextDocumentIdentifier textDocument
The document that was opened.
Position position
The position at which this request was sent.
std::string newName
The new name of the symbol.
Parameters for the typeHierarchy/resolve request.
TypeHierarchyItem item
The item to resolve.
int resolve
The hierarchy levels to resolve. 0 indicates no level.
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
TextDocumentIdentifier textDocument
The text document.
std::vector< Position > positions
The positions inside the text document.
std::unique_ptr< SelectionRange > parent
The parent selection range containing this range.
Range range
The range of this selection range.
Specifies a single semantic token in the document.
unsigned length
the length of the token. A token cannot be multiline
unsigned deltaStart
token start character, relative to the previous token (relative to 0 or the previous token's start if...
unsigned deltaLine
token line number, relative to the previous token
unsigned tokenType
will be looked up in SemanticTokensLegend.tokenTypes
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
Body of textDocument/semanticTokens/full/delta request.
TextDocumentIdentifier textDocument
The text document.
std::string previousResultId
The previous result id.
Describes a replacement of a contiguous range of semanticTokens.
This models LSP SemanticTokensDelta | SemanticTokens, which is the result of textDocument/semanticTok...
std::optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
std::optional< std::vector< SemanticTokensEdit > > edits
Set if we computed edits relative to a previous set of tokens.
Body of textDocument/semanticTokens/full request.
TextDocumentIdentifier textDocument
The text document.
A versioned set of tokens.
std::vector< SemanticToken > tokens
The actual tokens.
The show message notification is sent from a server to a client to ask the client to display a partic...
MessageType type
The message type.
std::string message
The actual message.
Represents the signature of a callable.
int activeSignature
The active signature.
std::vector< SignatureInformation > signatures
The resulting signatures.
int activeParameter
The active parameter of the active signature.
Represents information about identifier.
std::optional< Location > definitionRange
std::string containerName
std::optional< Location > declarationRange
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol.
Ensure we have enough bits to represent all SymbolTag values.
std::optional< Range > range
The range of the document that changed.
std::string text
The new text of the range/document.
std::optional< int > rangeLength
The length of the range that got replaced.
VersionedTextDocumentIdentifier textDocument
The text document to change.
std::vector< TextEdit > edits
The edits to be applied.
URIForFile uri
The text document's URI.
std::string languageId
The text document's language identifier.
std::optional< int64_t > version
The version number of this document (it will strictly increase after each change, including undo/redo...
URIForFile uri
The text document's URI.
std::string text
The content of the opened text document.
TextDocumentIdentifier textDocument
The text document.
Position position
The position inside the text document.
std::string newText
The string to be inserted.
ChangeAnnotationIdentifier annotationId
The actual annotation identifier (optional) If empty, then this field is nullopt.
Range range
The range of the text document to be manipulated.
Arguments for the 'applyTweak' command.
Used to resolve a client provided item back.
std::optional< std::vector< ResolveParams > > parents
std::nullopt means parents aren't resolved and empty is no parents.
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else,...
URIForFile uri
The resource identifier of this item.
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
SymbolKind kind
The kind of this item.
std::optional< std::vector< TypeHierarchyItem > > children
If this type hierarchy item is resolved, it contains the direct children of the current item.
std::optional< std::vector< TypeHierarchyItem > > parents
This is a clangd exntesion.
bool deprecated
true if the hierarchy item is deprecated.
std::optional< std::string > detail
More detail for this item, e.g. the signature of a function.
std::vector< SymbolTag > tags
The symbol tags for this item.
ResolveParams data
A data entry field that is preserved between a type hierarchy prepare and supertypes or subtypes requ...
std::string name
The name of this item.
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
int resolve
The hierarchy levels to resolve.
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
static llvm::Expected< URIForFile > fromURI(const URI &U, llvm::StringRef HintPath)
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
Canonicalizes AbsPath via URI.
std::optional< std::int64_t > version
The version number of this document.
To start progress reporting a $/progress notification with the following payload must be sent.
Signals the end of progress reporting.
Reporting progress is done using the following payload.
The edit should either provide changes or documentChanges.
std::optional< std::vector< TextDocumentEdit > > documentChanges
Versioned document edits.
std::map< std::string, ChangeAnnotation > changeAnnotations
A map of change annotations that can be referenced in AnnotatedTextEdit.
std::optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.
The parameters of a Workspace Symbol Request.
std::string query
A query string to filter symbols by.
std::optional< int > limit
Max results to return, overriding global default.