forked from OSchip/llvm-project
clang-format: [ObjC] Wrap ObjC method declarations before annotations.
Before: - (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x y:(id<yyyyyyyyyyyyyyyyyyyy>) y NS_DESIGNATED_INITIALIZER; After: - (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x y:(id<yyyyyyyyyyyyyyyyyyyy>)y NS_DESIGNATED_INITIALIZER; llvm-svn: 219564
This commit is contained in:
parent
30bdfa7f99
commit
ec8e838baa
|
@ -1432,6 +1432,11 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
|
|||
|
||||
if (Right.Type == TT_TrailingAnnotation &&
|
||||
(!Right.Next || Right.Next->isNot(tok::l_paren))) {
|
||||
// Moving trailing annotations to the next line is fine for ObjC method
|
||||
// declarations.
|
||||
if (Line.First->Type == TT_ObjCMethodSpecifier)
|
||||
|
||||
return 10;
|
||||
// Generally, breaking before a trailing annotation is bad unless it is
|
||||
// function-like. It seems to be especially preferable to keep standard
|
||||
// annotations (i.e. "const", "final" and "override") on the same line.
|
||||
|
|
|
@ -6452,6 +6452,10 @@ TEST_F(FormatTest, FormatObjCMethodDeclarations) {
|
|||
" evenLongerKeyword:(float)theInterval\n"
|
||||
" error:(NSError **)theError {\n"
|
||||
"}");
|
||||
verifyFormat("- (instancetype)initXxxxxx:(id<x>)x\n"
|
||||
" y:(id<yyyyyyyyyyyyyyyyyyyy>)y\n"
|
||||
" NS_DESIGNATED_INITIALIZER;",
|
||||
getLLVMStyleWithColumns(60));
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, FormatObjCMethodExpr) {
|
||||
|
|
Loading…
Reference in New Issue