summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
diff options
context:
space:
mode:
authorNathan Ridge <zeratul976@hotmail.com>2019-06-15 02:26:47 +0000
committerNathan Ridge <zeratul976@hotmail.com>2019-06-15 02:26:47 +0000
commitf1e6f5713caac5da97dcde34a7042061bb0e6afa (patch)
tree3749a6a8cc46c27e65c31811fd870f2c3f9056f8 /clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
parent0b1ea8cb2825cb51c1c2f6dfa9bef95f4a450f93 (diff)
downloadbcm5719-llvm-f1e6f5713caac5da97dcde34a7042061bb0e6afa.tar.gz
bcm5719-llvm-f1e6f5713caac5da97dcde34a7042061bb0e6afa.zip
[clangd] Index API and implementations for relations
Summary: This builds on the relations support added in D59407, D62459, and D62471 to expose relations in SymbolIndex and its implementations. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62839 llvm-svn: 363481
Diffstat (limited to 'clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp')
-rw-r--r--clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 2f846e9c837..23fa0526b0d 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -90,7 +90,7 @@ std::unique_ptr<SymbolIndex> memIndex(std::vector<Symbol> Symbols) {
SymbolSlab::Builder Slab;
for (const auto &Sym : Symbols)
Slab.insert(Sym);
- return MemIndex::build(std::move(Slab).build(), RefSlab());
+ return MemIndex::build(std::move(Slab).build(), RefSlab(), RelationSlab());
}
CodeCompleteResult completions(ClangdServer &Server, llvm::StringRef TestCode,
@@ -641,10 +641,10 @@ TEST(CompletionTest, IncludeInsertionPreprocessorIntegrationTests) {
CodeCompleteOptions NoInsertion;
NoInsertion.InsertIncludes = CodeCompleteOptions::NeverInsert;
Results = completions(Server,
- R"cpp(
+ R"cpp(
int main() { ns::^ }
)cpp",
- {Sym}, NoInsertion);
+ {Sym}, NoInsertion);
EXPECT_THAT(Results.Completions,
ElementsAre(AllOf(Named("X"), Not(InsertInclude()))));
// Duplicate based on inclusions in preamble.
@@ -1108,6 +1108,10 @@ public:
void refs(const RefsRequest &,
llvm::function_ref<void(const Ref &)>) const override {}
+ void relations(const RelationsRequest &,
+ llvm::function_ref<void(const SymbolID &, const Symbol &)>)
+ const override {}
+
// This is incorrect, but IndexRequestCollector is not an actual index and it
// isn't used in production code.
size_t estimateMemoryUsage() const override { return 0; }
@@ -2026,19 +2030,19 @@ TEST(CompletionTest, OverridesNonIdentName) {
TEST(GuessCompletionPrefix, Filters) {
for (llvm::StringRef Case : {
- "[[scope::]][[ident]]^",
- "[[]][[]]^",
- "\n[[]][[]]^",
- "[[]][[ab]]^",
- "x.[[]][[ab]]^",
- "x.[[]][[]]^",
- "[[x::]][[ab]]^",
- "[[x::]][[]]^",
- "[[::x::]][[ab]]^",
- "some text [[scope::more::]][[identif]]^ier",
- "some text [[scope::]][[mor]]^e::identifier",
- "weird case foo::[[::bar::]][[baz]]^",
- }) {
+ "[[scope::]][[ident]]^",
+ "[[]][[]]^",
+ "\n[[]][[]]^",
+ "[[]][[ab]]^",
+ "x.[[]][[ab]]^",
+ "x.[[]][[]]^",
+ "[[x::]][[ab]]^",
+ "[[x::]][[]]^",
+ "[[::x::]][[ab]]^",
+ "some text [[scope::more::]][[identif]]^ier",
+ "some text [[scope::]][[mor]]^e::identifier",
+ "weird case foo::[[::bar::]][[baz]]^",
+ }) {
Annotations F(Case);
auto Offset = cantFail(positionToOffset(F.code(), F.point()));
auto ToStringRef = [&](Range R) {
@@ -2440,10 +2444,10 @@ TEST(CompletionTest, CursorInSnippets) {
/*IndexSymbols=*/{}, Options);
// Last placeholder in code patterns should be $0 to put the cursor there.
- EXPECT_THAT(
- Results.Completions,
- Contains(AllOf(Named("while"),
- SnippetSuffix(" (${1:condition}) {\n${0:statements}\n}"))));
+ EXPECT_THAT(Results.Completions,
+ Contains(AllOf(
+ Named("while"),
+ SnippetSuffix(" (${1:condition}) {\n${0:statements}\n}"))));
// However, snippets for functions must *not* end with $0.
EXPECT_THAT(Results.Completions,
Contains(AllOf(Named("while_foo"),
OpenPOWER on IntegriCloud