]> granicus.if.org Git - clang/commitdiff
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;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258981 91177308-0d34-0410-b5e6-96231b3b80d8

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

index b820f53db52739d5a7f4340d11c4d36a251d3b31..07b90090ac2739225dfea067a15d65437fbfe82e 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 8fadfc09b3ed73d417c0b778f090da7aacc793a4..30d1bc8baf82ac25d6132f92f58e528198284aee 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) {