【发布时间】:2017-08-14 13:41:55
【问题描述】:
我想知道Uncrustify中是否存在配置,以便可以实现以下格式(或至少部分格式)(语言为objective-c)。
原码:
@interface BaseVideoViewController : BaseViewController <UICollectionViewDelegate, UICollectionViewDataSource, CircleTransitionFromController, PassiveUserGifCellDelegate, PassiveUserCollectionViewDelegate>
@property (strong, nonatomic) NSMutableArray <TokBoxParticipants *> *currentPassivePlayersArray;
@interface BaseVideoViewController () {
NSMutableArray <NSString *> *passiveUserForCellList;
}
[UIView animateWithDuration:1.0 parama1:2.0 animations:^{
// oc_block should come down if in same line by formatter
}
completion:^(BOOL finished) {
// something
}];
switch (something.state) {
case 0: {}
Break;
}
if (_voiceTextView == nil) {
格式化后所需的代码:
@interface BaseVideoViewController: BaseViewController <UICollectionViewDelegate, UICollectionViewDataSource, CircleTransitionFromController, PassiveUserGifCellDelegate, PassiveUserCollectionViewDelegate>
@property (strong, nonatomic) NSMutableArray <TokBoxParticipants *> *currentPassivePlayersArray;
@interface BaseVideoViewController() {
NSMutableArray<NSString *> *passiveUserForCellList;
}
[UIView animateWithDuration:1.0 parama1:2.0
animations:^{
// oc_block should come down if in same line by formatter
}
completion:^(BOOL finished) {
// something
}];
switch (something.state) {
case 0: {
Break;
}
}
if (_voiceTextView == nil) {
格式化后需要注意的变化:
- 'if' 和 '(' 之间有空格,但我不希望 'BaseVideoViewController' 和 '(' 之间有空格。
- 我不希望接口名称之间有空格,即“BaseVideoViewController”和“:”。
- 我希望接口或属性定义中的数据类型和尖括号('
- 注意 break 语句的变化。
- 调用函数时,我希望参数进入新行,如果该参数的值从 '^' 开始(名为动画的参数,上述代码中的完成)。
【问题讨论】:
标签: objective-c format uncrustify