forked from qt-creator/qt-creator
CppEditor: Fix handling of "m_" in GenerateGetterSetter
If a variable's name is only "m_" it should not be recognized as a prefix (resulting in an invalid/empty getter and meaningless setter) but rather as a name with the "_" postfix. This way, it results in getM() and setM(). Change-Id: I9a8249fc12319034b95532415f40b6c3183f7754 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
@@ -725,6 +725,36 @@ void CppEditorPlugin::test_quickfix_data()
|
||||
"};\n"
|
||||
) << _();
|
||||
|
||||
// Checks if "m_" is recognized as "m" with the postfix "_" and not simply as "m_" prefix.
|
||||
QTest::newRow("GenerateGetterSetter_recognizeMasVariableName")
|
||||
<< CppQuickFixFactoryPtr(new GenerateGetterSetter) << _(
|
||||
"\n"
|
||||
"class Something\n"
|
||||
"{\n"
|
||||
" int @m_;\n"
|
||||
"};\n"
|
||||
) << _(
|
||||
"\n"
|
||||
"class Something\n"
|
||||
"{\n"
|
||||
" int m_;\n"
|
||||
"\n"
|
||||
"public:\n"
|
||||
" int m() const;\n"
|
||||
" void setM(int m);\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"int Something::m() const\n"
|
||||
"{\n"
|
||||
" return m_;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void Something::setM(int m)\n"
|
||||
"{\n"
|
||||
" m_ = m;\n"
|
||||
"}\n"
|
||||
);
|
||||
|
||||
QTest::newRow("MoveDeclarationOutOfIf_ifOnly")
|
||||
<< CppQuickFixFactoryPtr(new MoveDeclarationOutOfIf) << _(
|
||||
"void f()\n"
|
||||
|
||||
Reference in New Issue
Block a user