summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp3
-rw-r--r--clang/unittests/Format/FormatTestJava.cpp13
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index aa1bfdc725e..7d54156c3bc 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1362,6 +1362,9 @@ void UnwrappedLineParser::parseEnum() {
// We fall through to parsing a structural element afterwards, so that in
// enum A {} n, m;
// "} n, m;" will end up in one unwrapped line.
+ // This does not apply for Java.
+ if (Style.Language == FormatStyle::LK_Java)
+ addUnwrappedLine();
}
void UnwrappedLineParser::parseRecord() {
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 126b163c600..96dda9b11b4 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -79,6 +79,19 @@ TEST_F(FormatTestJava, ClassDeclarations) {
getStyleWithColumns(40));
}
+TEST_F(FormatTestJava, EnumDeclarations) {
+ verifyFormat("enum SomeThing { ABC, CDE }");
+ verifyFormat("enum SomeThing {\n"
+ " ABC,\n"
+ " CDE,\n"
+ "}");
+ verifyFormat("public class SomeClass {\n"
+ " enum SomeThing { ABC, CDE }\n"
+ " void f() {\n"
+ " }\n"
+ "}");
+}
+
TEST_F(FormatTestJava, ThrowsDeclarations) {
verifyFormat("public void doSooooooooooooooooooooooooooomething()\n"
" throws LooooooooooooooooooooooooooooongException {\n}");
OpenPOWER on IntegriCloud