clang-format: [Java] Make annotation formatting more consistent.

Before:
  DoSomething(new A() {
    @Override public String toString() {
    }
  });

After:
  DoSomething(new A() {
    @Override
    public String toString() {
    }
  });

llvm-svn: 220282
This commit is contained in:
Daniel Jasper 2014-10-21 10:02:03 +00:00
parent 16b107e9f0
commit c7d024ac53
2 changed files with 7 additions and 1 deletions

View File

@ -1797,7 +1797,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
return true;
} else if (Style.Language == FormatStyle::LK_Java) {
if (Left.Type == TT_JavaAnnotation && Right.isNot(tok::l_paren) &&
Line.MightBeFunctionDecl)
Line.Last->is(tok::l_brace))
return true;
}

View File

@ -75,6 +75,12 @@ TEST_F(FormatTestJava, Annotations) {
verifyFormat("@SuppressWarnings(value = \"unchecked\")\n"
"public void doSomething() {\n}");
verifyFormat("DoSomething(new A() {\n"
" @Override\n"
" public String toString() {\n"
" }\n"
"});");
verifyFormat("@Partial @Mock DataLoader loader;");
}