}
if (CurrentToken->isOneOf(tok::r_paren, tok::r_brace))
return false;
- if (CurrentToken->is(tok::colon))
+ if (CurrentToken->is(tok::colon)) {
+ if (Left->Type == TT_ArraySubscriptLSquare) {
+ Left->Type = TT_ObjCMethodExpr;
+ StartsObjCMethodExpr = true;
+ Contexts.back().ColonIsObjCMethodExpr = true;
+ if (Parent && Parent->is(tok::r_paren))
+ Parent->Type = TT_CastRParen;
+ }
ColonFound = true;
+ }
if (CurrentToken->is(tok::comma) &&
Style.Language != FormatStyle::LK_Proto &&
(Left->Type == TT_ArraySubscriptLSquare ||
TEST_F(FormatTest, FormatObjCMethodExpr) {
verifyFormat("[foo bar:baz];");
verifyFormat("return [foo bar:baz];");
+ verifyFormat("return (a)[foo bar:baz];");
verifyFormat("f([foo bar:baz]);");
verifyFormat("f(2, [foo bar:baz]);");
verifyFormat("f(2, a ? b : c);");
verifyFormat("foo(^{ bar(); });");
verifyFormat("foo(a, ^{ bar(); });");
- // FIXME: Make whitespace formatting consistent. Ask a ObjC dev how
- // it would ideally look.
verifyFormat("[operation setCompletionBlock:^{ [self onOperationDone]; }];");
- verifyFormat("int i = {[operation setCompletionBlock : ^{ [self "
+ verifyFormat("int i = {[operation setCompletionBlock:^{ [self "
"onOperationDone]; }]};");
verifyFormat("[operation setCompletionBlock:^(int *i) { f(); }];");
verifyFormat("int a = [operation block:^int(int *i) { return 1; }];");