From 89ad72c78958bd3706ce9ca6461cec8487bb1441 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 14 Jan 2021 17:12:01 +0100 Subject: [PATCH] CppEditor: Start renaming the new function parameter ... in the ExtractLiteralAsParameter quickfix. It's unlikely that the user wants to keep the generic default name. Fixes: QTCREATORBUG-25104 Change-Id: Ic354f20c27da43664bcb3c2839e981c176aaf821 Reviewed-by: Christian Stenger --- src/plugins/cppeditor/cppquickfixes.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 8ceb9e7d4d2..40d3fdd55cc 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -5821,6 +5821,10 @@ public: } currentFile->setChangeSet(changes); currentFile->apply(); + QTextCursor c = currentFile->cursor(); + c.setPosition(c.position() - parameterName().length()); + editor()->setTextCursor(c); + editor()->renameSymbolUnderCursor(); } private: @@ -5842,6 +5846,8 @@ private: m_typeName = overview.prettyType(items.first().type()); } + static QString parameterName() { return QLatin1String("newParameter"); } + QString parameterDeclarationTextToInsert(FunctionDeclaratorAST *ast) const { QString str; @@ -5850,7 +5856,7 @@ private: str += m_typeName; if (!m_typeName.endsWith(QLatin1Char('*'))) str += QLatin1Char(' '); - str += QLatin1String("newParameter"); + str += parameterName(); return str; }