user3247895
user3247895

Reputation: 515

Configuration for newLine for block parameter in Uncrustify formatter

I want to know as if there exists configuration in Uncrustify, so that following formatting(or at least some part of it) can be achieved(language is objective-c).

Original code:

@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)   {

Desired code after formatting:

@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) {

Changes which need to be observed after formatting:

  1. There is space between 'if' and '(', but I don't want space between 'BaseVideoViewController' and '('.
  2. I dont want space between interface name i.e. 'BaseVideoViewController' and ':'.
  3. I want space between data-type and angular bracket('<') in interface or property definition, but not at other places in code.
  4. Notice the change in break statement.
  5. When calling function, I want parameters to come into new line, if that parameter has value starting from '^'(parameter named animations, completions in above code).

Upvotes: 0

Views: 170

Answers (1)

CDanU
CDanU

Reputation: 181

Uncrustify-0.65-106-95188777

  1. It does not seem like there is an option for that currently
  2. sp_before_class_colon = remove
  3. See 1, there are however (way) more generic options like for example sp_before_angle and sp_inside_angle
  4. mod_move_case_break = true should do that, but it does not seem to work for OC. It also does not work with your example for C++ unless Break is changed to break and the closing brace is on its own line.
  5. See 1

Submit Feature and Pull requests to the Uncrustify git repo

Upvotes: 1

Related Questions