[clang-tools-extra] [clangd] Check for other clangd extension capabilities under 'experimental' (PR #116531)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 16 23:46:19 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangd
Author: Nathan Ridge (HighCommander4)
<details>
<summary>Changes</summary>
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'.
---
Full diff: https://github.com/llvm/llvm-project/pull/116531.diff
2 Files Affected:
- (modified) clang-tools-extra/clangd/Protocol.cpp (+22)
- (modified) clang-tools-extra/clangd/Protocol.h (+3)
``````````diff
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index 761f96846d4538..2b26e16598821c 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -511,6 +511,28 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
R.CompletionFixes |= *EditsNearCursor;
}
+ if (auto *References = TextDocument->getObject("references")) {
+ if (auto ContainerSupport = References->getBoolean("container")) {
+ R.ReferenceContainer |= *ContainerSupport;
+ }
+ }
+ if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
+ if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline")) {
+ R.DiagnosticFixes |= *CodeActions;
+ }
+ }
+ }
+ if (auto *Window = Experimental->getObject("window")) {
+ if (auto Implicit =
+ Window->getBoolean("implicitWorkDoneProgressCreate")) {
+ R.ImplicitProgressCreation |= *Implicit;
+ }
+ }
+ if (auto *OffsetEncoding = Experimental->get("offsetEncoding")) {
+ R.offsetEncoding.emplace();
+ if (!fromJSON(*OffsetEncoding, *R.offsetEncoding,
+ P.field("offsetEncoding")))
+ return false;
}
}
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h
index 5b28095758198d..c7ef1a13e6e39e 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -452,6 +452,7 @@ struct ClientCapabilities {
std::optional<SymbolKindBitset> WorkspaceSymbolKinds;
/// Whether the client accepts diagnostics with codeActions attached inline.
+ /// This is a clangd extension.
/// textDocument.publishDiagnostics.codeActionsInline.
bool DiagnosticFixes = false;
@@ -475,6 +476,7 @@ struct ClientCapabilities {
/// Client supports displaying a container string for results of
/// textDocument/reference (clangd extension)
+ /// textDocument.references.container
bool ReferenceContainer = false;
/// Client supports hierarchical document symbols.
@@ -563,6 +565,7 @@ struct ClientCapabilities {
/// Whether the client supports the textDocument/inactiveRegions
/// notification. This is a clangd extension.
+ /// textDocument.inactiveRegionsCapabilities.inactiveRegions
bool InactiveRegions = false;
};
bool fromJSON(const llvm::json::Value &, ClientCapabilities &,
``````````
</details>
https://github.com/llvm/llvm-project/pull/116531
More information about the cfe-commits
mailing list