CppEditor: Prevent showing unwanted function template parameters

Task-number: QTCREATORBUG-28186
Change-Id: Ic52090e873b4defa68cf98e2a5d08f2f0604e714
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2022-11-29 16:32:38 +01:00
parent 524f9e063a
commit 7c0bc1384c
2 changed files with 5 additions and 3 deletions

View File

@@ -361,11 +361,13 @@ static bool endsWithPtrOrRef(const QString &type)
void TypePrettyPrinter::visit(Function *type)
{
if (_overview->showTemplateParameters) {
bool showTemplateParameters = _overview->showTemplateParameters;
QStringList nameParts = _name.split("::");
int i = nameParts.length() - 1;
for (Scope *s = type->enclosingScope(); s && i >= 0; s = s->enclosingScope()) {
if (Template *templ = s->asTemplate()) {
if (s->asClass())
showTemplateParameters = true;
if (Template *templ = s->asTemplate(); templ && showTemplateParameters) {
QString &n = nameParts[i];
const int paramCount = templ->templateParameterCount();
if (paramCount > 0) {
@@ -388,7 +390,6 @@ void TypePrettyPrinter::visit(Function *type)
--i;
}
_name = nameParts.join("::");
}
if (_needsParens) {
_text.prepend(QLatin1Char('('));

View File

@@ -6277,6 +6277,7 @@ QString definitionSignature(const CppQuickFixInterface *assist,
oo.includeWhiteSpaceInOperatorName = operatorNameText.contains(QLatin1Char(' '));
}
const QString nameText = oo.prettyName(LookupContext::minimalName(func, cppCoN, control));
oo.showTemplateParameters = false;
const FullySpecifiedType tn = rewriteType(func->type(), &env, control);
return oo.prettyType(tn, nameText);