From f1e6f5713caac5da97dcde34a7042061bb0e6afa Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sat, 15 Jun 2019 02:26:47 +0000 Subject: [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 --- .../clangd/unittests/CodeCompleteTests.cpp | 44 ++++++++++++---------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp') 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 memIndex(std::vector 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) const override {} + void relations(const RelationsRequest &, + llvm::function_ref) + 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"), -- cgit v1.2.3