r221113 - clang-format: [Java] Support enums without trailing semicolon.
Daniel Jasper
djasper at google.com
Sun Nov 2 14:31:40 PST 2014
Author: djasper
Date: Sun Nov 2 16:31:39 2014
New Revision: 221113
URL: http://llvm.org/viewvc/llvm-project?rev=221113&view=rev
Log:
clang-format: [Java] Support enums without trailing semicolon.
Before:
class SomeClass {
enum SomeThing { ABC, CDE } void f() {
}
}
After:
class SomeClass {
enum SomeThing { ABC, CDE }
void f() {
}
}
This fixed llvm.org/PR21458.
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=221113&r1=221112&r2=221113&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Sun Nov 2 16:31:39 2014
@@ -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() {
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=221113&r1=221112&r2=221113&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Sun Nov 2 16:31:39 2014
@@ -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}");
More information about the cfe-commits
mailing list