Go to the documentation of this file.
16 #include "clang/Basic/LLVM.h"
17 #include "clang/Index/IndexSymbol.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/ADT/StringSwitch.h"
20 #include "llvm/Support/ErrorHandling.h"
21 #include "llvm/Support/JSON.h"
22 #include "llvm/Support/Path.h"
23 #include "llvm/Support/raw_ostream.h"
33 auto *O = Params.getAsObject();
35 auto *V = O->get(Prop);
37 if (!V || V->getAsNull().hasValue())
46 llvm::StringRef TUPath) {
47 assert(llvm::sys::path::is_absolute(AbsPath) &&
"the path is relative");
50 elog(
"URIForFile: failed to resolve path {0} with TU path {1}: "
51 "{2}.\nUsing unresolved path.",
52 AbsPath, TUPath, Resolved.takeError());
59 llvm::StringRef HintPath) {
62 return Resolved.takeError();
67 if (
auto S =
E.getAsString()) {
70 consumeError(Parsed.takeError());
71 P.report(
"failed to parse URI");
74 if (Parsed->scheme() !=
"file" && Parsed->scheme() !=
"test") {
75 P.report(
"clangd only supports 'file' URI scheme for workspace files");
81 P.report(
"unresolvable URI");
82 consumeError(U.takeError());
98 return llvm::json::Object{{
"uri", R.
uri}};
103 llvm::json::ObjectMapper O(Params, P);
104 return O && O.map(
"uri", R.
uri);
109 Result.getAsObject()->try_emplace(
"version", R.
version);
115 llvm::json::ObjectMapper O(Params, P);
122 llvm::json::ObjectMapper O(Params, P);
123 return O && O.map(
"line", R.
line) && O.map(
"character", R.
character);
127 return llvm::json::Object{
138 llvm::json::ObjectMapper O(Params, P);
139 return O && O.map(
"start", R.
start) && O.map(
"end", R.
end);
143 return llvm::json::Object{
154 return llvm::json::Object{
161 return OS << L.range <<
'@' << L.uri;
166 llvm::json::ObjectMapper O(Params, P);
167 return O && O.map(
"uri", R.
uri) && O.map(
"languageId", R.
languageId) &&
168 O.map(
"version", R.
version) && O.map(
"text", R.
text);
173 llvm::json::ObjectMapper O(Params, P);
174 return O && O.map(
"range", R.
range) && O.map(
"newText", R.
newText);
178 return llvm::json::Object{
186 llvm::printEscapedString(TE.
newText,
OS);
191 if (
auto S =
E.getAsString()) {
196 if (*S ==
"messages") {
200 if (*S ==
"verbose") {
209 if (
auto T =
E.getAsInteger()) {
221 if (
auto *
A =
E.getAsArray()) {
222 for (
size_t I = 0; I <
A->size(); ++I) {
224 if (
fromJSON((*
A)[I], KindOut, P.index(I)))
225 Out.set(
size_t(KindOut));
234 auto KindVal =
static_cast<size_t>(
Kind);
235 if (KindVal >=
SymbolKindMin && KindVal <= SupportedSymbolKinds.size() &&
236 SupportedSymbolKinds[KindVal])
254 case index::SymbolKind::Module:
256 case index::SymbolKind::Namespace:
258 case index::SymbolKind::NamespaceAlias:
260 case index::SymbolKind::Macro:
262 case index::SymbolKind::Enum:
264 case index::SymbolKind::Struct:
266 case index::SymbolKind::Class:
268 case index::SymbolKind::Protocol:
270 case index::SymbolKind::Extension:
272 case index::SymbolKind::Union:
274 case index::SymbolKind::TypeAlias:
276 case index::SymbolKind::Function:
278 case index::SymbolKind::Variable:
282 case index::SymbolKind::EnumConstant:
284 case index::SymbolKind::InstanceMethod:
285 case index::SymbolKind::ClassMethod:
286 case index::SymbolKind::StaticMethod:
288 case index::SymbolKind::InstanceProperty:
289 case index::SymbolKind::ClassProperty:
290 case index::SymbolKind::StaticProperty:
292 case index::SymbolKind::Constructor:
293 case index::SymbolKind::Destructor:
295 case index::SymbolKind::ConversionFunction:
297 case index::SymbolKind::Parameter:
298 case index::SymbolKind::NonTypeTemplateParm:
300 case index::SymbolKind::Using:
302 case index::SymbolKind::TemplateTemplateParm:
303 case index::SymbolKind::TemplateTypeParm:
305 case index::SymbolKind::Concept:
308 llvm_unreachable(
"invalid symbol kind");
313 const llvm::json::Object *O = Params.getAsObject();
315 P.report(
"expected object");
318 if (
auto *TextDocument = O->getObject(
"textDocument")) {
319 if (
auto *SemanticHighlighting =
320 TextDocument->getObject(
"semanticHighlightingCapabilities")) {
321 if (
auto SemanticHighlightingSupport =
322 SemanticHighlighting->getBoolean(
"semanticHighlighting"))
325 if (TextDocument->getObject(
"semanticTokens"))
327 if (
auto *
Diagnostics = TextDocument->getObject(
"publishDiagnostics")) {
328 if (
auto CategorySupport =
Diagnostics->getBoolean(
"categorySupport"))
330 if (
auto CodeActions =
Diagnostics->getBoolean(
"codeActionsInline"))
332 if (
auto RelatedInfo =
Diagnostics->getBoolean(
"relatedInformation"))
335 if (
auto *Completion = TextDocument->getObject(
"completion")) {
336 if (
auto *Item = Completion->getObject(
"completionItem")) {
337 if (
auto SnippetSupport = Item->getBoolean(
"snippetSupport"))
339 if (
const auto *DocumentationFormat =
340 Item->getArray(
"documentationFormat")) {
341 for (
const auto &Format : *DocumentationFormat) {
347 if (
auto *ItemKind = Completion->getObject(
"completionItemKind")) {
348 if (
auto *ValueSet = ItemKind->get(
"valueSet")) {
351 P.field(
"textDocument")
353 .field(
"completionItemKind")
358 if (
auto EditsNearCursor = Completion->getBoolean(
"editsNearCursor"))
361 if (
auto *
CodeAction = TextDocument->getObject(
"codeAction")) {
362 if (
CodeAction->getObject(
"codeActionLiteralSupport"))
365 if (
auto *
DocumentSymbol = TextDocument->getObject(
"documentSymbol")) {
366 if (
auto HierarchicalSupport =
370 if (
auto *
Hover = TextDocument->getObject(
"hover")) {
371 if (
auto *ContentFormat =
Hover->getArray(
"contentFormat")) {
372 for (
const auto &Format : *ContentFormat) {
378 if (
auto *Help = TextDocument->getObject(
"signatureHelp")) {
380 if (
auto *
Info = Help->getObject(
"signatureInformation")) {
381 if (
auto *
Parameter =
Info->getObject(
"parameterInformation")) {
382 if (
auto OffsetSupport =
Parameter->getBoolean(
"labelOffsetSupport"))
385 if (
const auto *DocumentationFormat =
386 Info->getArray(
"documentationFormat")) {
387 for (
const auto &Format : *DocumentationFormat) {
394 if (
auto *Rename = TextDocument->getObject(
"rename")) {
395 if (
auto RenameSupport = Rename->getBoolean(
"prepareSupport"))
399 if (
auto *Workspace = O->getObject(
"workspace")) {
400 if (
auto *
Symbol = Workspace->getObject(
"symbol")) {
402 if (
auto *ValueSet =
SymbolKind->get(
"valueSet")) {
413 if (
auto *
SemanticTokens = Workspace->getObject(
"semanticTokens")) {
414 if (
auto RefreshSupport =
SemanticTokens->getBoolean(
"refreshSupport"))
418 if (
auto *Window = O->getObject(
"window")) {
419 if (
auto WorkDoneProgress = Window->getBoolean(
"workDoneProgress"))
421 if (
auto Implicit = Window->getBoolean(
"implicitWorkDoneProgressCreate"))
424 if (
auto *General = O->getObject(
"general")) {
425 if (
auto *StaleRequestSupport = General->getObject(
"staleRequestSupport")) {
426 if (
auto Cancel = StaleRequestSupport->getBoolean(
"cancel"))
433 P.field(
"offsetEncoding")))
441 llvm::json::ObjectMapper O(Params, P);
450 if (
auto *RawCaps = Params.getAsObject()->getObject(
"capabilities"))
452 O.map(
"trace", R.
trace);
458 return llvm::json::Object{{
"token", P.
token}};
462 llvm::json::Object Result{
467 Result[
"cancellable"] =
true;
469 Result[
"percentage"] = 0;
472 return std::move(Result);
476 llvm::json::Object Result{{
"kind",
"report"}};
480 Result[
"message"] = *P.
message;
484 return std::move(Result);
488 llvm::json::Object Result{{
"kind",
"end"}};
490 Result[
"message"] = *P.
message;
492 return std::move(Result);
496 return static_cast<int64_t
>(R);
500 return llvm::json::Object{{
"type", R.
type}, {
"message", R.
message}};
505 llvm::json::ObjectMapper O(Params, P);
511 llvm::json::ObjectMapper O(Params, P);
517 llvm::json::ObjectMapper O(Params, P);
523 llvm::json::ObjectMapper O(Params, P);
527 mapOptOrNull(Params,
"forceRebuild", R.
forceRebuild, P);
532 if (
auto T =
E.getAsInteger()) {
544 llvm::json::ObjectMapper O(Params, P);
545 return O && O.map(
"uri", R.
uri) && O.map(
"type", R.
type);
550 llvm::json::ObjectMapper O(Params, P);
551 return O && O.map(
"changes", R.
changes);
556 llvm::json::ObjectMapper O(Params, P);
557 return O && O.map(
"range", R.
range) && O.map(
"rangeLength", R.
rangeLength) &&
558 O.map(
"text", R.
text);
563 llvm::json::ObjectMapper O(Params, P);
569 llvm::json::ObjectMapper O(Params, P);
571 O.map(
"position", R.
position) && O.map(
"ch", R.
ch);
576 llvm::json::ObjectMapper O(Params, P);
582 llvm::json::ObjectMapper O(Params, P);
587 return llvm::json::Object{
596 return llvm::json::Object{{
"href",
D.href}};
600 llvm::json::Object
Diag{
602 {
"severity",
D.severity},
603 {
"message",
D.message},
606 Diag[
"category"] = *
D.category;
608 Diag[
"codeActions"] =
D.codeActions;
610 Diag[
"code"] =
D.code;
611 if (
D.codeDescription.hasValue())
612 Diag[
"codeDescription"] = *
D.codeDescription;
613 if (!
D.source.empty())
614 Diag[
"source"] =
D.source;
615 if (
D.relatedInformation)
616 Diag[
"relatedInformation"] = *
D.relatedInformation;
618 Diag[
"data"] = llvm::json::Object(
D.data);
620 Diag[
"tags"] = llvm::json::Array{
D.tags};
622 return std::move(
Diag);
627 llvm::json::ObjectMapper O(Params, P);
630 if (
auto *Data = Params.getAsObject()->getObject(
"data"))
632 return O.map(
"range", R.
range) && O.map(
"message", R.
message) &&
633 mapOptOrNull(Params,
"severity", R.
severity, P) &&
634 mapOptOrNull(Params,
"category", R.
category, P) &&
635 mapOptOrNull(Params,
"code", R.
code, P) &&
636 mapOptOrNull(Params,
"source", R.
source, P);
640 llvm::json::Object Result{
645 Result[
"version"] = PDP.
version;
646 return std::move(Result);
651 llvm::json::ObjectMapper O(Params, P);
654 O.map(
"only", R.
only);
659 OS <<
D.range <<
" [";
660 switch (
D.severity) {
677 return OS <<
'(' <<
D.severity <<
"): " <<
D.message <<
"]";
682 llvm::json::ObjectMapper O(Params, P);
689 llvm::json::ObjectMapper O(Params, P);
690 return O && O.map(
"changes", R.
changes);
695 llvm::json::ObjectMapper O(Params, P);
696 if (!O || !O.map(
"command", R.
command))
699 const auto *
Args = Params.getAsObject()->get(
"arguments");
702 const auto *ArgsArray =
Args->getAsArray();
704 P.field(
"arguments").report(
"expected array");
707 if (ArgsArray->size() > 1) {
708 P.field(
"arguments").report(
"Command should have 0 or 1 argument");
711 if (ArgsArray->size() == 1) {
718 llvm::json::Object O{
720 {
"kind",
static_cast<int>(P.
kind)},
725 O[
"score"] = *P.
score;
747 Result[
"name"] = P.
name;
753 Result[
"usr"] = P.
USR;
756 Result[
"id"] = P.
ID.
str();
759 return std::move(Result);
765 llvm::StringRef ContNameRef;
766 if (!ContNameRef.endswith(
"::")) {
776 llvm::json::ObjectMapper O(Params, P);
777 return O && O.map(
"query", R.
query) &&
778 mapOptOrNull(Params,
"limit", R.
limit, P);
782 auto Cmd = llvm::json::Object{{
"title",
C.title}, {
"command",
C.command}};
783 if (!
C.argument.getAsNull())
784 Cmd[
"arguments"] = llvm::json::Array{
C.argument};
785 return std::move(Cmd);
812 llvm::json::Object Result{{
"name", S.
name},
813 {
"kind",
static_cast<int>(S.
kind)},
818 Result[
"detail"] = S.
detail;
822 Result[
"deprecated"] =
true;
824 return std::move(Result);
828 llvm::json::Object FileChanges;
829 for (
auto &Change : WE.
changes)
830 FileChanges[Change.first] = llvm::json::Array(Change.second);
831 return llvm::json::Object{{
"changes", std::move(FileChanges)}};
836 llvm::json::ObjectMapper O(Params, P);
837 return O && O.map(
"file",
A.file) && O.map(
"selection",
A.selection) &&
838 O.map(
"tweakID",
A.tweakID);
842 return llvm::json::Object{
843 {
"tweakID",
A.tweakID}, {
"selection",
A.selection}, {
"file",
A.file}};
847 return llvm::json::Object{{
"edit", Params.
edit}};
852 llvm::json::ObjectMapper O(Response, P);
853 return O && O.map(
"applied", R.
applied) &&
859 llvm::json::ObjectMapper O(Params, P);
866 llvm::json::ObjectMapper O(Params, P);
868 if (!O || !O.map(
"triggerKind", TriggerKind) ||
878 !mapOptOrNull(Params,
"limit", R.
limit, P))
880 if (
auto *
Context = Params.getAsObject()->
get(
"context"))
892 llvm_unreachable(
"Invalid MarkupKind");
896 auto Str = V.getAsString();
898 P.report(
"expected string");
901 if (*Str ==
"plaintext")
903 else if (*Str ==
"markdown")
906 P.report(
"unknown markup kind");
917 if (MC.
value.empty())
920 return llvm::json::Object{
927 llvm::json::Object Result{{
"contents",
toJSON(H.contents)}};
929 if (H.range.hasValue())
930 Result[
"range"] =
toJSON(*H.range);
932 return std::move(Result);
937 if (
auto T =
E.getAsInteger()) {
950 auto KindVal =
static_cast<size_t>(
Kind);
952 KindVal <= SupportedCompletionItemKinds.size() &&
953 SupportedCompletionItemKinds[KindVal])
971 if (
auto *
A =
E.getAsArray()) {
972 for (
size_t I = 0; I <
A->size(); ++I) {
974 if (
fromJSON((*
A)[I], KindOut, P.index(I)))
975 Out.set(
size_t(KindOut));
983 assert(!
CI.label.empty() &&
"completion item label is required");
984 llvm::json::Object Result{{
"label",
CI.label}};
986 Result[
"kind"] =
static_cast<int>(
CI.kind);
987 if (!
CI.detail.empty())
988 Result[
"detail"] =
CI.detail;
989 if (
CI.documentation)
990 Result[
"documentation"] =
CI.documentation;
991 if (!
CI.sortText.empty())
992 Result[
"sortText"] =
CI.sortText;
993 if (!
CI.filterText.empty())
994 Result[
"filterText"] =
CI.filterText;
995 if (!
CI.insertText.empty())
996 Result[
"insertText"] =
CI.insertText;
998 Result[
"insertTextFormat"] =
static_cast<int>(
CI.insertTextFormat);
1000 Result[
"textEdit"] = *
CI.textEdit;
1001 if (!
CI.additionalTextEdits.empty())
1002 Result[
"additionalTextEdits"] = llvm::json::Array(
CI.additionalTextEdits);
1004 Result[
"deprecated"] =
CI.deprecated;
1005 Result[
"score"] =
CI.score;
1006 return std::move(Result);
1015 return (L.sortText.empty() ? L.label : L.sortText) <
1020 return llvm::json::Object{
1021 {
"isIncomplete", L.isIncomplete},
1022 {
"items", llvm::json::Array(L.items)},
1028 "parameter information label is required");
1029 llvm::json::Object Result;
1037 return std::move(Result);
1041 assert(!SI.
label.empty() &&
"signature information label is required");
1042 llvm::json::Object Result{
1043 {
"label", SI.
label},
1044 {
"parameters", llvm::json::Array(SI.
parameters)},
1048 return std::move(Result);
1059 "Unexpected negative value for number of active signatures.");
1061 "Unexpected negative value for active parameter index");
1062 return llvm::json::Object{
1065 {
"signatures", llvm::json::Array(SH.
signatures)},
1071 llvm::json::ObjectMapper O(Params, P);
1077 return llvm::json::Object{
1079 {
"kind",
static_cast<int>(DH.
kind)},
1084 return llvm::json::Object{
1085 {
"uri", FStatus.
uri},
1086 {
"state", FStatus.
state},
1092 llvm::json::Array Result;
1094 for (
const auto &Tok : Toks) {
1095 Result.push_back(Tok.deltaLine);
1096 Result.push_back(Tok.deltaStart);
1097 Result.push_back(Tok.length);
1098 Result.push_back(Tok.tokenType);
1099 Result.push_back(Tok.tokenModifiers);
1102 return std::move(Result);
1106 return std::tie(L.deltaLine, L.deltaStart, L.length, L.tokenType,
1113 return llvm::json::Object{{
"resultId", Tokens.resultId},
1118 return llvm::json::Object{
1125 llvm::json::Object Result{{
"resultId", TE.
resultId}};
1127 Result[
"edits"] = *TE.
edits;
1130 return std::move(Result);
1135 llvm::json::ObjectMapper O(Params, P);
1141 llvm::json::ObjectMapper O(Params, P);
1158 llvm::json::ObjectMapper O(Params, P);
1159 return O && O.map(
"settings", CCP.
settings);
1164 llvm::json::ObjectMapper O(Params, P);
1171 llvm::json::ObjectMapper O(Params, P);
1174 return mapOptOrNull(Params,
"compilationDatabaseChanges",
1180 llvm::json::ObjectMapper O(Params, P);
1184 return fromJSON(Params, Opts.ConfigSettings, P) &&
1185 O.map(
"compilationDatabasePath", Opts.compilationDatabasePath) &&
1186 mapOptOrNull(Params,
"fallbackFlags", Opts.fallbackFlags, P) &&
1187 mapOptOrNull(Params,
"clangdFileStatus", Opts.FileStatus, P);
1192 auto T =
E.getAsInteger();
1204 llvm::json::ObjectMapper O(Params, P);
1216 llvm::json::Object Result{{
"name", I.
name},
1217 {
"kind",
static_cast<int>(I.
kind)},
1223 Result[
"detail"] = I.
detail;
1227 Result[
"parents"] = I.
parents;
1231 Result[
"data"] = I.
data;
1232 return std::move(Result);
1237 llvm::json::ObjectMapper O(Params, P);
1240 return O && O.map(
"name", I.
name) && O.map(
"kind", I.
kind) &&
1241 O.map(
"uri", I.
uri) && O.map(
"range", I.
range) &&
1243 mapOptOrNull(Params,
"detail", I.
detail, P) &&
1244 mapOptOrNull(Params,
"deprecated", I.
deprecated, P) &&
1245 mapOptOrNull(Params,
"parents", I.
parents, P) &&
1246 mapOptOrNull(Params,
"children", I.
children, P) &&
1247 mapOptOrNull(Params,
"data", I.
data, P);
1252 llvm::json::ObjectMapper O(Params, P);
1253 return O && O.map(
"item", R.
item) && O.map(
"resolve", R.
resolve) &&
1259 llvm::json::ObjectMapper O(Params, P);
1266 llvm::json::ObjectMapper O(Params, P);
1275 llvm::json::Object Result{{
"name", I.
name},
1276 {
"kind",
static_cast<int>(I.
kind)},
1280 if (!I.
tags.empty())
1281 Result[
"tags"] = I.
tags;
1283 Result[
"detail"] = I.
detail;
1285 Result[
"data"] = I.
data;
1286 return std::move(Result);
1291 llvm::json::ObjectMapper O(Params, P);
1296 return O && O.map(
"name", I.
name) && O.map(
"kind", I.
kind) &&
1297 O.map(
"uri", I.
uri) && O.map(
"range", I.
range) &&
1299 mapOptOrNull(Params,
"data", I.
data, P);
1304 llvm::json::ObjectMapper O(Params, P);
1305 return O.map(
"item",
C.item);
1309 return llvm::json::Object{{
"from",
C.from}, {
"fromRanges",
C.fromRanges}};
1314 llvm::json::ObjectMapper O(Params, P);
1315 return O.map(
"item",
C.item);
1319 return llvm::json::Object{{
"to",
C.to}, {
"fromRanges",
C.fromRanges}};
1324 llvm::json::ObjectMapper O(Params, P);
1337 llvm_unreachable(
"Unknown clang.clangd.InlayHintKind");
1341 llvm::json::Object Result{{
"position", H.position},
1343 {
"paddingLeft", H.paddingLeft},
1344 {
"paddingRight", H.paddingRight}};
1347 Result[
"kind"] = std::move(
K);
1348 return std::move(Result);
1351 return std::tie(
A.position,
A.range,
A.kind,
A.label) ==
1352 std::tie(
B.position,
B.range,
B.kind,
B.label);
1355 return std::tie(
A.position,
A.range,
A.kind,
A.label) <
1356 std::tie(
B.position,
B.range,
B.kind,
B.label);
1367 return "designator";
1369 llvm_unreachable(
"Unknown clang.clangd.InlayHintKind");
1371 return OS << ToString(
Kind);
1385 llvm_unreachable(
"Unknown clang.clangd.OffsetEncoding");
1390 auto Str = V.getAsString();
1393 OE = llvm::StringSwitch<OffsetEncoding>(*Str)
1406 llvm::json::ObjectMapper O(Params, P);
1413 return llvm::json::Object{{
"range",
Out.range},
1416 return llvm::json::Object{{
"range",
Out.range}};
1421 llvm::json::ObjectMapper O(Params, P);
1426 return llvm::json::Object{
1434 llvm::json::ObjectMapper O(Params, P);
1439 llvm::json::Object Result{
1440 {
"startLine",
Range.startLine},
1441 {
"endLine",
Range.endLine},
1443 if (
Range.startCharacter)
1444 Result[
"startCharacter"] =
Range.startCharacter;
1445 if (
Range.endCharacter)
1446 Result[
"endCharacter"] =
Range.endCharacter;
1448 Result[
"kind"] = *
Range.kind;
1453 llvm::json::Object
Out;
1458 Total += *Child.getAsObject()->getInteger(
"_total");
1459 Out[
Entry.first] = std::move(Child);
1467 llvm::json::ObjectMapper O(Params, P);
1472 llvm::json::Object Result{
1479 Result[
"detail"] = N.
detail;
1481 Result[
"arcana"] = N.
arcana;
1483 Result[
"range"] = *N.
range;
1488 std::function<void(
const ASTNode &,
unsigned)> Print = [&](
const ASTNode &N,
1490 OS.indent(2 * Level) << N.
role <<
": " << N.
kind;
1495 Print(
C, Level + 1);
bool includeDeclaration
Include the declaration of the current symbol.
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
A document highlight is a range inside a text document which deserves special attention.
Range selectionRange
The range that should be selected and revealed when this type hierarchy item is being picked,...
Range range
The range enclosing this symbol not including leading/trailing whitespace but everything else like co...
@ Designator
A hint before an element of an aggregate braced initializer list, indicating what it is initializing.
TextDocumentItem textDocument
The document that was opened.
std::unique_ptr< GlobalCompilationDatabase > Base
std::string source
A human-readable string describing the source of this diagnostic, e.g.
constexpr auto SymbolKindMin
URIForFile uri
The text document's URI.
Clangd extension that's used in the 'compilationDatabaseChanges' in workspace/didChangeConfiguration ...
std::string workingDirectory
bool DiagnosticFixes
Whether the client accepts diagnostics with codeActions attached inline.
llvm::Optional< bool > wantDiagnostics
Forces diagnostics to be generated, or to not be generated, for this version of the file.
std::string previousResultId
The previous result id.
unsigned tokenModifiers
each set bit will be looked up in SemanticTokensLegend.tokenModifiers
A set of edits generated for a single file.
Body of textDocument/semanticTokens/full request.
URIForFile uri
The text document's URI.
std::vector< Diagnostic > diagnostics
An array of diagnostic information items.
URIForFile uri
The file's URI.
bool DiagnosticCategory
Whether the client accepts diagnostics with category attached to it using the "category" extension.
URIForFile uri
The resource identifier of this item.
MessageType type
The message type.
int resolve
The hierarchy levels to resolve. 0 indicates no level.
TextDocumentIdentifier textDocument
The text document.
std::string detail
More detaill for this item, e.g. the signature of a function.
A code action represents a change that can be performed in code, e.g.
llvm::Optional< std::string > category
The diagnostic's category.
Body of textDocument/semanticTokens/full/delta request.
llvm::Optional< CompletionItemKindBitset > CompletionItemKinds
The supported set of CompletionItemKinds for textDocument/completion.
constexpr unsigned SemanticTokenEncodingSize
llvm::Optional< std::string > message
Optional, a final message indicating to for example indicate the outcome of the operation.
llvm::Optional< int > processId
The process Id of the parent process that started the server.
std::string detail
Brief additional information, such as "||" for the particular operator.
Represents a collection of completion items to be presented in the editor.
bool CompletionFixes
Client supports completions with additionalTextEdit near the cursor.
WantDiagnostics Diagnostics
const Type * get(const Key< Type > &Key) const
Get data stored for a typed Key.
std::vector< std::string > only
Requested kind of actions to return.
Describes a a replacement of a contiguous range of semanticTokens.
This models LSP SemanticTokensDelta | SemanticTokens, which is the result of textDocument/semanticTok...
llvm::Optional< SymbolKindBitset > WorkspaceSymbolKinds
The supported set of SymbolKinds for workspace/symbol.
std::vector< Position > positions
The positions inside the text document.
std::unique_ptr< CompilerInvocation > CI
bool isPreferred
Marks this as a preferred action.
ConfigurationSettings settings
std::string label
The label of this completion item.
bool HierarchicalDocumentSymbol
Client supports hierarchical document symbols.
Position start
The range's start position.
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...
bool forceRebuild
Force a complete rebuild of the file, ignoring all cached state.
MarkupKind CompletionDocumentationFormat
The documentation format that should be used for textDocument/completion.
@ Created
The file got created.
std::vector< SymbolTag > tags
Tags for this item.
SymbolKind kind
The kind of the hierarchy item. For instance, class or interface.
A range in a text document that links to an internal or external resource, like another text document...
bool CompletionSnippets
Client supports snippets as insert text.
unsigned deltaLine
token line number, relative to the previous token
Range range
The range this highlight applies to.
static llvm::Expected< URIForFile > fromURI(const URI &U, llvm::StringRef HintPath)
TextDocumentIdentifier textDocument
The document in which the command was invoked.
CodeActionContext context
Context carrying additional information.
llvm::Optional< std::string > failureReason
std::string kind
The specific kind of node this is, such as "BinaryOperator".
llvm::Optional< Range > range
The position of the node to be dumped.
Represents an incoming call, e.g. a caller of a method or constructor.
static llvm::Expected< URI > parse(llvm::StringRef Uri)
Parse a URI string "<scheme>:[//<authority>/]<path>".
llvm::json::Object rawCapabilities
The same data as capabilities, but not parsed (to expose to modules).
llvm::Optional< int > limit
Max results to return, overriding global default.
std::vector< DocumentSymbol > children
Children of this symbol, e.g. properties of a class.
std::bitset< SymbolKindMax+1 > SymbolKindBitset
std::string containerName
Range range
The range enclosing this type hierarchy item not including leading/trailing whitespace but everything...
llvm::Optional< int64_t > version
The version number of this document (it will strictly increase after each change, including undo/redo...
bool cancellable
Controls if a cancel button should show to allow the user to cancel the long-running operation.
Position position
The position at which this request was sent.
Range range
The range at which the message applies.
llvm::Optional< bool > cancellable
Controls enablement state of a cancel button.
llvm::Optional< Range > range
The range of the original source file covered by this node.
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
int line
Line position in a document (zero-based).
llvm::Optional< std::string > kind
The kind of the code action.
To start progress reporting a $/progress notification with the following payload must be sent.
std::string title
A short, human-readable, title for this code action.
DocumentHighlightKind kind
The highlight kind, default is DocumentHighlightKind.Text.
static llvm::StringRef toTextKind(MarkupKind Kind)
std::map< std::string, std::vector< TextEdit > > changes
Holds changes to existing resources.
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
Resolves the absolute path of U.
URIForFile uri
The text document's URI.
Signals the end of progress reporting.
llvm::Optional< std::vector< OffsetEncoding > > offsetEncoding
Supported encodings for LSP character offsets. (clangd extension).
bool OffsetsInSignatureHelp
Client supports processing label offsets instead of a simple label string.
std::string triggerCharacter
The trigger character (a single character) that has trigger code complete.
llvm::Optional< WorkspaceEdit > edit
The workspace edit this code action performs.
ClientCapabilities capabilities
The capabilities provided by the client (editor or tool)
llvm::json::Value argument
std::string state
The human-readable string presents the current state of the file, can be shown in the UI (e....
bool RenamePrepareSupport
The client supports testing for validity of rename operations before execution.
MarkupKind HoverContentFormat
The content format that should be used for Hover requests.
Arguments for the 'applyTweak' command.
MarkupKind SignatureHelpDocumentationFormat
The documentation format that should be used for textDocument/signatureHelp.
Specifies a single semantic token in the document.
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
llvm::Optional< std::vector< SemanticTokensEdit > > edits
Set if we computed edits relative to a previous set of tokens.
std::vector< SignatureInformation > signatures
The resulting signatures.
TextDocumentIdentifier textDocument
std::string role
The general kind of node, such as "expression" Corresponds to the base AST node type such as Expr.
URIForFile uri
The URI for which diagnostic information is reported.
A top-level diagnostic that may have Notes and Fixes.
llvm::json::Value toJSON(const FuzzyFindRequest &Request)
llvm::Optional< std::string > message
Optional, more detailed associated progress message.
unsigned deltaStart
token start character, relative to the previous token (relative to 0 or the previous token's start if...
std::string name
The human readable name of the hierarchy item.
The class presents a C++ symbol, e.g.
unsigned tokenType
will be looked up in SemanticTokensLegend.tokenTypes
@ Deleted
The file got deleted.
Represents an outgoing call, e.g.
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request, llvm::json::Path P)
std::string detail
More detail for this symbol, e.g the signature of a function.
llvm::json::Value token
The token to be used to report progress.
URIForFile uri
The text document's URI.
std::string data
An optional 'data' field, which can be used to identify a call hierarchy item in an incomingCalls or ...
std::string command
The identifier of the actual command handler.
TextDocumentIdentifier textDocument
SymbolKind indexSymbolKindToSymbolKind(index::SymbolKind Kind)
llvm::json::Object data
A data entry field that is preserved between a textDocument/publishDiagnostics notification and textD...
Range selectionRange
The range that should be selected and revealed when this symbol is being picked, e....
Structure to capture a description for an error code.
std::string languageId
The text document's language identifier.
std::string sortText
A string that should be used when comparing this item with other items.
static const char * toString(OffsetEncoding OE)
int character
Character offset on a line in a document (zero-based).
CompletionTriggerKind triggerKind
How the completion was triggered.
Position position
The position inside the text document.
Position end
The range's end position.
Represents programming constructs like variables, classes, interfaces etc.
llvm::Optional< std::vector< SemanticToken > > tokens
Set if we computed a fresh set of tokens.
unsigned length
the length of the token. A token cannot be multiline
std::vector< FileEvent > changes
The actual file events.
llvm::Optional< std::vector< TypeHierarchyItem > > children
If this type hierarchy item is resolved, it contains the direct children of the current item.
const llvm::DenseMap< llvm::StringRef, MemoryTree > & children() const
Returns edges to direct children of this node.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
llvm::Optional< Command > command
A command this code action executes.
CompletionItemKind
The kind of a completion entry.
URIForFile uri
The URI of the text document where this type hierarchy item belongs to.
Represents information about identifier.
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Parameters for the document link request.
bool DiagnosticRelatedInformation
Whether the client accepts diagnostics with related locations.
std::string USR
Unified Symbol Resolution identifier This is an opaque string uniquely identifying a symbol.
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
int activeSignature
The active signature.
std::string text
The content of the opened text document.
InitializationOptions initializationOptions
User-provided initialization options.
static llvm::json::Value encodeTokens(llvm::ArrayRef< SemanticToken > Toks)
The parameter of a callHierarchy/incomingCalls request.
int resolve
The hierarchy levels to resolve. 0 indicates no level.
std::vector< Diagnostic > diagnostics
An array of diagnostics known on the client side overlapping the range provided to the textDocument/c...
TextDocumentIdentifier textDocument
The text document.
Reporting progress is done using the following payload.
size_t self() const
Returns total number of bytes used by this node only.
bool WorkDoneProgress
The client supports progress notifications.
llvm::Optional< std::vector< Diagnostic > > diagnostics
The diagnostics that this code action resolves.
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
@ Type
An inlay hint that for a type annotation.
std::map< std::string, ClangdCompileCommand > compilationDatabaseChanges
llvm::Optional< std::string > detail
Optional detail for the hierarchy item.
bool deprecated
true if the hierarchy item is deprecated. Otherwise, false.
bool SemanticTokenRefreshSupport
Whether the client implementation supports a refresh request sent from the server to the client.
bool CodeActionStructure
Client supports CodeAction return value for textDocument/codeAction.
Payload for textDocument/ast request.
SymbolKind kind
The kind of this symbol.
bool percentage
Optional progress percentage to display (value 100 is considered 100%).
llvm::Optional< Range > range
The visible document range for which inlay hints should be computed.
std::vector< TextDocumentContentChangeEvent > contentChanges
The actual content changes.
VersionedTextDocumentIdentifier textDocument
The document that did change.
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
TextDocumentIdentifier textDocument
The text document.
TextDocumentIdentifier textDocument
The document that was saved.
The parameters of a Workspace Symbol Request.
std::vector< std::string > compilationCommand
FileChangeType type
The change type.
Represents the signature of a callable.
A versioned set of tokens.
llvm::Optional< std::int64_t > version
The version number of this document.
std::string message
The actual message.
std::string message
The diagnostic's message.
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
Canonicalizes AbsPath via URI.
int severity
The diagnostic's severity.
llvm::Optional< TraceLevel > trace
The initial trace setting. If omitted trace is disabled ('off').
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< int64_t > version
The version number of the document the diagnostics are published for.
llvm::Optional< unsigned > percentage
Optional progress percentage to display (value 100 is considered 100%).
llvm::raw_string_ostream OS
Stores information about a region of code that can be folded.
const static llvm::StringLiteral REFACTOR_KIND
llvm::Optional< std::vector< TypeHierarchyItem > > parents
If this type hierarchy item is resolved, it contains the direct parents.
Range range
The range enclosing this symbol not including leading / trailing whitespace but everything else,...
llvm::Optional< Range > range
The range of the document that changed.
Range range
The range this link applies to.
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
std::string query
A query string to filter symbols by.
bool deprecated
Indicates if this symbol is deprecated.
bool TheiaSemanticHighlighting
Client supports Theia semantic highlighting extension.
bool operator<(const Ref &L, const Ref &R)
llvm::Optional< std::string > rootPath
The rootPath of the workspace.
Clangd extension: parameters configurable at initialize time.
TextDocumentIdentifier textDocument
The document that was closed.
Represents programming constructs like functions or constructors in the context of call hierarchy.
std::string code
The diagnostic's code. Can be omitted.
TextDocumentIdentifier textDocument
The document that was opened.
int activeParameter
The active parameter of the active signature.
llvm::Optional< int > limit
Max results to return, overriding global default.
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
bool ImplicitProgressCreation
The client supports implicit $/progress work-done progress streams, without a preceding window/workDo...
std::string name
The name of this symbol.
CompletionContext context
bool SemanticTokens
Client advertises support for the semanticTokens feature.
InlayHintKind
Inlay hint kinds.
std::string arcana
A one-line dump of detailed information about the node.
TextDocumentIdentifier textDocument
The document to provide document links for.
TextDocumentIdentifier textDocument
The text document.
std::string newText
The string to be inserted.
CompiledFragmentImpl & Out
bool CancelsStaleRequests
Whether the client claims to cancel stale requests.
TextDocumentIdentifier textDocument
The text document.
void elog(const char *Fmt, Ts &&... Vals)
std::vector< ASTNode > children
Nodes nested within this one, such as the operands of a BinaryOperator.
llvm::Optional< URIForFile > rootUri
The rootUri of the workspace.
TypeHierarchyDirection direction
The direction of the hierarchy levels to resolve.
URIForFile target
The uri this link points to. If missing a resolve request is sent later.
std::string text
The new text of the range/document.
TextDocumentIdentifier textDocument
The text document.
The parameter of a callHierarchy/outgoingCalls request.
Simplified description of a clang AST node.
constexpr auto CompletionItemKindMin
TypeHierarchyItem item
The item to resolve.
Range range
The range of the text document to be manipulated.
A context is an immutable container for per-request data that must be propagated through layers that ...
The show message notification is sent from a server to a client to ask the client to display a partic...
const static llvm::StringLiteral INFO_KIND
A URI describes the location of a source file.
bool HasSignatureHelp
Client supports signature help.
std::string title
Mandatory title of the progress operation.
Range range
The range for which the command was invoked.
static constexpr bool Value
std::string name
The name of this item.
llvm::Optional< std::string > data
An optional 'data' field, which can be used to identify a type hierarchy item in a resolve request.
std::string newName
The new name of the symbol.
std::vector< HeaderHandle > Path
A parameter literal used in inlay hint requests.
SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
llvm::Optional< int > rangeLength
The length of the range that got replaced.
SymbolKind kind
The kind of this item.
const static llvm::StringLiteral QUICKFIX_KIND
Parameters for the typeHierarchy/resolve request.
@ Parameter
An inlay hint that is for a parameter.