CppEditor: Fix "Move Definition to Class" for function in template class

template<class T>
class Foo { void func(); };

template<class T>
void Foo<T>::func() {} // Move to class

Prior to this change, this currently leaves behind `template<class T>`
where the definition used to be:

template<class T>
class Foo { void func() {} };

template<class T>

Task-number: QTCREATORBUG-14354
Change-Id: I8e1f75a3ae50619a7bae9c63d3798b16bcfea545
Reviewed-by: Lorenz Haas <lorenz.haas@histomatics.de>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Orgad Shaneh
2016-07-28 22:16:45 +03:00
committed by Orgad Shaneh
parent 678e6e4ddf
commit e920921f27
3 changed files with 32 additions and 7 deletions

View File

@@ -4399,6 +4399,23 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_override()
QuickFixOperationTest(singleDocument(original, expected), &factory);
}
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_template()
{
QByteArray original =
"template<class T>\n"
"class Foo { void func(); };\n"
"\n"
"template<class T>\n"
"void Foo<T>::fu@nc() {}\n";
QByteArray expected =
"template<class T>\n"
"class Foo { void fu@nc() {} };\n\n\n";
MoveFuncDefToDecl factory;
QuickFixOperationTest(singleDocument(original, expected), &factory);
}
/// Check: Move all definitions from header to cpp.
void CppEditorPlugin::test_quickfix_MoveAllFuncDefOutside_MemberFuncToCpp()
{