CppEditor: Let user decide whether to use "auto"

... in "Assign to Local Variable" quickfix.

Fixes: QTCREATORBUG-28099
Change-Id: I3640ef3d1e069bb2cac4d78f0ae60726b131c4fe
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2022-09-19 16:14:07 +02:00
parent a8397c129f
commit 0f7a539262
6 changed files with 27 additions and 2 deletions

View File

@@ -1614,8 +1614,10 @@ private:
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
Overview oo = CppCodeStyleSettings::currentProjectCodeStyleOverview();
const auto settings = CppQuickFixProjectsSettings::getQuickFixSettings(
ProjectExplorer::ProjectTree::currentProject());
if (currentFile->cppDocument()->languageFeatures().cxx11Enabled)
if (currentFile->cppDocument()->languageFeatures().cxx11Enabled && settings->useAuto)
return "auto " + oo.prettyName(simpleNameAST->name);
TypeOfExpression typeOfExpression;
@@ -6764,7 +6766,9 @@ private:
QString deduceType() const
{
if (m_file->cppDocument()->languageFeatures().cxx11Enabled)
const auto settings = CppQuickFixProjectsSettings::getQuickFixSettings(
ProjectExplorer::ProjectTree::currentProject());
if (m_file->cppDocument()->languageFeatures().cxx11Enabled && settings->useAuto)
return "auto " + m_originalName;
TypeOfExpression typeOfExpression;