Commit 9d5705a7 authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

Clang: Stop trying to remove duplicate completion items

We assume that libclang does not return any duplicates, at least we
never noticed any so far. For the concrete test below no duplicates were

Function overloads are not problematic because they are folded into one
ClangAssistProposalItem (addOverload()).

To the completion items from libclang we add the Qt Creator snippets as
items. Those might have the same text in the completion list view, but
their icon is different (e.g. consider the keyword completion "class"
and the Qt Creator snippet "class"), thus the user can still tell them

 1. Open src/plugins/clangstaticanalyzer/unit-tests/
 2. Open main.cpp
 3. Complete in the main function

Measured with a timer in IpcReceiver::codeCompleted.

On Linux, for 20637 completion items:
 Before: 74ms (avg)
    Now: 66ms (avg)
   Gain: 11%

Change-Id: I524eaa09f8d9e07c78dc9efcc77f7e021c6f37f7
Reviewed-by: Tim Jenssen's avatarTim Jenssen <>
parent ead6853b
......@@ -40,6 +40,11 @@ ClangAssistProposalModel::ClangAssistProposalModel(
bool ClangAssistProposalModel::containsDuplicates() const
return false;
bool ClangAssistProposalModel::isSortable(const QString &/*prefix*/) const
return true;
......@@ -39,6 +39,8 @@ class ClangAssistProposalModel : public TextEditor::GenericProposalModel
ClangAssistProposalModel(ClangBackEnd::CompletionCorrection neededCorrection);
bool containsDuplicates() const override;
bool isSortable(const QString &prefix) const override;
void sort(const QString &prefix) override;
......@@ -170,7 +170,6 @@ QString GenericProposalModel::detail(int index) const
// make it optional because it is not needed in many cases
void GenericProposalModel::removeDuplicates()
QHash<QString, quint64> unique;
......@@ -272,6 +271,11 @@ int GenericProposalModel::persistentId(int index) const
return m_idByText.value(>text());
bool GenericProposalModel::containsDuplicates() const
return true;
bool GenericProposalModel::supportsPrefixExpansion() const
return true;
......@@ -53,6 +53,7 @@ public:
virtual QIcon icon(int index) const;
virtual QString detail(int index) const;
virtual int persistentId(int index) const;
virtual bool containsDuplicates() const;
virtual void removeDuplicates();
virtual void filter(const QString &prefix);
virtual bool isSortable(const QString &prefix) const;
......@@ -407,7 +407,8 @@ void GenericProposalWidget::setIsSynchronized(bool isSync)
void GenericProposalWidget::showProposal(const QString &prefix)
if (d->m_model->containsDuplicates())
if (!updateAndCheck(prefix))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment