LLVMStyle.SplitTemplateClosingGreater = true;
LLVMStyle.IndentCaseLabels = false;
LLVMStyle.SpacesBeforeTrailingComments = 1;
+ LLVMStyle.ObjCSpaceBeforeProtocolList = true;
return LLVMStyle;
}
GoogleStyle.SplitTemplateClosingGreater = false;
GoogleStyle.IndentCaseLabels = true;
GoogleStyle.SpacesBeforeTrailingComments = 2;
+ GoogleStyle.ObjCSpaceBeforeProtocolList = false;
return GoogleStyle;
}
return Right.is(tok::hash);
if (Right.is(tok::r_paren) || Right.is(tok::semi) || Right.is(tok::comma))
return false;
- if (Left.is(tok::kw_template) && Right.is(tok::less))
+ if (Right.is(tok::less) &&
+ (Left.is(tok::kw_template) ||
+ (CurrentLineType == LT_ObjCDecl && Style.ObjCSpaceBeforeProtocolList)))
return true;
if (Left.is(tok::arrow) || Right.is(tok::arrow))
return false;
*/
@property (copy) id PropertyMyClass;
@end
-// CHECK: <Declaration>@interface MyClass : NSObject<MyProto> {\n id IvarMyClass;\n}\n@end</Declaration>
+// CHECK: <Declaration>@interface MyClass : NSObject <MyProto> {\n id IvarMyClass;\n}\n@end</Declaration>
// CHECK: <Declaration>id IvarMyClass</Declaration>
// CHECK: <Declaration>- (id)MethodMyClass;</Declaration>
// CHECK: <Declaration>+ (id)ClassMethodMyClass;</Declaration>
TEST_F(FormatTest, FormatObjCInterface) {
// FIXME: Handle comments like in "@interface /* wait for it */ Foo", PR14875
// FIXME: In google style, it's "+(id) init", not "+ (id)init".
- verifyFormat("@interface Foo : NSObject<NSSomeDelegate> {\n"
+ verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n"
"@public\n"
" int field1;\n"
"@protected\n"
"+ (id)init;\n"
"@end");
- // FIXME: In LLVM style, there should be a space before '<' for protocols.
verifyGoogleFormat("@interface Foo : NSObject<NSSomeDelegate> {\n"
" @public\n"
" int field1;\n"
"+ (id)init;\n"
"@end");
- verifyFormat("@interface Foo : Bar<Baz, Quux>\n"
+ verifyFormat("@interface Foo : Bar <Baz, Quux>\n"
"+ (id)init;\n"
"@end");
+ verifyGoogleFormat("@interface Foo : Bar<Baz, Quux>\n"
+ "+ (id)init;\n"
+ "@end");
+
verifyFormat("@interface Foo (HackStuff)\n"
"+ (id)init;\n"
"@end");
"+ (id)init;\n"
"@end");
- verifyFormat("@interface Foo (HackStuff)<MyProtocol>\n"
+ verifyFormat("@interface Foo (HackStuff) <MyProtocol>\n"
"+ (id)init;\n"
"@end");
+ verifyGoogleFormat("@interface Foo (HackStuff)<MyProtocol>\n"
+ "+ (id)init;\n"
+ "@end");
+
verifyFormat("@interface Foo {\n"
" int _i;\n"
"}\n"
"+ (id)init;\n"
"@end");
- verifyFormat("@interface Foo : Bar<Baz, Quux> {\n"
+ verifyFormat("@interface Foo : Bar <Baz, Quux> {\n"
" int _i;\n"
"}\n"
"+ (id)init;\n"
"+ (id)init;\n"
"@end");
- verifyFormat("@interface Foo (HackStuff)<MyProtocol> {\n"
+ verifyFormat("@interface Foo (HackStuff) <MyProtocol> {\n"
" int _i;\n"
"}\n"
"+ (id)init;\n"
"- (NSUInteger)numberOfThings;\n"
"@end");
- // FIXME: In LLVM style, there should be a space before '<' for protocols.
- verifyFormat("@protocol MyProtocol<NSObject>\n"
+ verifyFormat("@protocol MyProtocol <NSObject>\n"
"- (NSUInteger)numberOfThings;\n"
"@end");
+ verifyGoogleFormat("@protocol MyProtocol<NSObject>\n"
+ "- (NSUInteger)numberOfThings;\n"
+ "@end");
+
verifyFormat("@protocol Foo;\n"
"@protocol Bar;\n");