forked from qt-creator/qt-creator
CppEditor: Support try/catch in built-in indenter
Fixes: QTCREATORBUG-29452 Change-Id: Icf3d86a6080aeb741436800ae77af7c8bec3155c Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -109,6 +109,7 @@ private Q_SLOTS:
|
||||
void structuredBinding();
|
||||
void subscriptOperatorInFunctionCall();
|
||||
void statementMacros();
|
||||
void tryCatchClause();
|
||||
};
|
||||
|
||||
struct Line {
|
||||
@@ -2231,6 +2232,45 @@ void tst_CodeFormatter::statementMacros()
|
||||
checkIndent(data, settings);
|
||||
}
|
||||
|
||||
void tst_CodeFormatter::tryCatchClause()
|
||||
{
|
||||
CppCodeStyleSettings settings;
|
||||
settings.indentFunctionBody = true;
|
||||
settings.indentFunctionBraces = false;
|
||||
settings.indentBlockBody = false;
|
||||
settings.indentBlockBraces = true;
|
||||
QList<Line> data;
|
||||
data << Line("int main()")
|
||||
<< Line("{")
|
||||
<< Line(" try")
|
||||
<< Line(" {")
|
||||
<< Line(" throw;")
|
||||
<< Line(" }")
|
||||
<< Line(" catch (const E &e)")
|
||||
<< Line(" {")
|
||||
<< Line(" handle(e);")
|
||||
<< Line(" }")
|
||||
<< Line(" catch (...)")
|
||||
<< Line(" {")
|
||||
<< Line(" handle();")
|
||||
<< Line(" }")
|
||||
<< Line("}");
|
||||
checkIndent(data, settings);
|
||||
|
||||
data.clear();
|
||||
data << Line("int main()")
|
||||
<< Line("{")
|
||||
<< Line(" try {")
|
||||
<< Line(" throw;")
|
||||
<< Line(" } catch (const E &e) {")
|
||||
<< Line(" handle(e);")
|
||||
<< Line(" } catch (...) {")
|
||||
<< Line(" handle();")
|
||||
<< Line(" }")
|
||||
<< Line("}");
|
||||
checkIndent(data);
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(tst_CodeFormatter)
|
||||
|
||||
#include "tst_codeformatter.moc"
|
||||
|
||||
Reference in New Issue
Block a user