CppEditor: GenerateGetterSetter now ignores symbols in Q_PROPERTY

Since the Q_PROPERTY's name equals the typical getter name the "Generate
Getter" quick fix was not offered.

Q_PROPERTY(int a ...) // <-- a is "recognized" as "int a();"
int m_a;

Task-number: QTCREATORBUG-14166
Change-Id: I35709a1b6492b68309d02427d60251df4fd76cfa
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Lorenz Haas
2015-03-21 19:24:31 +01:00
parent 4749d5ece4
commit 0913eb8660
2 changed files with 34 additions and 1 deletions

View File

@@ -914,6 +914,36 @@ void CppEditorPlugin::test_quickfix_data()
"}\n"
);
// Checks if the declaration inside Q_PROPERTY macro is ignored and a getter created
QTest::newRow("GenerateGetterSetter_ignoreQPropertiesMacro")
<< CppQuickFixFactoryPtr(new GenerateGetterSetter) << _(
"class Something\n"
"{\n"
" Q_PROPERTY(int foo)\n"
" int @m_foo;\n"
"};\n"
) << _(
"class Something\n"
"{\n"
" Q_PROPERTY(int foo)\n"
" int m_foo;\n"
"\n"
"public:\n"
" int foo() const;\n"
" void setFoo(int foo);\n"
"};\n"
"\n"
"int Something::foo() const\n"
"{\n"
" return m_foo;\n"
"}\n"
"\n"
"void Something::setFoo(int foo)\n"
"{\n"
" m_foo = foo;\n"
"}\n"
);
QTest::newRow("MoveDeclarationOutOfIf_ifOnly")
<< CppQuickFixFactoryPtr(new MoveDeclarationOutOfIf) << _(
"void f()\n"