[clang-tools-extra] c338735 - [clangd] Enable folding ranges by default.
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 30 03:05:10 PDT 2022
Author: Utkarsh Saxena
Date: 2022-08-30T12:04:59+02:00
New Revision: c338735020033e49fe36369ce3e49e316b6d2da0
URL: https://github.com/llvm/llvm-project/commit/c338735020033e49fe36369ce3e49e316b6d2da0
DIFF: https://github.com/llvm/llvm-project/commit/c338735020033e49fe36369ce3e49e316b6d2da0.diff
LOG: [clangd] Enable folding ranges by default.
Differential Revision: https://reviews.llvm.org/D132919
Added:
Modified:
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/test/initialize-params.test
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 e0129d99d9706..449ac9e3a85bd 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -584,6 +584,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
{"callHierarchyProvider", true},
{"clangdInlayHintsProvider", true},
{"inlayHintProvider", true},
+ {"foldingRangeProvider", true},
};
{
@@ -613,8 +614,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
CodeAction::INFO_KIND}}}
: llvm::json::Value(true);
- if (Opts.FoldingRanges)
- ServerCaps["foldingRangeProvider"] = true;
std::vector<llvm::StringRef> Commands;
for (llvm::StringRef Command : Handlers.CommandHandlers.keys())
@@ -1618,8 +1617,7 @@ void ClangdLSPServer::bindMethods(LSPBinder &Bind,
Bind.method("clangd/inlayHints", this, &ClangdLSPServer::onClangdInlayHints);
Bind.method("textDocument/inlayHint", this, &ClangdLSPServer::onInlayHint);
Bind.method("$/memoryUsage", this, &ClangdLSPServer::onMemoryUsage);
- if (Opts.FoldingRanges)
- Bind.method("textDocument/foldingRange", this, &ClangdLSPServer::onFoldingRange);
+ Bind.method("textDocument/foldingRange", this, &ClangdLSPServer::onFoldingRange);
Bind.command(ApplyFixCommand, this, &ClangdLSPServer::onCommandApplyEdit);
Bind.command(ApplyTweakCommand, this, &ClangdLSPServer::onCommandApplyTweak);
diff --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h
index 6be0c930ded47..13eed0784c589 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -161,9 +161,6 @@ class ClangdServer {
/// fetch system include path.
std::vector<std::string> QueryDriverGlobs;
- /// Enable preview of FoldingRanges feature.
- bool FoldingRanges = false;
-
// Whether the client supports folding only complete lines.
bool LineFoldingOnly = false;
diff --git a/clang-tools-extra/clangd/test/initialize-params.test b/clang-tools-extra/clangd/test/initialize-params.test
index 8387fb9b504be..e7810c66f44a2 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -43,6 +43,7 @@
# CHECK-NEXT: "clangd.applyTweak"
# CHECK-NEXT: ]
# CHECK-NEXT: },
+# CHECK-NEXT: "foldingRangeProvider": true,
# CHECK-NEXT: "hoverProvider": true,
# CHECK-NEXT: "implementationProvider": true,
# CHECK-NEXT: "inlayHintProvider": true,
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 76cfaf7a35dfe..11c5acb71d978 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -308,6 +308,8 @@ RetiredFlag<bool> CollectMainFileRefs("collect-main-file-refs");
RetiredFlag<bool> CrossFileRename("cross-file-rename");
RetiredFlag<std::string> ClangTidyChecks("clang-tidy-checks");
RetiredFlag<std::string> InlayHints("inlay-hints");
+RetiredFlag<std::string> FoldingRanges("folding-ranges");
+
opt<int> LimitResults{
"limit-results",
@@ -333,14 +335,6 @@ list<std::string> TweakList{
CommaSeparated,
};
-opt<bool> FoldingRanges{
- "folding-ranges",
- cat(Features),
- desc("Enable preview of FoldingRanges feature"),
- init(false),
- Hidden,
-};
-
opt<unsigned> WorkerThreadsCount{
"j",
cat(Misc),
@@ -903,7 +897,6 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
Opts.StaticIndex = PAI.get();
}
Opts.AsyncThreadsCount = WorkerThreadsCount;
- Opts.FoldingRanges = FoldingRanges;
Opts.MemoryCleanup = getMemoryCleanupFunction();
Opts.CodeComplete.IncludeIneligibleResults = IncludeIneligibleResults;
More information about the cfe-commits
mailing list