forked from OSchip/llvm-project
clang-format: Improve formatting of ObjC method expressions.
In particular, make breaking after a parameter's ":" more of a last resort choice as it significantly affects the readability gained by aligning the parameters. Before (in Chromium style - which doesn't allow bin-packing): { popup_window_.reset([[RenderWidgetPopupWindow alloc] initWithContentRect: NSMakeRect( origin_global.x, origin_global.y, pos.width(), pos.height()) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); } After: { popup_window_.reset([[RenderWidgetPopupWindow alloc] initWithContentRect:NSMakeRect(origin_global.x, origin_global.y, pos.width(), pos.height()) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); } llvm-svn: 195301
This commit is contained in:
parent
29b8fc4da9
commit
a78d7d4502
|
@ -1181,7 +1181,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
|
|||
if (Right.Type == TT_ObjCSelectorName)
|
||||
return 0;
|
||||
if (Left.is(tok::colon) && Left.Type == TT_ObjCMethodExpr)
|
||||
return 50;
|
||||
return 500;
|
||||
|
||||
if (Left.is(tok::l_paren) && InFunctionDecl)
|
||||
return 100;
|
||||
|
|
|
@ -5520,6 +5520,17 @@ TEST_F(FormatTest, FormatObjCMethodExpr) {
|
|||
" der:NO]);\n"
|
||||
"}",
|
||||
getLLVMStyleWithColumns(70));
|
||||
verifyFormat("{\n"
|
||||
" popup_window_.reset([[RenderWidgetPopupWindow alloc]\n"
|
||||
" initWithContentRect:NSMakeRect(origin_global.x,\n"
|
||||
" origin_global.y,\n"
|
||||
" pos.width(),\n"
|
||||
" pos.height())\n"
|
||||
" styleMask:NSBorderlessWindowMask\n"
|
||||
" backing:NSBackingStoreBuffered\n"
|
||||
" defer:NO]);\n"
|
||||
"}",
|
||||
getChromiumStyle());
|
||||
verifyFormat("[contentsContainer replaceSubview:[subviews objectAtIndex:0]\n"
|
||||
" with:contentsNativeView];");
|
||||
|
||||
|
|
Loading…
Reference in New Issue