Hi djasper,

Before

```
enum Foo implements Bar<X, Y> {
  ABC {
    ...
  }
  , CDE {
    ...
  };
}
```

After

```
enum Foo implements Bar<X, Y> {
  ABC {
    ...
  },
  CDE {
    ...
  };
}
```

http://reviews.llvm.org/D6325

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJava.cpp
Index: lib/Format/UnwrappedLineParser.cpp
===================================================================
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1331,7 +1331,7 @@
 void UnwrappedLineParser::parseEnum() {
   // Won't be 'enum' for NS_ENUMs.
   if (FormatTok->Tok.is(tok::kw_enum))
-    nextToken(); 
+    nextToken();
 
   // Eat up enum class ...
   if (FormatTok->Tok.is(tok::kw_class) || FormatTok->Tok.is(tok::kw_struct))
@@ -1342,12 +1342,12 @@
     // We can have macros or attributes in between 'enum' and the enum name.
     if (FormatTok->Tok.is(tok::l_paren))
       parseParens();
-    if (FormatTok->Tok.is(tok::identifier))
+    if (FormatTok->isOneOf(tok::identifier, tok::less, tok::greater, tok::comma))
       nextToken();
   }
 
   // Just a declaration or something is wrong.
-  if (!FormatTok->is(tok::l_brace))
+  if (FormatTok->isNot(tok::l_brace))
     return;
   FormatTok->BlockKind = BK_Block;
 
Index: unittests/Format/FormatTestJava.cpp
===================================================================
--- unittests/Format/FormatTestJava.cpp
+++ unittests/Format/FormatTestJava.cpp
@@ -164,6 +164,20 @@
                "  public void f() {\n"
                "  }\n"
                "}");
+  verifyFormat("private enum SomeEnum implements Foo<A, B> {\n"
+               "  ABC {\n"
+               "    @Override\n"
+               "    public String toString() {\n"
+               "      return \"ABC\";\n"
+               "    }\n"
+               "  },\n"
+               "  CDE {\n"
+               "    @Override\n"
+               "    public String toString() {\n"
+               "      return \"CDE\";\n"
+               "    }\n"
+               "  };\n"
+               "}");
 }
 
 TEST_F(FormatTestJava, ThrowsDeclarations) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to