Commit 64d8ac48 authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by Marco Bubke

Clang: Fix showing signature tooltips for functions

...and others in the generic completion widget.

Task-number: QTCREATORBUG-14874
Change-Id: I75122eaf364d740b0a64ca514b31a26c5c8ea673
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent c4fe977e
......@@ -100,10 +100,7 @@ QList<AssistProposalItem *> toAssistProposalItems(const CodeCompletions &complet
items.insert(name, item);
item->setText(name);
item->setOrder(ccr.priority());
if (ccr.completionKind() == CodeCompletion::KeywordCompletionKind)
item->setDetail(CompletionChunksToTextConverter::convertToToolTip(ccr.chunks()));
item->setDetail(CompletionChunksToTextConverter::convertToToolTip(ccr.chunks()));
item->setCodeCompletion(ccr);
}
......
......@@ -623,15 +623,33 @@ public:
ProposalModel proposal;
};
bool hasItem(ProposalModel model, const QByteArray &text)
int indexOfItemWithText(ProposalModel model, const QByteArray &text)
{
if (!model)
return false;
return -1;
for (int i = 0, size = model->size(); i < size; ++i) {
const QString itemText = model->text(i);
if (itemText == QString::fromUtf8(text))
return true;
return i;
}
return -1;
}
bool hasItem(ProposalModel model, const QByteArray &text)
{
return indexOfItemWithText(model, text) != -1;
}
bool hasItem(ProposalModel model, const QByteArray &text, const QByteArray &detail)
{
const int index = indexOfItemWithText(model, text);
if (index != -1 && index < model->size()) {
TextEditor::IAssistProposalModel *imodel = model.data();
const auto genericModel = static_cast<TextEditor::GenericProposalModel *>(imodel);
const auto itemDetail = genericModel->detail(index);
return itemDetail == QString::fromUtf8(detail);
}
return false;
......@@ -844,10 +862,10 @@ void ClangCodeCompletionTest::testCompleteGlobals()
{
ProjectLessCompletionTest t("globalCompletion.cpp");
QVERIFY(hasItem(t.proposal, "globalVariable"));
QVERIFY(hasItem(t.proposal, "globalFunction"));
QVERIFY(hasItem(t.proposal, "GlobalClass"));
QVERIFY(hasItem(t.proposal, "class")); // Keyword
QVERIFY(hasItem(t.proposal, "globalVariable", "int globalVariable"));
QVERIFY(hasItem(t.proposal, "globalFunction", "void globalFunction ()"));
QVERIFY(hasItem(t.proposal, "GlobalClass", "GlobalClass"));
QVERIFY(hasItem(t.proposal, "class", "class")); // Keyword
QVERIFY(hasSnippet(t.proposal, "class")); // Snippet
}
......
Markdown is supported
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