// space between keywords and paren e.g. "using ("
if (Right.is(tok::l_paren))
if (Left.is(tok::kw_using))
- return spaceRequiredBeforeParens(Left);
+ return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements ||
+ spaceRequiredBeforeParens(Right);
} else if (Style.Language == FormatStyle::LK_JavaScript) {
if (Left.is(TT_JsFatArrow))
return true;
Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
verifyFormat("public void foo () {\n"
" using (StreamWriter sw = new StreamWriter (filenameA)) {}\n"
+ " using () {}\n"
"}",
Style);
+ // Ensure clang-format affects top-level snippets correctly.
verifyFormat("using (StreamWriter sw = new StreamWriter (filenameB)) {}",
Style);
Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
verifyFormat("public void foo() {\n"
" using(StreamWriter sw = new StreamWriter(filenameB)) {}\n"
+ " using() {}\n"
"}",
Style);
+ // Ensure clang-format affects top-level snippets correctly.
verifyFormat("using(StreamWriter sw = new StreamWriter(filenameB)) {}",
Style);
+
+ Style.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
+ verifyFormat("public void foo() {\n"
+ " using (StreamWriter sw = new StreamWriter(filenameA)) {}\n"
+ " using () {}\n"
+ "}",
+ Style);
+
+ // Ensure clang-format affects top-level snippets correctly.
+ verifyFormat("using (StreamWriter sw = new StreamWriter(filenameB)) {}",
+ Style);
+
+ Style.SpaceBeforeParens = FormatStyle::SBPO_NonEmptyParentheses;
+ verifyFormat("public void foo() {\n"
+ " using (StreamWriter sw = new StreamWriter (filenameA)) {}\n"
+ " using() {}\n"
+ "}",
+ Style);
+
+ // Ensure clang-format affects top-level snippets correctly.
+ verifyFormat("using (StreamWriter sw = new StreamWriter (filenameB)) {}",
+ Style);
}
TEST_F(FormatTestCSharp, CSharpRegions) {