forked from qt-creator/qt-creator
C++: Support pretty printing of template enclosing scope
Change-Id: Ib228184e1259585eeac61b9196195c39a9550cb9 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
e919746808
commit
e7eac98c7e
@@ -84,6 +84,7 @@ Overview::Overview()
|
||||
showFunctionSignatures(true),
|
||||
showDefaultArguments(true),
|
||||
showTemplateParameters(false),
|
||||
showEnclosingTemplate(false),
|
||||
includeWhiteSpaceInOperatorName(true),
|
||||
markedArgument(0),
|
||||
markedArgumentBegin(0),
|
||||
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
bool showFunctionSignatures: 1;
|
||||
bool showDefaultArguments: 1;
|
||||
bool showTemplateParameters: 1;
|
||||
bool showEnclosingTemplate: 1;
|
||||
bool includeWhiteSpaceInOperatorName: 1; /// "operator =()" vs "operator=()"
|
||||
|
||||
unsigned markedArgument;
|
||||
|
||||
@@ -166,12 +166,13 @@ void TypePrettyPrinter::visit(Namespace *type)
|
||||
void TypePrettyPrinter::visit(Template *type)
|
||||
{
|
||||
if (Symbol *d = type->declaration()) {
|
||||
if (overview()->showTemplateParameters && ! _name.isEmpty()) {
|
||||
const Overview &oo = *overview();
|
||||
if (oo.showTemplateParameters && ! _name.isEmpty()) {
|
||||
_name += QLatin1Char('<');
|
||||
for (unsigned index = 0; index < type->templateParameterCount(); ++index) {
|
||||
if (index)
|
||||
_name += QLatin1String(", ");
|
||||
QString arg = overview()->prettyName(type->templateParameterAt(index)->name());
|
||||
QString arg = oo.prettyName(type->templateParameterAt(index)->name());
|
||||
if (arg.isEmpty()) {
|
||||
arg += QLatin1Char('T');
|
||||
arg += QString::number(index + 1);
|
||||
@@ -181,6 +182,23 @@ void TypePrettyPrinter::visit(Template *type)
|
||||
_name += QLatin1Char('>');
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user