diff options
author | Orgad Shaneh <[email protected]> | 2016-07-31 23:54:05 +0300 |
---|---|---|
committer | Orgad Shaneh <[email protected]> | 2016-08-19 13:34:44 +0000 |
commit | e7eac98c7eb9217926a8d21a9a13616fc5f07914 (patch) | |
tree | 8b9dc3eb8b25eb1d3e8cef58c5b5ed49bb5f2cd6 /src/libs/cplusplus | |
parent | e9197468083e98392f11ee51100734243a435f91 (diff) |
C++: Support pretty printing of template enclosing scope
Change-Id: Ib228184e1259585eeac61b9196195c39a9550cb9
Reviewed-by: Nikolai Kosjar <[email protected]>
Diffstat (limited to 'src/libs/cplusplus')
-rw-r--r-- | src/libs/cplusplus/Overview.cpp | 1 | ||||
-rw-r--r-- | src/libs/cplusplus/Overview.h | 1 | ||||
-rw-r--r-- | src/libs/cplusplus/TypePrettyPrinter.cpp | 22 |
3 files changed, 22 insertions, 2 deletions
diff --git a/src/libs/cplusplus/Overview.cpp b/src/libs/cplusplus/Overview.cpp index b43d5e829bf..7303791b06d 100644 --- a/src/libs/cplusplus/Overview.cpp +++ b/src/libs/cplusplus/Overview.cpp @@ -84,6 +84,7 @@ Overview::Overview() showFunctionSignatures(true), showDefaultArguments(true), showTemplateParameters(false), + showEnclosingTemplate(false), includeWhiteSpaceInOperatorName(true), markedArgument(0), markedArgumentBegin(0), diff --git a/src/libs/cplusplus/Overview.h b/src/libs/cplusplus/Overview.h index 612ea79662c..eeef87212e4 100644 --- a/src/libs/cplusplus/Overview.h +++ b/src/libs/cplusplus/Overview.h @@ -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; diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index e3693f17a05..4b2d92d37e6 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); } |