[clang-tools-extra] cea736e - [clangd] Hide inlay hints capability behind a command-line flag
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Sun May 2 22:02:10 PDT 2021
Author: Nathan Ridge
Date: 2021-05-03T01:01:57-04:00
New Revision: cea736e5b8a48065007a591d71699b53c04d95b3
URL: https://github.com/llvm/llvm-project/commit/cea736e5b8a48065007a591d71699b53c04d95b3
DIFF: https://github.com/llvm/llvm-project/commit/cea736e5b8a48065007a591d71699b53c04d95b3.diff
LOG: [clangd] Hide inlay hints capability behind a command-line flag
Differential Revision: https://reviews.llvm.org/D101275
Added:
Modified:
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index a7cc1ed42818f..77fc948cbfe08 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -571,7 +571,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
{"referencesProvider", true},
{"astProvider", true}, // clangd extension
{"typeHierarchyProvider", true},
- {"clangdInlayHintsProvider", true},
{"memoryUsageProvider", true}, // clangd extension
{"compilationDatabase", // clangd extension
llvm::json::Object{{"automaticReload", true}}},
@@ -608,6 +607,9 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
if (Opts.FoldingRanges)
ServerCaps["foldingRangeProvider"] = true;
+ if (Opts.InlayHints)
+ ServerCaps["clangdInlayHintsProvider"] = true;
+
std::vector<llvm::StringRef> Commands;
for (llvm::StringRef Command : Handlers.CommandHandlers.keys())
Commands.push_back(Command);
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.h b/clang-tools-extra/clangd/ClangdLSPServer.h
index 577ee66b34243..3f5cc9abc688a 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -62,6 +62,9 @@ class ClangdLSPServer : private ClangdServer::Callbacks,
std::function<bool(const Tweak &)> TweakFilter = [](const Tweak &T) {
return !T.hidden(); // only enable non-hidden tweaks.
};
+
+ /// Enable preview of InlayHints feature.
+ bool InlayHints = false;
};
ClangdLSPServer(Transport &Transp, const ThreadsafeFS &TFS,
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 8fe14231bfee1..07fec2fc76358 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -308,6 +308,9 @@ opt<bool> FoldingRanges{
Hidden,
};
+opt<bool> InlayHints{"inlay-hints", cat(Features),
+ desc("Enable preview of InlayHints feature"), init(false)};
+
opt<unsigned> WorkerThreadsCount{
"j",
cat(Misc),
@@ -829,6 +832,7 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
}
Opts.AsyncThreadsCount = WorkerThreadsCount;
Opts.FoldingRanges = FoldingRanges;
+ Opts.InlayHints = InlayHints;
Opts.MemoryCleanup = getMemoryCleanupFunction();
Opts.CodeComplete.IncludeIneligibleResults = IncludeIneligibleResults;
More information about the cfe-commits
mailing list