Commit 91dec7fe authored by Jochen Becher's avatar Jochen Becher

CppEditor: Minor refactoring quickfix

Change-Id: I978d79f081749cef58ca9be7387892dbca71683c
Reviewed-by: default avatarAndré Hartmann <aha_1980@gmx.de>
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent 1feb5c60
......@@ -2934,8 +2934,6 @@ public:
updateDescriptionAndPriority();
}
void determineGetterSetterNames();
// Clones "other" in order to prevent all the initial detection made in the ctor.
GenerateGetterSetterOperation(const CppQuickFixInterface &interface,
GenerateGetterSetterOperation *other, OperationType type)
......@@ -2968,6 +2966,28 @@ public:
return (m_type == GetterSetterType || m_type == SetterType);
}
void determineGetterSetterNames()
{
m_baseName = memberBaseName(m_variableString);
if (m_baseName.isEmpty())
m_baseName = QLatin1String("value");
// Getter Name
const CppCodeStyleSettings settings = CppCodeStyleSettings::currentProjectCodeStyle();
const bool hasValidBaseName = m_baseName != m_variableString;
const bool getPrefixIsAlreadyUsed = hasClassMemberWithGetPrefix(m_classSpecifier->symbol);
if (settings.preferGetterNameWithoutGetPrefix && hasValidBaseName && !getPrefixIsAlreadyUsed) {
m_getterName = m_baseName;
} else {
const QString baseNameWithCapital = m_baseName.left(1).toUpper() + m_baseName.mid(1);
m_getterName = QLatin1String("get") + baseNameWithCapital;
}
// Setter Name
const QString baseNameWithCapital = m_baseName.left(1).toUpper() + m_baseName.mid(1);
m_setterName = QLatin1String("set") + baseNameWithCapital;
}
void updateDescriptionAndPriority()
{
switch (m_type) {
......@@ -6018,27 +6038,7 @@ void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface,
}
}
void GenerateGetterSetterOperation::determineGetterSetterNames()
{
m_baseName = memberBaseName(m_variableString);
if (m_baseName.isEmpty())
m_baseName = QLatin1String("value");
// Getter Name
const CppCodeStyleSettings settings = CppCodeStyleSettings::currentProjectCodeStyle();
const bool hasValidBaseName = m_baseName != m_variableString;
const bool getPrefixIsAlreadyUsed = hasClassMemberWithGetPrefix(m_classSpecifier->symbol);
if (settings.preferGetterNameWithoutGetPrefix && hasValidBaseName && !getPrefixIsAlreadyUsed) {
m_getterName = m_baseName;
} else {
const QString baseNameWithCapital = m_baseName.left(1).toUpper() + m_baseName.mid(1);
m_getterName = QLatin1String("get") + baseNameWithCapital;
}
// Setter Name
const QString baseNameWithCapital = m_baseName.left(1).toUpper() + m_baseName.mid(1);
m_setterName = QLatin1String("set") + baseNameWithCapital;
}
} // namespace Internal
} // namespace CppEditor
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment