forked from qt-creator/qt-creator
CppEditor: Use trailing return type when moving function definition
... if the original definition also used a trailing return type. Task-number: QTCREATORBUG-27132 Change-Id: Iaeeeac08601f1d931aabe12be9f89ca0240d97a2 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -86,6 +86,7 @@ Overview::Overview()
|
||||
showTemplateParameters(false),
|
||||
showEnclosingTemplate(false),
|
||||
includeWhiteSpaceInOperatorName(true),
|
||||
trailingReturnType(false),
|
||||
markedArgument(0),
|
||||
markedArgumentBegin(0),
|
||||
markedArgumentEnd(0)
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
bool showTemplateParameters: 1;
|
||||
bool showEnclosingTemplate: 1;
|
||||
bool includeWhiteSpaceInOperatorName: 1; /// "operator =()" vs "operator=()"
|
||||
bool trailingReturnType: 1;
|
||||
|
||||
int markedArgument;
|
||||
int markedArgumentBegin;
|
||||
|
||||
@@ -435,11 +435,17 @@ void TypePrettyPrinter::visit(Function *type)
|
||||
retAndArgOverview.showTemplateParameters = true;
|
||||
|
||||
if (_overview->showReturnTypes) {
|
||||
const QString returnType = retAndArgOverview.prettyType(type->returnType());
|
||||
if (!returnType.isEmpty()) {
|
||||
if (!endsWithPtrOrRef(returnType) || !(_overview->starBindFlags & Overview::BindToIdentifier))
|
||||
_text.prepend(QLatin1Char(' '));
|
||||
_text.prepend(returnType);
|
||||
if (_overview->trailingReturnType) {
|
||||
_text.prepend("auto ");
|
||||
} else {
|
||||
const QString returnType = retAndArgOverview.prettyType(type->returnType());
|
||||
if (!returnType.isEmpty()) {
|
||||
if (!endsWithPtrOrRef(returnType)
|
||||
|| !(_overview->starBindFlags & Overview::BindToIdentifier)) {
|
||||
_text.prepend(QLatin1Char(' '));
|
||||
}
|
||||
_text.prepend(returnType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,6 +535,12 @@ void TypePrettyPrinter::visit(Function *type)
|
||||
_text += QLatin1String(spec->chars());
|
||||
}
|
||||
}
|
||||
|
||||
if (_overview->showReturnTypes && _overview->trailingReturnType) {
|
||||
const QString returnType = retAndArgOverview.prettyType(type->returnType());
|
||||
if (!returnType.isEmpty())
|
||||
_text.append(" -> ").append(returnType);
|
||||
}
|
||||
}
|
||||
|
||||
void TypePrettyPrinter::appendSpace()
|
||||
|
||||
Reference in New Issue
Block a user