forked from qt-creator/qt-creator
C++: Enable showEnclosingTemplate also for function type
Do not require directly passing the enclosing template. Change-Id: Ie03bc58338fe003677a5f5311d86d70f499373ee Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
50a6c47830
commit
39aff55d8a
@@ -182,23 +182,6 @@ void TypePrettyPrinter::visit(Template *type)
|
|||||||
_name += QLatin1Char('>');
|
_name += QLatin1Char('>');
|
||||||
}
|
}
|
||||||
acceptType(d->type());
|
acceptType(d->type());
|
||||||
if (oo.showEnclosingTemplate) {
|
|
||||||
QString templateScope = "template<";
|
|
||||||
for (unsigned i = 0, total = type->templateParameterCount(); i < total; ++i) {
|
|
||||||
if (Symbol *param = type->templateParameterAt(i)) {
|
|
||||||
if (i > 0)
|
|
||||||
templateScope.append(", ");
|
|
||||||
if (TypenameArgument *typenameArg = param->asTypenameArgument()) {
|
|
||||||
templateScope.append(QLatin1String(typenameArg->isClassDeclarator()
|
|
||||||
? "class " : "typename "));
|
|
||||||
templateScope.append(oo(typenameArg->name()));
|
|
||||||
} else if (Argument *arg = param->asArgument()) {
|
|
||||||
templateScope.append(operator()(arg->type(), oo(arg->name())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_text.prepend(templateScope + ">\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
prependCv(_fullySpecifiedType);
|
prependCv(_fullySpecifiedType);
|
||||||
}
|
}
|
||||||
@@ -424,6 +407,27 @@ void TypePrettyPrinter::visit(Function *type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_overview->showEnclosingTemplate) {
|
||||||
|
if (Template *templ = type->enclosingTemplate()) {
|
||||||
|
QString templateScope = "template<";
|
||||||
|
for (unsigned i = 0, total = templ->templateParameterCount(); i < total; ++i) {
|
||||||
|
if (Symbol *param = templ->templateParameterAt(i)) {
|
||||||
|
if (i > 0)
|
||||||
|
templateScope.append(", ");
|
||||||
|
if (TypenameArgument *typenameArg = param->asTypenameArgument()) {
|
||||||
|
templateScope.append(QLatin1String(typenameArg->isClassDeclarator()
|
||||||
|
? "class " : "typename "));
|
||||||
|
templateScope.append(_overview->prettyName(typenameArg->name()));
|
||||||
|
} else if (Argument *arg = param->asArgument()) {
|
||||||
|
templateScope.append(operator()(arg->type(),
|
||||||
|
_overview->prettyName(arg->name())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_text.prepend(templateScope + ">\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_overview->showFunctionSignatures) {
|
if (_overview->showFunctionSignatures) {
|
||||||
Overview argumentText;
|
Overview argumentText;
|
||||||
argumentText.starBindFlags = _overview->starBindFlags;
|
argumentText.starBindFlags = _overview->starBindFlags;
|
||||||
|
|||||||
@@ -2510,13 +2510,8 @@ QString InsertDeclOperation::generateDeclaration(const Function *function)
|
|||||||
oo.showArgumentNames = true;
|
oo.showArgumentNames = true;
|
||||||
oo.showEnclosingTemplate = true;
|
oo.showEnclosingTemplate = true;
|
||||||
|
|
||||||
const Symbol *symbol = function;
|
|
||||||
if (const Scope *enclosingScope = function->enclosingScope()) {
|
|
||||||
if (const Template *templ = enclosingScope->asTemplate())
|
|
||||||
symbol = templ;
|
|
||||||
}
|
|
||||||
QString decl;
|
QString decl;
|
||||||
decl += oo.prettyType(symbol->type(), function->unqualifiedName());
|
decl += oo.prettyType(function->type(), function->unqualifiedName());
|
||||||
decl += QLatin1String(";\n");
|
decl += QLatin1String(";\n");
|
||||||
|
|
||||||
return decl;
|
return decl;
|
||||||
|
|||||||
@@ -107,11 +107,13 @@ static FullySpecifiedType fnTy(const QString &name, const FullySpecifiedType &re
|
|||||||
return FullySpecifiedType(fn);
|
return FullySpecifiedType(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FullySpecifiedType templTy(const FullySpecifiedType &declTy, bool isClassDeclarator)
|
static FullySpecifiedType templTy(FullySpecifiedType declTy, bool isClassDeclarator)
|
||||||
{
|
{
|
||||||
Template *templ = new Template(0, 0, nameId(""));
|
Template *templ = new Template(0, 0, nameId(""));
|
||||||
templ->addMember(typenameArg("T", isClassDeclarator));
|
templ->addMember(typenameArg("T", isClassDeclarator));
|
||||||
templ->addMember(decl(declTy));
|
templ->addMember(decl(declTy));
|
||||||
|
if (Function *func = declTy->asFunctionType())
|
||||||
|
func->setEnclosingScope(templ);
|
||||||
return FullySpecifiedType(templ);
|
return FullySpecifiedType(templ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user