diff --git a/src/plugins/cppeditor/cppeditorplugin.h b/src/plugins/cppeditor/cppeditorplugin.h index 66b94fe6fcf..a6653942879 100644 --- a/src/plugins/cppeditor/cppeditorplugin.h +++ b/src/plugins/cppeditor/cppeditorplugin.h @@ -145,6 +145,8 @@ private slots: void test_quickfix_InsertDefFromDecl_rvalueReference(); void test_quickfix_InsertDefFromDecl_findImplementationFile(); void test_quickfix_InsertDefFromDecl_unicodeIdentifier(); + void test_quickfix_InsertDefFromDecl_templateClass(); + void test_quickfix_InsertDefFromDecl_templateFunction(); void test_quickfix_InsertDeclFromDef(); void test_quickfix_InsertDeclFromDef_templateFuncTypename(); diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index d9fd1d38b33..e405797de43 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -2668,6 +2668,56 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_unicodeIdentifier() QuickFixOperationTest(testDocuments, &factory); } +void CppEditorPlugin::test_quickfix_InsertDefFromDecl_templateClass() +{ + QByteArray original = + "template\n" + "class Foo\n" + "{\n" + " void fun@c();\n" + "};\n"; + QByteArray expected = + "template\n" + "class Foo\n" + "{\n" + " void fun@c();\n" + "};\n" + "\n" + "template\n" + "void Foo::func()\n" // Should really be Foo::func() + "{\n" + "\n" + "}\n"; + + InsertDefFromDecl factory; + QuickFixOperationTest(singleDocument(original, expected), &factory); +} + +void CppEditorPlugin::test_quickfix_InsertDefFromDecl_templateFunction() +{ + QByteArray original = + "class Foo\n" + "{\n" + " template\n" + " void fun@c();\n" + "};\n"; + QByteArray expected = + "class Foo\n" + "{\n" + " template\n" + " void fun@c();\n" + "};\n" + "\n" + "template\n" + "void Foo::func()\n" + "{\n" + "\n" + "}\n"; + + InsertDefFromDecl factory; + QuickFixOperationTest(singleDocument(original, expected), &factory); +} + // Function for one of InsertDeclDef section cases void insertToSectionDeclFromDef(const QByteArray §ion, int sectionIndex) { diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 68ca671bf9c..9200869b79a 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -2567,6 +2567,7 @@ public: oo.showFunctionSignatures = true; oo.showReturnTypes = true; oo.showArgumentNames = true; + oo.showEnclosingTemplate = true; if (m_defpos == DefPosInsideClass) { const int targetPos = targetFile->position(m_loc.line(), m_loc.column());