CppEditor: Respect current getter coding style

With a simple check GenerateGetterSetter looks for symbols starting with
"get". If such symbols are found it is most likely that the current
class uses "getFoo" for getters and thus the quick fix uses this coding
style for generating the getter name.

Change-Id: I9ff8ef8bb936572abaaf9e671b8985553c1018f1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Lorenz Haas
2015-03-22 18:56:29 +01:00
parent 0913eb8660
commit 0ea753ad63
2 changed files with 53 additions and 1 deletions

View File

@@ -612,6 +612,38 @@ void CppEditorPlugin::test_quickfix_data()
"}\n"
);
// Checks if getter uses 'get' prefix if member function with such a prefix is found
QTest::newRow("GenerateGetterSetter_getterWithGetPrefix")
<< CppQuickFixFactoryPtr(new GenerateGetterSetter) << _(
"\n"
"class Something\n"
"{\n"
" int getFoo();\n"
" int @m_it;\n"
"};\n"
) << _(
"\n"
"class Something\n"
"{\n"
" int getFoo();\n"
" int m_it;\n"
"\n"
"public:\n"
" int getIt() const;\n"
" void setIt(int it);\n"
"};\n"
"\n"
"int Something::getIt() const\n"
"{\n"
" return m_it;\n"
"}\n"
"\n"
"void Something::setIt(int it)\n"
"{\n"
" m_it = it;\n"
"}\n"
);
// Check: Setter: Use pass by reference for parameters which
// are not integer, float or pointers.
QTest::newRow("GenerateGetterSetter_customType")