HomePhabricator

[clang-format] Add option for not breaking line before ObjC params

Authored by MyDeveloperDay on Feb 1 2020, 9:37 AM.

Description

[clang-format] Add option for not breaking line before ObjC params

Summary:
From clang-format version 3.7.0 and up, , there is no way to keep following format of ObjectiveC block:

- (void)_aMethod
{
    [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
        u = c;
    }]
}

Regardless of the change in .clang-format configuration file, all parameters will be lined up so that colons will be on the same column, like following:

- (void)_aMethod
{
    [self.test1 t:self
                w:self
         callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
             u = c;
         }]
}

Considering with ObjectiveC, the first code style is cleaner & more readable for some people, I've added a config option: ObjCDontBreakBeforeNestedBlockParam (boolean) so that if it is enable, the first code style will be favored.

Reviewed By: MyDeveloperDay

Patch By: ghvg1313

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D70926

Details