// If in Whitemsmiths mode, indent start and end of blocks
if (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths) {
- if (RootToken.isOneOf(tok::l_brace, tok::r_brace, tok::kw_case))
+ if (RootToken.isOneOf(tok::l_brace, tok::r_brace, tok::kw_case,
+ tok::kw_default))
Indent += Style.IndentWidth;
}
parseBlock(/*MustBeDeclaration=*/false);
if (FormatTok->Tok.is(tok::kw_break)) {
if (Style.BraceWrapping.AfterControlStatement ==
- FormatStyle::BWACS_Always)
+ FormatStyle::BWACS_Always) {
addUnwrappedLine();
+ if (!Style.IndentCaseBlocks &&
+ Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths) {
+ Line->Level++;
+ }
+ }
parseStructuralElement();
}
addUnwrappedLine();
" }\n",
WhitesmithsBraceStyle);
- // FIXME: the block and the break under case 2 in this test don't get indented
- // correctly
- /*
+ WhitesmithsBraceStyle.IndentCaseBlocks = true;
verifyFormat("void switchTest1(int a)\n"
" {\n"
" switch (a)\n"
" case 2:\n"
" {\n"
" }\n"
- " break;\n"
+ " break;\n"
" }\n"
" }\n",
WhitesmithsBraceStyle);
- */
- // FIXME: the block and the break under case 2 in this test don't get indented
- // correctly
- /*
verifyFormat("void switchTest2(int a)\n"
" {\n"
" switch (a)\n"
" {\n"
- " case 0:\n"
+ " case 0:\n"
" break;\n"
- " case 1:\n"
+ " case 1:\n"
+ " {\n"
+ " break;\n"
+ " }\n"
+ " case 2:\n"
+ " {\n"
+ " }\n"
+ " break;\n"
+ " default:\n"
+ " break;\n"
+ " }\n"
+ " }\n",
+ WhitesmithsBraceStyle);
+
+ verifyFormat("void switchTest3(int a)\n"
+ " {\n"
+ " switch (a)\n"
" {\n"
+ " case 0:\n"
+ " {\n"
+ " foo(x);\n"
+ " }\n"
+ " break;\n"
+ " default:\n"
+ " {\n"
+ " foo(1);\n"
+ " }\n"
" break;\n"
" }\n"
- " case 2:\n"
+ " }\n",
+ WhitesmithsBraceStyle);
+
+ WhitesmithsBraceStyle.IndentCaseBlocks = false;
+
+ verifyFormat("void switchTest4(int a)\n"
+ " {\n"
+ " switch (a)\n"
+ " {\n"
+ " case 2:\n"
" {\n"
" }\n"
" break;\n"
- " default:\n"
+ " }\n"
+ " }\n",
+ WhitesmithsBraceStyle);
+
+ verifyFormat("void switchTest5(int a)\n"
+ " {\n"
+ " switch (a)\n"
+ " {\n"
+ " case 0:\n"
+ " break;\n"
+ " case 1:\n"
+ " {\n"
+ " foo();\n"
+ " break;\n"
+ " }\n"
+ " case 2:\n"
+ " {\n"
+ " }\n"
+ " break;\n"
+ " default:\n"
+ " break;\n"
+ " }\n"
+ " }\n",
+ WhitesmithsBraceStyle);
+
+ verifyFormat("void switchTest6(int a)\n"
+ " {\n"
+ " switch (a)\n"
+ " {\n"
+ " case 0:\n"
+ " {\n"
+ " foo(x);\n"
+ " }\n"
+ " break;\n"
+ " default:\n"
+ " {\n"
+ " foo(1);\n"
+ " }\n"
" break;\n"
" }\n"
" }\n",
WhitesmithsBraceStyle);
- */
verifyFormat("enum X\n"
" {\n"