[clang-tools-extra] e623ce6 - [clangd] Split CC and refs limit and increase refs limit to 1000
Kirill Bobyrev via cfe-commits
cfe-commits at lists.llvm.org
Wed May 5 14:40:09 PDT 2021
Author: Kirill Bobyrev
Date: 2021-05-05T23:39:48+02:00
New Revision: e623ce6188d698422d4ead24065056d6a869e6f8
URL: https://github.com/llvm/llvm-project/commit/e623ce6188d698422d4ead24065056d6a869e6f8
DIFF: https://github.com/llvm/llvm-project/commit/e623ce6188d698422d4ead24065056d6a869e6f8.diff
LOG: [clangd] Split CC and refs limit and increase refs limit to 1000
Related discussion: https://github.com/clangd/clangd/discussions/761
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D101902
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 77fc948cbfe08..913c5c3219a5c 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1264,7 +1264,7 @@ void ClangdLSPServer::onChangeConfiguration(
void ClangdLSPServer::onReference(const ReferenceParams &Params,
Callback<std::vector<Location>> Reply) {
Server->findReferences(
- Params.textDocument.uri.file(), Params.position, Opts.CodeComplete.Limit,
+ Params.textDocument.uri.file(), Params.position, Opts.ReferencesLimit,
[Reply = std::move(Reply),
IncludeDecl(Params.context.includeDeclaration)](
llvm::Expected<ReferencesResult> Refs) mutable {
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.h b/clang-tools-extra/clangd/ClangdLSPServer.h
index 3f5cc9abc688a..8c43d18502875 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -65,6 +65,9 @@ class ClangdLSPServer : private ClangdServer::Callbacks,
/// Enable preview of InlayHints feature.
bool InlayHints = false;
+
+ /// Limit the number of references returned (0 means no limit).
+ size_t ReferencesLimit = 0;
};
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 07fec2fc76358..f0aa89b8091fb 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -292,6 +292,14 @@ opt<int> LimitResults{
init(100),
};
+opt<int> ReferencesLimit{
+ "limit-references",
+ cat(Features),
+ desc("Limit the number of references returned by clangd. "
+ "0 means no limit (default=1000)"),
+ init(1000),
+};
+
list<std::string> TweakList{
"tweaks",
cat(Features),
@@ -821,6 +829,7 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
}
#endif
Opts.BackgroundIndex = EnableBackgroundIndex;
+ Opts.ReferencesLimit = ReferencesLimit;
auto PAI = createProjectAwareIndex(loadExternalIndex, Sync);
if (StaticIdx) {
IdxStack.emplace_back(std::move(StaticIdx));
More information about the cfe-commits
mailing list