CppEditor: Fix insert position in MoveFuncDefToDecl

When a class was directly assigned to a variable the definition was
misplaced right after the variable.

Task-number: QTCREATORBUG-10303
Change-Id: I2cdfee784b085d856d7ff5ebe62bf791b9a6754e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Lorenz Haas
2013-10-05 21:15:43 +02:00
committed by Nikolai Kosjar
parent 2cbb64e0f9
commit e3d95168a0
3 changed files with 29 additions and 1 deletions

View File

@@ -3047,6 +3047,33 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_CtorWithInitialization()
data.run(&factory);
}
/// Check: Definition should not be placed behind the variable. QTCREATORBUG-10303
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_structWithAssignedVariable()
{
QByteArray original =
"struct Foo\n"
"{\n"
" void foo();\n"
"} bar;\n\n"
"void Foo::fo@o()\n"
"{\n"
" return;\n"
"}";
QByteArray expected =
"struct Foo\n"
"{\n"
" void foo()\n"
" {\n"
" return;\n"
" }\n"
"} bar;\n\n\n";
MoveFuncDefToDecl factory;
TestCase data(original, expected);
data.run(&factory);
}
/// Check: Add local variable for a free function.
void CppEditorPlugin::test_quickfix_AssignToLocalVariable_freeFunction()
{