Aar*_*her 18 formatting objective-c clang clang-format
我知道人们对如何在Objective-C中格式化方法调用有不同的看法,即
[self presentViewController:scanViewController
animated:YES
completion:nil];
Run Code Online (Sandbox Code Playgroud)
VS
[self presentViewController:scanViewController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
我使用.clang格式文件中的哪些选项来控制这种缩进?(如果我不想要它,冒号排队等)
还有,这只是我还是这个格式无知的块?注意成功块的if语句不是缩进的,NSLog函数也不是故障块.
[self.client getPath:path
parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([from_id isEqualToString:self.from_id]) {
self.image.image = [UIImage imageWithData:responseObject];
}
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(error.description);
}];
Run Code Online (Sandbox Code Playgroud)
Mat*_*ias 10
我查看了clang格式的源代码,其中Objective-c方法表达式的格式化完成并在此处找到:http://llvm.org/svn/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp
代码:
// If this '[' opens an ObjC call, determine whether all parameters fit
// into one line and put one per line if they don't.
if (Current.Type == TT_ObjCMethodExpr &&
getLengthToMatchingParen(Current) + State.Column >
getColumnLimit(State))
BreakBeforeParameter = true;
Run Code Online (Sandbox Code Playgroud)
如您所见,行为仅由配置选项ColumnLimit控制.您可以将其设置为0以抑制换行符.不幸的是,这当然影响了完整的格式.
关于块内缺少缩进的问题:我无法使用最新的Visual Studio插件(SVN r203967)重现它.你有没有摆弄ContinuationIndentWidth?
| 归档时间: |
|
| 查看次数: |
3042 次 |
| 最近记录: |