clang-format: [Java] Support anonymous classes after = and return.

Before:
  A a = new A(){public String toString(){return "NotReallyA";
  }
  }
  ;

After:
  A a = return new A() {
    public String toString() {
      return "NotReallyA";
    }
  };

This fixes llvm.org/PR22878.

llvm-svn: 232042
This commit is contained in:
Daniel Jasper
2015-03-12 14:44:29 +00:00
parent bbdb712765
commit 6acf513099
3 changed files with 42 additions and 0 deletions

View File

@@ -153,6 +153,19 @@ TEST_F(FormatTestJava, ClassDeclarations) {
"}");
}
TEST_F(FormatTestJava, AnonymousClasses) {
verifyFormat("return new A() {\n"
" public String toString() {\n"
" return \"NotReallyA\";\n"
" }\n"
"};");
verifyFormat("A a = new A() {\n"
" public String toString() {\n"
" return \"NotReallyA\";\n"
" }\n"
"};");
}
TEST_F(FormatTestJava, EnumDeclarations) {
verifyFormat("enum SomeThing { ABC, CDE }");
verifyFormat("enum SomeThing {\n"