clang-format: [Java] Remove unnecessary line break after complex annotations
authorDaniel Jasper <djasper@google.com>
Wed, 27 Jan 2016 20:14:23 +0000 (20:14 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 27 Jan 2016 20:14:23 +0000 (20:14 +0000)
Before:
  @Annotation("Some"
      + " text")
  List<Integer>
      list;

After:
  @Annotation("Some"
      + " text")
  List<Integer> list;

llvm-svn: 258981

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

index b820f53..07b9009 100644 (file)
@@ -151,6 +151,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
     return true;
   if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
        (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
+        Style.Language == FormatStyle::LK_Cpp &&
         // FIXME: This is a temporary workaround for the case where clang-format
         // sets BreakBeforeParameter to avoid bin packing and this creates a
         // completely unnecessary line break after a template type that isn't
index 8fadfc0..30d1bc8 100644 (file)
@@ -312,6 +312,9 @@ TEST_F(FormatTestJava, Annotations) {
                "      String bbbbbbbbbbbbbbb) {}\n"
                "}",
                getStyleWithColumns(60));
+  verifyFormat("@Annotation(\"Some\"\n"
+               "    + \" text\")\n"
+               "List<Integer> list;");
 }
 
 TEST_F(FormatTestJava, Generics) {