[clang-tools-extra] 71c4fb1 - [clangd] Set Incompleteness for spec fuzzyfind requests
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 8 09:35:38 PDT 2022
Author: Kadir Cetinkaya
Date: 2022-09-08T18:34:25+02:00
New Revision: 71c4fb1d6482e9b7e825ad28e0366649301470d3
URL: https://github.com/llvm/llvm-project/commit/71c4fb1d6482e9b7e825ad28e0366649301470d3
DIFF: https://github.com/llvm/llvm-project/commit/71c4fb1d6482e9b7e825ad28e0366649301470d3.diff
LOG: [clangd] Set Incompleteness for spec fuzzyfind requests
Differential Revision: https://reviews.llvm.org/D133479
Added:
Modified:
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index 9d9b0e748153..275749da55e7 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -70,6 +70,7 @@
#include <algorithm>
#include <iterator>
#include <limits>
+#include <utility>
// We log detailed candidate here if you run with -debug-only=codecomplete.
#define DEBUG_TYPE "CodeComplete"
@@ -1363,13 +1364,14 @@ bool includeSymbolFromIndex(CodeCompletionContext::Kind Kind,
return true;
}
-std::future<SymbolSlab> startAsyncFuzzyFind(const SymbolIndex &Index,
- const FuzzyFindRequest &Req) {
- return runAsync<SymbolSlab>([&Index, Req]() {
+std::future<std::pair<bool, SymbolSlab>>
+startAsyncFuzzyFind(const SymbolIndex &Index, const FuzzyFindRequest &Req) {
+ return runAsync<std::pair<bool, SymbolSlab>>([&Index, Req]() {
trace::Span Tracer("Async fuzzyFind");
SymbolSlab::Builder Syms;
- Index.fuzzyFind(Req, [&Syms](const Symbol &Sym) { Syms.insert(Sym); });
- return std::move(Syms).build();
+ bool Incomplete =
+ Index.fuzzyFind(Req, [&Syms](const Symbol &Sym) { Syms.insert(Sym); });
+ return std::make_pair(Incomplete, std::move(Syms).build());
});
}
@@ -1721,7 +1723,9 @@ class CodeCompleteFlow {
SPAN_ATTACH(Tracer, "Speculative results", true);
trace::Span WaitSpec("Wait speculative results");
- return SpecFuzzyFind->Result.get();
+ auto SpecRes = SpecFuzzyFind->Result.get();
+ Incomplete |= SpecRes.first;
+ return std::move(SpecRes.second);
}
SPAN_ATTACH(Tracer, "Speculative results", false);
diff --git a/clang-tools-extra/clangd/CodeComplete.h b/clang-tools-extra/clangd/CodeComplete.h
index ebd451c95c76..269be8944df1 100644
--- a/clang-tools-extra/clangd/CodeComplete.h
+++ b/clang-tools-extra/clangd/CodeComplete.h
@@ -31,6 +31,7 @@
#include "llvm/ADT/StringRef.h"
#include <functional>
#include <future>
+#include <utility>
namespace clang {
class NamedDecl;
@@ -262,7 +263,7 @@ struct SpeculativeFuzzyFind {
llvm::Optional<FuzzyFindRequest> NewReq;
/// The result is consumed by `codeComplete()` if speculation succeeded.
/// NOTE: the destructor will wait for the async call to finish.
- std::future<SymbolSlab> Result;
+ std::future<std::pair<bool /*Incomplete*/, SymbolSlab>> Result;
};
/// Gets code completions at a specified \p Pos in \p FileName.
diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index f2d8328afdbb..2fb5c7a47f77 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2594,7 +2594,8 @@ TEST(CompletionTest, EnableSpeculativeIndexRequest) {
Opts.Index = &Requests;
auto CompleteAtPoint = [&](StringRef P) {
- cantFail(runCodeComplete(Server, File, Test.point(P), Opts));
+ auto CCR = cantFail(runCodeComplete(Server, File, Test.point(P), Opts));
+ EXPECT_TRUE(CCR.HasMore);
};
CompleteAtPoint("1");
More information about the cfe-commits
mailing list