Commit fef167b9 authored by Lorenz Haas's avatar Lorenz Haas

CppEditor: Allow single "m" prefix for GenerateGetterSetter

Task-number: QTCREATORBUG-12244
Change-Id: Iab666f003df04da97ed7f4aa47f9b979e319e9a4
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 386eca64
......@@ -755,6 +755,36 @@ void CppEditorPlugin::test_quickfix_data()
"}\n"
);
// Checks if "m" followed by an upper character is recognized as a prefix
QTest::newRow("GenerateGetterSetter_recognizeMFollowedByCapital")
<< CppQuickFixFactoryPtr(new GenerateGetterSetter) << _(
"\n"
"class Something\n"
"{\n"
" int @mFoo;\n"
"};\n"
) << _(
"\n"
"class Something\n"
"{\n"
" int mFoo;\n"
"\n"
"public:\n"
" int foo() const;\n"
" void setFoo(int foo);\n"
"};\n"
"\n"
"int Something::foo() const\n"
"{\n"
" return mFoo;\n"
"}\n"
"\n"
"void Something::setFoo(int foo)\n"
"{\n"
" mFoo = foo;\n"
"}\n"
);
QTest::newRow("MoveDeclarationOutOfIf_ifOnly")
<< CppQuickFixFactoryPtr(new MoveDeclarationOutOfIf) << _(
"void f()\n"
......
......@@ -2827,12 +2827,17 @@ public:
m_variableString = QString::fromUtf8(variableId->chars(), variableId->size());
m_baseName = m_variableString;
if (m_baseName.startsWith(QLatin1Char('_')))
if (m_baseName.startsWith(QLatin1Char('_'))) {
m_baseName.remove(0, 1);
else if (m_baseName.endsWith(QLatin1Char('_')))
} else if (m_baseName.endsWith(QLatin1Char('_'))) {
m_baseName.chop(1);
else if (m_baseName.startsWith(QLatin1String("m_")))
} else if (m_baseName.startsWith(QLatin1String("m_"))) {
m_baseName.remove(0, 2);
} else if (m_baseName.startsWith(QLatin1Char('m')) && m_baseName.length() > 1
&& m_baseName.at(1).isUpper()) {
m_baseName.remove(0, 1);
m_baseName[0] = m_baseName.at(0).toLower();
}
m_getterName = m_baseName != m_variableString
? m_baseName
......
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