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) {}

llvm-svn: 225971
This commit is contained in:
Daniel Jasper 2015-01-14 10:36:31 +00:00
parent a18dcf7efd
commit 190fbda6de
2 changed files with 8 additions and 0 deletions

View File

@ -1587,6 +1587,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
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)) {

View File

@ -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) {