Commit 03575317 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

CppEditor: Add "= 0" for pure virtual functions in override popup

Change-Id: If1887424f240eba750aeb13d52a101c00904f71b
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 5a909111
......@@ -126,7 +126,7 @@ public:
hintItem->setOrder(-1000);
QList<BasicProposalItem *> items;
items << itemFromFunction(maybeDefinitionFor(m_params.function));
items << itemFromFunction(m_params.function);
items << hintItem;
return new VirtualFunctionProposal(m_params.cursorPosition,
new BasicProposalItemListModel(items),
......@@ -151,7 +151,7 @@ public:
QList<BasicProposalItem *> items;
foreach (Function *func, overrides)
items << itemFromFunction(maybeDefinitionFor(func));
items << itemFromFunction(func);
items.first()->setOrder(1000); // Ensure top position for function of static type
return new VirtualFunctionProposal(m_params.cursorPosition,
......@@ -160,7 +160,7 @@ public:
}
private:
Function *maybeDefinitionFor(Function *func)
Function *maybeDefinitionFor(Function *func) const
{
if (Function *definition = m_finder.findMatchingDefinition(func, m_params.snapshot))
return definition;
......@@ -169,8 +169,10 @@ private:
BasicProposalItem *itemFromFunction(Function *func) const
{
const QString text = m_overview.prettyName(LookupContext::fullyQualifiedName(func));
const CPPEditorWidget::Link link = CPPEditorWidget::linkToSymbol(func);
const CPPEditorWidget::Link link = CPPEditorWidget::linkToSymbol(maybeDefinitionFor(func));
QString text = m_overview.prettyName(LookupContext::fullyQualifiedName(func));
if (func->isPureVirtual())
text += QLatin1String(" = 0");
BasicProposalItem *item = new VirtualFunctionProposalItem(link, m_params.openInNextSplit);
item->setText(text);
......@@ -182,7 +184,7 @@ private:
VirtualFunctionAssistProvider::Parameters m_params;
Overview m_overview;
Icons m_icons;
CppTools::SymbolFinder m_finder;
mutable CppTools::SymbolFinder m_finder;
};
VirtualFunctionAssistProvider::VirtualFunctionAssistProvider()
......
......@@ -1040,7 +1040,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
"int f(A *o) { o->$@virt(); }\n"
"}\n")
<< (OverrideItemList()
<< OverrideItem(QLatin1String("A::virt"), 2)
<< OverrideItem(QLatin1String("A::virt = 0"), 2)
<< OverrideItem(QLatin1String("B::virt"), 5)
<< OverrideItem(QLatin1String("C::virt"), 8)
<< OverrideItem(QLatin1String("CD1::virt"), 11)
......@@ -1110,7 +1110,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
"\n"
"int f(C *o) { o->$@virt(); }\n")
<< (OverrideItemList()
<< OverrideItem(QLatin1String("C::virt"), 2)
<< OverrideItem(QLatin1String("C::virt = 0"), 2)
<< OverrideItem(QLatin1String("A::virt"), 8)
<< OverrideItem(QLatin1String("B::virt"), 5));
......@@ -1194,7 +1194,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
"\n"
"void client(A &o) { o.$@virt(); }\n")
<< (OverrideItemList()
<< OverrideItem(QLatin1String("A::virt"), 2));
<< OverrideItem(QLatin1String("A::virt = 0"), 2));
/// Check: Do not trigger on a.virt() if a is of type A.
QTest::newRow("notOnDotMemberAccessOfNonReferenceType") << _(
......@@ -1312,7 +1312,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_multipleD
;
const OverrideItemList finalResults = OverrideItemList()
<< OverrideItem(QLatin1String("A::virt"), 1)
<< OverrideItem(QLatin1String("A::virt = 0"), 1)
<< OverrideItem(QLatin1String("B::virt"), 2);
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, testFiles, finalResults);
......
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