forked from qt-creator/qt-creator
CppEditor: Make "Add curly braces" quickfix more robust
Anchor the opening brace at the closing parenthesis, rather than at the statement. This way, we won't get troubled by macro weirdness in the statement part. Fixes: QTCREATORBUG-13921 Change-Id: I05af24d1642e6b62c78bb2f47a1ef0b1fea326d0 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -5417,6 +5417,31 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_notTriggeringForIn
|
||||
QuickFixOperationTest(testDocuments, &factory);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_addCurlyBraces()
|
||||
{
|
||||
QList<QuickFixTestDocument::Ptr> testDocuments;
|
||||
const QByteArray original = R"delim(
|
||||
void MyObject::f()
|
||||
{
|
||||
@if (true)
|
||||
emit mySig();
|
||||
}
|
||||
)delim";
|
||||
const QByteArray expected = R"delim(
|
||||
void MyObject::f()
|
||||
{
|
||||
if (true) {
|
||||
emit mySig();
|
||||
}
|
||||
}
|
||||
)delim";
|
||||
|
||||
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||
AddBracesToIf factory;
|
||||
QuickFixOperationTest(testDocuments, &factory);
|
||||
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectOutOfClass()
|
||||
{
|
||||
QByteArray prefix =
|
||||
|
||||
Reference in New Issue
Block a user