clang-format: [Java] Prefer not to break in parameter annotations.
authorDaniel Jasper <djasper@google.com>
Wed, 14 Jan 2015 10:36:31 +0000 (10:36 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 14 Jan 2015 10:36:31 +0000 (10:36 +0000)
Before:
  boolean someFunction(@Param(aaaaaaaaaaaaaaaa)
                       String aaaaa,
      String bbbbbbbbbbbbbbb) {}

After:
  boolean someFunction(
      @Param(aaaaaaaaaaaaaaaa) String aaaaa,
      String bbbbbbbbbbbbbbb) {}

llvm-svn: 225971

clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestJava.cpp

index 34d8835..d0d888f 100644 (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)) {
index 9b3b993..af4199b 100644 (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) {