clang-format: [Java] Don't line-wrap before annotations' l_parens.
authorDaniel Jasper <djasper@google.com>
Wed, 14 Jan 2015 09:51:32 +0000 (09:51 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 14 Jan 2015 09:51:32 +0000 (09:51 +0000)
Before:
  @SomeAnnotation
  (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
  int i;

After:
  @SomeAnnotation(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
  int i;

llvm-svn: 225963

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

index 11dd2be..351c6fa 100644 (file)
@@ -1939,7 +1939,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
   if (Left.Tok.getObjCKeywordID() == tok::objc_interface)
     return false;
   if (Left.isOneOf(TT_JavaAnnotation, TT_LeadingJavaAnnotation))
-    return true;
+    return !Right.is(tok::l_paren);
   if (Right.isOneOf(TT_StartOfName, TT_FunctionDeclarationName) ||
       Right.is(tok::kw_operator))
     return true;
index a3e86d6..39abc7b 100644 (file)
@@ -279,6 +279,10 @@ TEST_F(FormatTestJava, Annotations) {
   verifyFormat("@Test(a)\n"
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
                "    aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa);");
+  verifyFormat("@SomeAnnotation(\n"
+               "    aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa)\n"
+               "int i;",
+               getStyleWithColumns(50));
 }
 
 TEST_F(FormatTestJava, Generics) {