Commit be1cde6e authored by Roberto Raggi's avatar Roberto Raggi

Pretty print templates.

parent a14016bf
......@@ -44,7 +44,8 @@ Overview::Overview()
_showArgumentNames(false),
_showReturnTypes(false),
_showFunctionSignatures(true),
_showDefaultArguments(true)
_showDefaultArguments(true),
_showTemplateParameters(false)
{ }
Overview::~Overview()
......@@ -120,6 +121,16 @@ void Overview::setShowDefaultArguments(bool showDefaultArguments)
_showDefaultArguments = showDefaultArguments;
}
bool Overview::showTemplateParameters() const
{
return _showTemplateParameters;
}
void Overview::setShowTemplateParameters(bool showTemplateParameters)
{
_showTemplateParameters = showTemplateParameters;
}
QString Overview::prettyName(const Name *name) const
{
NamePrettyPrinter pp(this);
......
......@@ -56,6 +56,9 @@ public:
bool showDefaultArguments() const;
void setShowDefaultArguments(bool showDefaultArguments);
bool showTemplateParameters() const;
void setShowTemplateParameters(bool showTemplateParameters);
// argument index that you want to mark
unsigned markedArgument() const;
void setMarkedArgument(unsigned position);
......@@ -88,6 +91,7 @@ private:
bool _showReturnTypes: 1;
bool _showFunctionSignatures: 1;
bool _showDefaultArguments: 1;
bool _showTemplateParameters: 1;
};
} // end of namespace CPlusPlus
......
......@@ -142,23 +142,23 @@ void TypePrettyPrinter::visit(Namespace *type)
void TypePrettyPrinter::visit(Template *type)
{
const unsigned argc = type->templateParameterCount();
QString decl;
decl += QLatin1String("template <");
for (unsigned i = 0; i < argc; ++i) {
if (i != 0)
decl += QLatin1String(", ");
decl += QLatin1String("T");
decl += QString::number(i + 1);
}
decl += QLatin1Char('<');
if (Symbol *d = type->declaration()) {
decl += QLatin1Char(' ');
decl += overview()->prettyType(d->type(), d->name());
if (overview()->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());
if (arg.isEmpty()) {
arg += QLatin1Char('T');
arg += QString::number(index + 1);
}
_name += arg;
}
_name += QLatin1Char('>');
}
acceptType(d->type());
}
_text.prepend(decl);
qWarning() << "here:" << decl;
prependCv(_fullySpecifiedType);
}
......
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