Commit 87de1533 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

CppEditor: Use explicit Functions for overrides list

Change-Id: Icb6c8ece3ba64d35dcd1a695cf400546f3254921
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 9f06081a
......@@ -126,7 +126,7 @@ public:
hintItem->setOrder(-1000);
QList<BasicProposalItem *> items;
items << itemFromSymbol(maybeDefinitionFor(m_params.function));
items << itemFromFunction(maybeDefinitionFor(m_params.function));
items << hintItem;
return new VirtualFunctionProposal(m_params.cursorPosition,
new BasicProposalItemListModel(items),
......@@ -144,14 +144,14 @@ public:
if (!functionsClass)
return 0;
const QList<Symbol *> overrides = FunctionUtils::overrides(
const QList<Function *> overrides = FunctionUtils::overrides(
m_params.function, functionsClass, m_params.staticClass, m_params.snapshot);
if (overrides.isEmpty())
return 0;
QList<BasicProposalItem *> items;
foreach (Symbol *symbol, overrides)
items << itemFromSymbol(maybeDefinitionFor(symbol));
foreach (Function *func, overrides)
items << itemFromFunction(maybeDefinitionFor(func));
items.first()->setOrder(1000); // Ensure top position for function of static type
return new VirtualFunctionProposal(m_params.cursorPosition,
......@@ -160,21 +160,21 @@ public:
}
private:
Symbol *maybeDefinitionFor(Symbol *symbol)
Function *maybeDefinitionFor(Function *func)
{
if (Function *definition = m_finder.findMatchingDefinition(symbol, m_params.snapshot))
if (Function *definition = m_finder.findMatchingDefinition(func, m_params.snapshot))
return definition;
return symbol;
return func;
}
BasicProposalItem *itemFromSymbol(Symbol *symbol) const
BasicProposalItem *itemFromFunction(Function *func) const
{
const QString text = m_overview.prettyName(LookupContext::fullyQualifiedName(symbol));
const CPPEditorWidget::Link link = CPPEditorWidget::linkToSymbol(symbol);
const QString text = m_overview.prettyName(LookupContext::fullyQualifiedName(func));
const CPPEditorWidget::Link link = CPPEditorWidget::linkToSymbol(func);
BasicProposalItem *item = new VirtualFunctionProposalItem(link, m_params.openInNextSplit);
item->setText(text);
item->setIcon(m_icons.iconForSymbol(symbol));
item->setIcon(m_icons.iconForSymbol(func));
return item;
}
......
......@@ -110,10 +110,10 @@ bool FunctionUtils::isPureVirtualFunction(const Function *function,
return isVirtualFunction_helper(function, context, PureVirtual, firstVirtual);
}
QList<Symbol *> FunctionUtils::overrides(Function *function, Class *functionsClass,
Class *staticClass, const Snapshot &snapshot)
QList<Function *> FunctionUtils::overrides(Function *function, Class *functionsClass,
Class *staticClass, const Snapshot &snapshot)
{
QList<Symbol *> result;
QList<Function *> result;
QTC_ASSERT(function && functionsClass && staticClass, return result);
FullySpecifiedType referenceType = function->type();
......@@ -145,12 +145,12 @@ QList<Symbol *> FunctionUtils::overrides(Function *function, Class *functionsCla
for (int i = 0, total = c->memberCount(); i < total; ++i) {
Symbol *candidate = c->memberAt(i);
const Name *candidateName = candidate->name();
const Function *candidateFunc = candidate->type()->asFunctionType();
Function *candidateFunc = candidate->type()->asFunctionType();
if (!candidateName || !candidateFunc)
continue;
if (candidateName->isEqualTo(referenceName)
&& candidateFunc->isSignatureEqualTo(function)) {
result << candidate;
result << candidateFunc;
}
}
}
......
......@@ -57,10 +57,10 @@ public:
const CPlusPlus::LookupContext &context,
const CPlusPlus::Function **firstVirtual = 0);
static QList<CPlusPlus::Symbol *> overrides(CPlusPlus::Function *function,
CPlusPlus::Class *functionsClass,
CPlusPlus::Class *staticClass,
const CPlusPlus::Snapshot &snapshot);
static QList<CPlusPlus::Function *> overrides(CPlusPlus::Function *function,
CPlusPlus::Class *functionsClass,
CPlusPlus::Class *staticClass,
const CPlusPlus::Snapshot &snapshot);
};
} // namespace CppTools
......
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