Skip to content

Commit a01e4d2

Browse files
[clangd] Check for other clangd extension capabilities under 'experimental'
This is a follow-up to PR114699, with the same motivation: to support clients which only support adding custom (language-specific or server-specific) capabilities under 'experimental'.
1 parent 2991a4e commit a01e4d2

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,35 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
511511
if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
512512
R.CompletionFixes |= *EditsNearCursor;
513513
}
514+
if (auto *References = TextDocument->getObject("references")) {
515+
if (auto ContainerSupport = References->getBoolean("container")) {
516+
R.ReferenceContainer |= *ContainerSupport;
517+
}
518+
}
519+
if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
520+
if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline")) {
521+
R.DiagnosticFixes |= *CodeActions;
522+
}
523+
}
524+
if (auto *InactiveRegions =
525+
TextDocument->getObject("inactiveRegionsCapabilities")) {
526+
if (auto InactiveRegionsSupport =
527+
InactiveRegions->getBoolean("inactiveRegions")) {
528+
R.InactiveRegions |= *InactiveRegionsSupport;
529+
}
530+
}
531+
}
532+
if (auto *Window = Experimental->getObject("window")) {
533+
if (auto Implicit =
534+
Window->getBoolean("implicitWorkDoneProgressCreate")) {
535+
R.ImplicitProgressCreation |= *Implicit;
536+
}
537+
}
538+
if (auto *OffsetEncoding = Experimental->get("offsetEncoding")) {
539+
R.offsetEncoding.emplace();
540+
if (!fromJSON(*OffsetEncoding, *R.offsetEncoding,
541+
P.field("offsetEncoding")))
542+
return false;
514543
}
515544
}
516545

clang-tools-extra/clangd/Protocol.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ struct ClientCapabilities {
452452
std::optional<SymbolKindBitset> WorkspaceSymbolKinds;
453453

454454
/// Whether the client accepts diagnostics with codeActions attached inline.
455+
/// This is a clangd extension.
455456
/// textDocument.publishDiagnostics.codeActionsInline.
456457
bool DiagnosticFixes = false;
457458

@@ -475,6 +476,7 @@ struct ClientCapabilities {
475476

476477
/// Client supports displaying a container string for results of
477478
/// textDocument/reference (clangd extension)
479+
/// textDocument.references.container
478480
bool ReferenceContainer = false;
479481

480482
/// Client supports hierarchical document symbols.
@@ -563,6 +565,7 @@ struct ClientCapabilities {
563565

564566
/// Whether the client supports the textDocument/inactiveRegions
565567
/// notification. This is a clangd extension.
568+
/// textDocument.inactiveRegionsCapabilities.inactiveRegions
566569
bool InactiveRegions = false;
567570
};
568571
bool fromJSON(const llvm::json::Value &, ClientCapabilities &,

0 commit comments

Comments
 (0)