CurrentPrecedence = 1;
else if (Current->Type == TT_BinaryOperator || Current->is(tok::comma))
CurrentPrecedence = 1 + (int)Current->getPrecedence();
+ else if (Current->Type == TT_ObjCSelectorName) {
+ CurrentPrecedence = 1 + (int)prec::Assignment;
+ if (Precedence == CurrentPrecedence)
+ Start = Current;
+ }
}
// At the end of the line or when an operator with higher precedence is
verifyFormat(
"void f() {\n"
" if ((self = [super initWithContentRect:contentRect\n"
- " styleMask:styleMask\n"
+ " styleMask:styleMask ?: otherMask\n"
" backing:NSBackingStoreBuffered\n"
" defer:YES]))");
verifyFormat(
"[foo checkThatBreakingAfterColonWorksOk:\n"
- " [bar ifItDoes:reduceOverallLineLengthLikeInThisCase]];");
+ " [bar ifItDoes:reduceOverallLineLengthLikeInThisCase]];");
verifyFormat("[myObj short:arg1 // Force line break\n"
- " longKeyword:arg2\n"
- " evenLongerKeyword:arg3\n"
+ " longKeyword:arg2 != nil ? arg2 : @\"longKeyword\"\n"
+ " evenLongerKeyword:arg3 ?: @\"evenLongerKeyword\"\n"
" error:arg4];");
verifyFormat(
"void f() {\n"
"scoped_nsobject<NSTextField> message(\n"
" // The frame will be fixed up when |-setMessageText:| is called.\n"
" [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)]);");
+ verifyFormat("[self aaaaaa:bbbbbbbbbbbbb\n"
+ " aaaaaaaaaa:bbbbbbbbbbbbbbbbb\n"
+ " aaaaa:bbbbbbbbbbb + bbbbbbbbbbbb\n"
+ " aaaa:bbb];");
}
TEST_F(FormatTest, ObjCAt) {