[PATCH] D79106: [clangd] Move inserted include from detail -> documentation.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 11:16:42 PDT 2020


sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Many clients try to display all the detail inline, with poor results.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79106

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1660,8 +1660,8 @@
   EXPECT_EQ(R.insertText, "Foo::x");
   EXPECT_EQ(R.insertTextFormat, InsertTextFormat::PlainText);
   EXPECT_EQ(R.filterText, "x");
-  EXPECT_EQ(R.detail, "int\n\"foo.h\"");
-  EXPECT_EQ(R.documentation, "This is x().");
+  EXPECT_EQ(R.detail, "int");
+  EXPECT_EQ(R.documentation, "#include \"foo.h\"\nThis is x().");
   EXPECT_THAT(R.additionalTextEdits, IsEmpty());
   EXPECT_EQ(R.sortText, sortText(1.0, "x"));
   EXPECT_FALSE(R.deprecated);
@@ -1683,7 +1683,8 @@
 
   C.BundleSize = 2;
   R = C.render(Opts);
-  EXPECT_EQ(R.detail, "[2 overloads]\n\"foo.h\"");
+  EXPECT_EQ(R.detail, "[2 overloads]");
+  EXPECT_EQ(R.documentation, "#include \"foo.h\"\nThis is x().");
 
   C.Deprecated = true;
   R = C.render(Opts);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===================================================================
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1831,8 +1831,12 @@
                    : ReturnType;
   LSP.deprecated = Deprecated;
   if (InsertInclude)
-    LSP.detail += "\n" + InsertInclude->Header;
-  LSP.documentation = Documentation;
+    LSP.documentation = llvm::formatv("#include {0}", InsertInclude->Header);
+  if (!Documentation.empty()) {
+    if (!LSP.documentation.empty())
+      LSP.documentation += "\n";
+    LSP.documentation += Documentation;
+  }
   LSP.sortText = sortText(Score.Total, Name);
   LSP.filterText = Name;
   LSP.textEdit = {CompletionTokenRange, RequiredQualifier + Name};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79106.260962.patch
Type: text/x-patch
Size: 1778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200429/08e8ebbc/attachment.bin>


More information about the cfe-commits mailing list