forked from qt-creator/qt-creator
CppEditor: Add enclosing template on "Add Definition"
The template id for the class name is missing, but it's better than
nothing.
For example:
template<class T>
class Foo
{
void func(); // Add Definition
};
// The following lines are added
template<class T>
void Foo::func() // Should be Foo<T>::func
{
}
Change-Id: I60a0cbd348985def3dfb7037067786e942278593
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
39aff55d8a
commit
d0d1f43e8f
@@ -2668,6 +2668,56 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_unicodeIdentifier()
|
||||
QuickFixOperationTest(testDocuments, &factory);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_templateClass()
|
||||
{
|
||||
QByteArray original =
|
||||
"template<class T>\n"
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" void fun@c();\n"
|
||||
"};\n";
|
||||
QByteArray expected =
|
||||
"template<class T>\n"
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" void fun@c();\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"template<class T>\n"
|
||||
"void Foo::func()\n" // Should really be Foo<T>::func()
|
||||
"{\n"
|
||||
"\n"
|
||||
"}\n";
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_templateFunction()
|
||||
{
|
||||
QByteArray original =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" template<class T>\n"
|
||||
" void fun@c();\n"
|
||||
"};\n";
|
||||
QByteArray expected =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" template<class T>\n"
|
||||
" void fun@c();\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"template<class T>\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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user