OSDN Git Service

[clang-format] Add option for not breaking line before ObjC params
authormydeveloperday <mydeveloperday@gmail.com>
Sat, 1 Feb 2020 17:37:25 +0000 (17:37 +0000)
committerpaulhoad <mydeveloperday@gmail.com>
Sat, 1 Feb 2020 17:39:34 +0000 (17:39 +0000)
commit70c98671fa7b395a52829b91782393f4c2613562
tree4a951e25d741acaa7ff8c9544ae5cc89e867b94c
parent1544cf2d7cecf61cf3a7d309b7a9fc92ef77c34a
[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
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTestObjC.cpp