forked from qt-creator/qt-creator
CppEditor: InsertDefFromDecl: choose insert position
Now one can decide where the new definition should go: Inside the class, outside the class or to the implementation file. Further the text cursor is positioned inside the new created definition body. Task-number: QTCREATORBUG-6973 Change-Id: I593955dd1e44e35240fa1e9b9a5c1a67eb119456 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
5dbcb974b0
commit
15f90404aa
@@ -713,11 +713,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_basic()
|
||||
"\n"
|
||||
;
|
||||
const QByteArray expected = original +
|
||||
"\n"
|
||||
"Foo::Foo()\n"
|
||||
"{\n"
|
||||
"{\n\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n\n"
|
||||
;
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
@@ -747,7 +746,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1()
|
||||
expected =
|
||||
"\n"
|
||||
"Foo::Foo()\n"
|
||||
"{\n"
|
||||
"{\n\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
;
|
||||
@@ -776,10 +775,9 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2()
|
||||
" Foo()@;\n"
|
||||
"};\n";
|
||||
expected = original +
|
||||
"\n"
|
||||
"\n"
|
||||
"Foo::Foo()\n"
|
||||
"{\n"
|
||||
"{\n\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
;
|
||||
@@ -815,7 +813,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace1()
|
||||
expected =
|
||||
"\n"
|
||||
"N::Foo::Foo()\n"
|
||||
"{\n"
|
||||
"{\n\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
;
|
||||
@@ -855,7 +853,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace2()
|
||||
expected = original +
|
||||
"\n"
|
||||
"Foo::Foo()\n"
|
||||
"{\n"
|
||||
"{\n\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
;
|
||||
@@ -869,11 +867,8 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace2()
|
||||
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_freeFunction()
|
||||
{
|
||||
const QByteArray original = "void free()@;\n";
|
||||
const QByteArray expected = original +
|
||||
"\n"
|
||||
"\n"
|
||||
"void free()\n"
|
||||
"{\n"
|
||||
const QByteArray expected =
|
||||
"void free() {\n\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
;
|
||||
@@ -883,6 +878,25 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_freeFunction()
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
/// Check definition insert inside class
|
||||
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass()
|
||||
{
|
||||
const QByteArray original =
|
||||
"class Foo {\n"
|
||||
" void b@ar();\n"
|
||||
"};";
|
||||
const QByteArray expected =
|
||||
"class Foo {\n"
|
||||
" void bar() {\n"
|
||||
"\n"
|
||||
" }\n"
|
||||
"};\n";
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
TestCase data(original, expected);
|
||||
data.run(&factory, 1);
|
||||
}
|
||||
|
||||
// Function for one of InsertDeclDef section cases
|
||||
void insertToSectionDeclFromDef(const QByteArray §ion, int sectionIndex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user