forked from qt-creator/qt-creator
Clang: Do not replace class completion with constructor completion
Both completion kinds have the same name. Do not merge them together when looking for constructor overloads. Task-number: QTCREATORBUG-21010 Change-Id: I4c851033d63ad4e242b6179491f1fba00af466f6 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -361,6 +361,20 @@ bool hasItem(TextEditor::ProposalModelPtr model, const QByteArray &text)
|
||||
return indexOfItemWithText(model, text) != -1;
|
||||
}
|
||||
|
||||
int itemsWithText(TextEditor::ProposalModelPtr model, const QByteArray &text)
|
||||
{
|
||||
if (!model)
|
||||
return 0;
|
||||
|
||||
int amount = 0;
|
||||
for (int i = 0, size = model->size(); i < size; ++i) {
|
||||
if (model->text(i) == QString::fromUtf8(text))
|
||||
++amount;
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
bool hasItem(TextEditor::ProposalModelPtr model, const QByteArray &text, const QByteArray &detail)
|
||||
{
|
||||
const int index = indexOfItemWithText(model, text);
|
||||
@@ -571,6 +585,13 @@ void ClangCodeCompletionTest::testCompleteConstructor()
|
||||
QVERIFY(hasItem(t.proposal, "Foo(int, double)"));
|
||||
}
|
||||
|
||||
void ClangCodeCompletionTest::testCompleteClassAndConstructor()
|
||||
{
|
||||
ProjectLessCompletionTest t("classAndConstructorCompletion.cpp");
|
||||
|
||||
QCOMPARE(itemsWithText(t.proposal, "Foo"), 2);
|
||||
}
|
||||
|
||||
// Explicitly Inserting The Dot
|
||||
// ----------------------------
|
||||
// Inserting the dot for is important since it will send the editor
|
||||
@@ -582,7 +603,7 @@ void ClangCodeCompletionTest::testCompleteWithDotToArrowCorrection()
|
||||
ProjectLessCompletionTest t("dotToArrowCorrection.cpp",
|
||||
QStringLiteral(".")); // See above "Explicitly Inserting The Dot"
|
||||
|
||||
QVERIFY(hasItem(t.proposal, "member"));
|
||||
QVERIFY(hasItem(t.proposal, "member (requires to correct [4:8-4:9] to \"->\")"));
|
||||
}
|
||||
|
||||
void ClangCodeCompletionTest::testDontCompleteWithDotToArrowCorrectionForFloats()
|
||||
|
||||
Reference in New Issue
Block a user