2017-08-14 47 views
0

我想知道在Uncrustify中是否存在配置,以便可以实现格式化(或至少某些部分)(语言是objective-c)。Uncrustify格式化程序中newLine for block参数的配置

原始代码:

格式化后
@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) { 

在格式化之后被观察到的变化:

  1. 有 '如果' 和'之间的空间(',但我不想在'BaseVideoViewController'和'('之间留出空间。
  2. 我不希望接口名称,即'BaseVideoViewController'和':'之间的空间。
  3. 我想在接口或属性定义中的数据类型和角括号('<')之间的空间,但不是在代码中的其他地方。
  4. 注意break语句的更改。
  5. 当调用函数时,如果参数的值从'^'(参数名称动画,上面代码中的完成)开始,我希望参数进入换行。

回答

1

Uncrustify-0.65-106-95188777

  1. 它似乎并不像有该选项目前
  2. sp_before_class_colon = remove
  3. 见1,然而有(方式)更通用的选项例如sp_before_anglesp_inside_angle
  4. mod_move_case_break = true应该这样做,但它似乎不适用于OC。它也不适用于C++的示例,除非Break更改为break,并且右大括号位于其自己的行上。
  5. 见1

提交功能,并引入请求到Uncrustify git repo

+0

谢谢你的投入和时间。你可以看看这个问题[链接](https://stackoverflow.com/questions/45772985/uncrustify-objective-c-parameter-value-alignment-indentation)也与uncrustify有关。 – user3247895