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};
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};
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits