aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format/FormatTestJava.cpp
diff options
context:
space:
mode:
authorHannes Braun <hannes@hannesbraun.net>2025-11-05 20:55:32 +0100
committerGitHub <noreply@github.com>2025-11-05 20:55:32 +0100
commit6c4f9688082361a5c5d57aa1e6d368dfc4aeea75 (patch)
treec8a658398ea65c85c3598af5abc17ccc257c6245 /clang/unittests/Format/FormatTestJava.cpp
parentdb6231b4c2e18bb5fc107624e9c9071b02124844 (diff)
downloadllvm-6c4f9688082361a5c5d57aa1e6d368dfc4aeea75.zip
llvm-6c4f9688082361a5c5d57aa1e6d368dfc4aeea75.tar.gz
llvm-6c4f9688082361a5c5d57aa1e6d368dfc4aeea75.tar.bz2
[clang-format] Fix brace wrapping for Java records (#164711)
The brace wrapping for Java records should now behave similar to classes. Before, opening braces for Java records were always placed in the same line as the record definition.
Diffstat (limited to 'clang/unittests/Format/FormatTestJava.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJava.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 1416614b..3cc97e2 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -848,6 +848,19 @@ TEST_F(FormatTestJava, TextBlock) {
" Pat Q. Smith");
}
+TEST_F(FormatTestJava, BreakAfterRecord) {
+ auto Style = getLLVMStyle(FormatStyle::LK_Java);
+ Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
+ Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+ Style.BraceWrapping.AfterClass = true;
+ Style.BraceWrapping.SplitEmptyRecord = true;
+
+ verifyFormat("public record Foo(int i)\n"
+ "{\n"
+ "}",
+ "public record Foo(int i) {}", Style);
+}
+
} // namespace
} // namespace test
} // namespace format