forked from qt-creator/qt-creator
CppEditor: Respect whitespace in operator names for more quick fixes
* Affected quick fixes: InsertDefFromDecl, MoveFuncDefOutside * Fix also reformating pointer declaration of operator functions for qualified name ids Change-Id: I6a7578f496221557d103f5fdbb5dacc9540ee779 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -1178,6 +1178,58 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
/// Check if whitespace is respected for operator functions
|
||||
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1()
|
||||
{
|
||||
QByteArray original =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" Foo &opera@tor =();\n"
|
||||
"};\n";
|
||||
QByteArray expected =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" Foo &operator =();\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Foo &Foo::operator =()\n"
|
||||
"{\n"
|
||||
"\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
TestCase data(original, expected);
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
/// Check if whitespace is respected for operator functions
|
||||
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2()
|
||||
{
|
||||
QByteArray original =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" Foo &opera@tor=();\n"
|
||||
"};\n";
|
||||
QByteArray expected =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" Foo &operator=();\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Foo &Foo::operator=()\n"
|
||||
"{\n"
|
||||
"\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
TestCase data(original, expected);
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
// Function for one of InsertDeclDef section cases
|
||||
void insertToSectionDeclFromDef(const QByteArray §ion, int sectionIndex)
|
||||
{
|
||||
@@ -2458,6 +2510,52 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
|
||||
data.run(&factory, 1);
|
||||
}
|
||||
|
||||
/// Check if whitespace is respected for operator functions
|
||||
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames1()
|
||||
{
|
||||
QByteArray original =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" Foo &opera@tor =() {}\n"
|
||||
"};\n";
|
||||
QByteArray expected =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" Foo &operator =();\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Foo &Foo::operator =() {}\n"
|
||||
"\n";
|
||||
|
||||
MoveFuncDefOutside factory;
|
||||
TestCase data(original, expected);
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
/// Check if whitespace is respected for operator functions
|
||||
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2()
|
||||
{
|
||||
QByteArray original =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" Foo &opera@tor=() {}\n"
|
||||
"};\n";
|
||||
QByteArray expected =
|
||||
"class Foo\n"
|
||||
"{\n"
|
||||
" Foo &operator=();\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Foo &Foo::operator=() {}\n"
|
||||
"\n";
|
||||
|
||||
MoveFuncDefOutside factory;
|
||||
TestCase data(original, expected);
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
|
||||
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFunc()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user