C++: Fix code completion for nested classes

Fix code completion for nested classes when enclosing is
template class.
Unit tests

Task-number: QTCREATORBUG-8245 (only standalone)
Change-Id: Ib31ad4b799db927b56debd4dc3e7403404c1839d
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Przemyslaw Gorszkowski
2012-12-07 14:31:32 +01:00
committed by hjk
parent 17748280e8
commit b1199ef0cc
8 changed files with 271 additions and 22 deletions

View File

@@ -811,16 +811,17 @@ bool ResolveExpression::visit(MemberAccessAST *ast)
return false;
}
ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &originalTy, Scope *scope) const
ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &originalTy, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation) const
{
FullySpecifiedType ty = originalTy.simplified();
ClassOrNamespace *binding = 0;
if (Class *klass = ty->asClassType())
binding = _context.lookupType(klass);
binding = _context.lookupType(klass, enclosingTemplateInstantiation);
else if (NamedType *namedTy = ty->asNamedType())
binding = _context.lookupType(namedTy->name(), scope);
binding = _context.lookupType(namedTy->name(), scope, enclosingTemplateInstantiation);
else if (Function *funTy = ty->asFunctionType())
return findClass(funTy->returnType(), scope);
@@ -979,7 +980,13 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
}
}
if (ClassOrNamespace *binding = findClass(ty, scope))
ClassOrNamespace *enclosingTemplateInstantiation = 0;
if (ClassOrNamespace *binding = r.binding()) {
if (binding->instantiationOrigin())
enclosingTemplateInstantiation = binding;
}
if (ClassOrNamespace *binding = findClass(ty, scope, enclosingTemplateInstantiation))
return binding;
}
}