forked from qt-creator/qt-creator
CppEditor: Improve "definition from declaration" for templates
- Make sure the template parameters are included in the definition. - Find the correct insertion location when using an already-defined template member function as an anchor. Fixes: QTCREATORBUG-24848 Change-Id: I1272ba36403904e7aed81bcef48745793c5e2217 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -3740,20 +3740,25 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_templateClass()
|
||||
"template<class T>\n"
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" void fun@c();\n"
|
||||
"};\n";
|
||||
" void fun@c1();\n"
|
||||
" void func2();\n"
|
||||
"};\n\n"
|
||||
"template<class T>\n"
|
||||
"void Foo<T>::func2() {}\n";
|
||||
QByteArray expected =
|
||||
"template<class T>\n"
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" void fun@c();\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
" void func1();\n"
|
||||
" void func2();\n"
|
||||
"};\n\n"
|
||||
"template<class T>\n"
|
||||
"void Foo::func()\n" // Should really be Foo<T>::func()
|
||||
"void Foo<T>::func1()\n"
|
||||
"{\n"
|
||||
"\n"
|
||||
"}\n";
|
||||
"}\n\n"
|
||||
"template<class T>\n"
|
||||
"void Foo<T>::func2() {}\n";
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||
@@ -3775,7 +3780,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_templateFunction()
|
||||
"};\n"
|
||||
"\n"
|
||||
"template<class T>\n"
|
||||
"void Foo::func()\n"
|
||||
"void Foo::func<T>()\n"
|
||||
"{\n"
|
||||
"\n"
|
||||
"}\n";
|
||||
|
||||
Reference in New Issue
Block a user