aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/cplusplus/TypePrettyPrinter.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2016-07-31 23:54:05 +0300
committerOrgad Shaneh <orgads@gmail.com>2016-08-19 13:34:44 +0000
commite7eac98c7eb9217926a8d21a9a13616fc5f07914 (patch)
tree8b9dc3eb8b25eb1d3e8cef58c5b5ed49bb5f2cd6 /src/libs/cplusplus/TypePrettyPrinter.cpp
parente9197468083e98392f11ee51100734243a435f91 (diff)
C++: Support pretty printing of template enclosing scope
Change-Id: Ib228184e1259585eeac61b9196195c39a9550cb9 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/libs/cplusplus/TypePrettyPrinter.cpp')
-rw-r--r--src/libs/cplusplus/TypePrettyPrinter.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp
index e3693f17a0..4b2d92d37e 100644
--- a/src/libs/cplusplus/TypePrettyPrinter.cpp
+++ b/src/libs/cplusplus/TypePrettyPrinter.cpp
@@ -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);
}