summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/CodeComplete.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-01-10 13:51:09 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-01-10 13:51:09 +0000
commitf60bf347c9769eda92fae02fbc06b5f31e70ffd9 (patch)
treeef4b60044238d76873b4b5c5c38b45adf145113d /clang-tools-extra/clangd/CodeComplete.cpp
parent400c7b3c7aa5486695dbacad609bb2fb2f4d4436 (diff)
downloadbcm5719-llvm-f60bf347c9769eda92fae02fbc06b5f31e70ffd9.tar.gz
bcm5719-llvm-f60bf347c9769eda92fae02fbc06b5f31e70ffd9.zip
[clangd] Remove duplicates from code completion
Summary: This patch removes hidden items from code completion. Items can be hidden, e.g., by other items in the child scopes. This patch addresses a particular problem of a duplicate completion item for the class in the following example: struct Adapter { void method(); }; void Adapter::method() { Adapter^ } We should probably investigate if there are other duplicates in completion and remove them, possibly adding assertions that it never happens. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D41901 llvm-svn: 322185
Diffstat (limited to 'clang-tools-extra/clangd/CodeComplete.cpp')
-rw-r--r--clang-tools-extra/clangd/CodeComplete.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index ee709021f9c..dc5a85027f9 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -294,6 +294,13 @@ public:
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))
OpenPOWER on IntegriCloud