【问题标题】:Configuration for newLine for block parameter in Uncrustify formatterUncrustify 格式化程序中块参数的 newLine 配置
【发布时间】: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) {

格式化后需要注意的变化:

  1. 'if' 和 '(' 之间有空格,但我不希望 'BaseVideoViewController' 和 '(' 之间有空格。
  2. 我不希望接口名称之间有空格,即“BaseVideoViewController”和“:”。
  3. 我希望接口或属性定义中的数据类型和尖括号('
  4. 注意 break 语句的变化。
  5. 调用函数时,我希望参数进入新行,如果该参数的值从 '^' 开始(名为动画的参数,上述代码中的完成)。

【问题讨论】:

    标签: objective-c format uncrustify


    【解决方案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提交功能和拉取请求

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-27
    • 2012-05-28
    • 1970-01-01
    • 1970-01-01
    • 2014-10-15
    • 2021-05-31
    相关资源
    最近更新 更多