[clang-tools-extra] r350720 - [clangd] Add a test for SignatureHelp on dynamic index.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 9 05:42:03 PST 2019


Author: hokein
Date: Wed Jan  9 05:42:03 2019
New Revision: 350720

URL: http://llvm.org/viewvc/llvm-project?rev=350720&view=rev
Log:
[clangd] Add a test for SignatureHelp on dynamic index.

Summary: This would catch regressions caused by future changes of the index.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56483

Modified:
    clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=350720&r1=350719&r2=350720&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Wed Jan  9 05:42:03 2019
@@ -1793,6 +1793,37 @@ TEST(SignatureHelpTest, IndexDocumentati
                         SigDoc("Doc from sema"))));
 }
 
+TEST(SignatureHelpTest, DynamicIndexDocumentation) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer::Options Opts = ClangdServer::optsForTest();
+  Opts.BuildDynamicSymbolIndex = true;
+  ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+
+  FS.Files[testPath("foo.h")] = R"cpp(
+    struct Foo {
+       // Member doc
+       int foo();
+    };
+  )cpp";
+  Annotations FileContent(R"cpp(
+    #include "foo.h"
+    void test() {
+      Foo f;
+      f.foo(^);
+    }
+  )cpp");
+  auto File = testPath("test.cpp");
+  Server.addDocument(File, FileContent.code());
+  // Wait for the dynamic index being built.
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(
+      llvm::cantFail(runSignatureHelp(Server, File, FileContent.point()))
+          .signatures,
+      ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Member doc"))));
+}
+
 TEST(CompletionTest, CompletionFunctionArgsDisabled) {
   CodeCompleteOptions Opts;
   Opts.EnableSnippets = true;




More information about the cfe-commits mailing list