[PATCH] D41901: [clangd] Remove duplicates from code completion
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 10 05:52:29 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322185: [clangd] Remove duplicates from code completion (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D41901?vs=129247&id=129264#toc
Repository:
rL LLVM
https://reviews.llvm.org/D41901
Files:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -592,6 +592,22 @@
Doc("Doooc"), Detail("void"))));
}
+TEST(CompletionTest, NoDuplicates) {
+ auto Items = completions(R"cpp(
+struct Adapter {
+ void method();
+};
+
+void Adapter::method() {
+ Adapter^
+}
+ )cpp")
+ .items;
+
+ // Make sure there are no duplicate entries of 'Adapter'.
+ EXPECT_THAT(Items, ElementsAre(Named("Adapter"), Named("~Adapter")));
+}
+
} // namespace
} // namespace clangd
} // namespace clang
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -294,6 +294,13 @@
std::priority_queue<CompletionCandidate> Candidates;
for (unsigned I = 0; I < NumResults; ++I) {
auto &Result = Results[I];
+ // We drop hidden items, as they cannot be found by the lookup after
+ // inserting the corresponding completion item and only produce noise and
+ // duplicates in the completion list. However, there is one exception. If
+ // Result has a Qualifier which is non-informative, we can refer to an
+ // item by adding that qualifier, so we don't filter out this item.
+ if (Result.Hidden && (!Result.Qualifier || Result.QualifierIsInformative))
+ continue;
if (!ClangdOpts.IncludeIneligibleResults &&
(Result.Availability == CXAvailability_NotAvailable ||
Result.Availability == CXAvailability_NotAccessible))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41901.129264.patch
Type: text/x-patch
Size: 1836 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180110/080453a3/attachment-0001.bin>
More information about the cfe-commits
mailing list