Previously, Java annotation declarations (@interface AnnotationName) were being
handled as ObjC interfaces. This caused the brace formatting to mess up, so
that when you had a class with an interface defined in it, it would indent the
final brace of the class.
It used to format this class like so:
class A {
@interface B {}
}
But will now just skip the @interface and format it like so:
class A {
@interface B {}
}
Patch by Sam Maier!
Differential Revision: https://reviews.llvm.org/D53434
llvm-svn: 344789
nextToken();
parseBracedList();
break;
+ } else if (Style.Language == FormatStyle::LK_Java &&
+ FormatTok->is(Keywords.kw_interface)) {
+ nextToken();
+ break;
}
switch (FormatTok->Tok.getObjCKeywordID()) {
case tok::objc_public:
" void doStuff(int theStuff);\n"
" void doMoreStuff(int moreStuff);\n"
"}");
+ verifyFormat("class A {\n"
+ " public @interface SomeInterface {\n"
+ " int stuff;\n"
+ " void doMoreStuff(int moreStuff);\n"
+ " }\n"
+ "}");
+ verifyFormat("class A {\n"
+ " public @interface SomeInterface {}\n"
+ "}");
}
TEST_F(FormatTestJava, AnonymousClasses) {