Clang: Add sorting by priority

The priority is adjusted too provide a better completion list.

Change-Id: I1ebed1996f660046843e0c5249a91e8c2b1eeb88
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-07-07 13:09:04 +02:00
parent dd89d731cf
commit eb5afed10f
4 changed files with 67 additions and 0 deletions

View File

@@ -32,6 +32,10 @@
#include "clangassistproposalmodel.h"
#include <texteditor/codeassist/assistproposalitem.h>
#include <algorithm>
namespace ClangCodeModel {
namespace Internal {
@@ -56,6 +60,19 @@ bool ClangAssistProposalModel::isSortable(const QString &/*prefix*/) const
return true;
}
void ClangAssistProposalModel::sort(const QString &/*prefix*/)
{
using TextEditor::AssistProposalItem;
auto currentItemsCompare = [](AssistProposalItem *first, AssistProposalItem *second) {
return (first->order() > 0
&& (first->order() < second->order()
|| (first->order() == second->order() && first->text() < second->text())));
};
std::sort(m_currentItems.begin(), m_currentItems.end(), currentItemsCompare);
}
} // namespace Internal
} // namespace ClangCodeModel