Commit 339cb434 authored by Roberto Raggi's avatar Roberto Raggi

Removed hidden function declarations from the overloaded function set.

parent 55c69ffe
......@@ -696,27 +696,31 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpression::Result> &results)
{
ConvertToCompletionItem toCompletionItem(this);
Overview o;
o.setShowReturnTypes(true);
o.setShowArgumentNames(true);
QList<Function *> functions;
foreach (const TypeOfExpression::Result &result, results) {
FullySpecifiedType exprTy = result.first;
if (Class *klass = exprTy->asClassType()) {
Name *className = klass->name();
if (! className)
continue; // nothing to do for anonymoous classes.
for (unsigned i = 0; i < klass->memberCount(); ++i) {
Symbol *member = klass->memberAt(i);
if (! member->type()->isFunctionType())
continue;
else if (! member->identity())
continue;
else if (! member->identity()->isEqualTo(klass->identity()))
continue;
if (TextEditor::CompletionItem item = toCompletionItem(member)) {
functions.append(member->type()->asFunctionType());
Name *memberName = member->name();
if (! memberName)
continue; // skip anonymous member.
else if (memberName->isQualifiedNameId())
continue; // skip
if (Function *funTy = member->type()->asFunctionType()) {
if (memberName->isEqualTo(className)) {
// it's a ctor.
functions.append(funTy);
}
}
}
......@@ -725,27 +729,38 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpressi
}
if (functions.isEmpty()) {
QSet<QString> signatures;
foreach (const TypeOfExpression::Result &p, results) {
FullySpecifiedType ty = p.first;
if (Function *fun = ty->asFunctionType()) {
if (TextEditor::CompletionItem item = toCompletionItem(fun)) {
QString signature;
signature += overview.prettyName(fun->name());
signature += overview.prettyType(fun->type());
if (signatures.contains(signature))
continue;
signatures.insert(signature);
functions.append(fun);
if (! fun->name())
continue;
else if (! functions.isEmpty() && functions.first()->scope() != fun->scope())
continue; // skip fun, it's an hidden declaration.
Name *name = fun->name();
if (QualifiedNameId *q = fun->name()->asQualifiedNameId())
name = q->unqualifiedNameId();
bool newOverload = true;
foreach (Function *f, functions) {
if (fun->isEqualTo(f)) {
newOverload = false;
break;
}
}
if (newOverload)
functions.append(fun);
}
}
}
if (! functions.isEmpty()) {
// Recreate if necessary
if (!m_functionArgumentWidget)
m_functionArgumentWidget = new FunctionArgumentWidget;
......
......@@ -187,6 +187,11 @@ bool Function::isEqualTo(const Type *other) const
const Function *o = other->asFunctionType();
if (! o)
return false;
else if (isConst() != o->isConst())
return false;
else if (isVolatile() != o->isVolatile())
return false;
Name *l = identity();
Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r))) {
......
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