r225971 - clang-format: [Java] Prefer not to break in parameter annotations.
Daniel Jasper
djasper at google.com
Wed Jan 14 02:36:31 PST 2015
Author: djasper
Date: Wed Jan 14 04:36:31 2015
New Revision: 225971
URL: http://llvm.org/viewvc/llvm-project?rev=225971&view=rev
Log:
clang-format: [Java] Prefer not to break in parameter annotations.
Before:
boolean someFunction(@Param(aaaaaaaaaaaaaaaa)
String aaaaa,
String bbbbbbbbbbbbbbb) {}
After:
boolean someFunction(
@Param(aaaaaaaaaaaaaaaa) String aaaaa,
String bbbbbbbbbbbbbbb) {}
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=225971&r1=225970&r2=225971&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jan 14 04:36:31 2015
@@ -1587,6 +1587,8 @@ unsigned TokenAnnotator::splitPenalty(co
return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter
: 19;
}
+ if (Left.is(TT_JavaAnnotation))
+ return 50;
if (Right.is(tok::lessless)) {
if (Left.is(tok::string_literal)) {
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=225971&r1=225970&r2=225971&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Wed Jan 14 04:36:31 2015
@@ -287,6 +287,12 @@ TEST_F(FormatTestJava, Annotations) {
"ReturnType doSomething(\n"
" String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}",
getStyleWithColumns(60));
+ verifyFormat("{\n"
+ " boolean someFunction(\n"
+ " @Param(aaaaaaaaaaaaaaaa) String aaaaa,\n"
+ " String bbbbbbbbbbbbbbb) {}\n"
+ "}",
+ getStyleWithColumns(60));
}
TEST_F(FormatTestJava, Generics) {
More information about the cfe-commits
mailing list