llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.82k forks source link

clang-format for ObjC should support ContinuationIndentWidth from the beginning of the first non whitespace character. #20000

Open llvmbot opened 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 19626
Version trunk
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

current output of clang-format -style="{ColumnLimit: 80, ContinuationIndentWidth: 4}"

[scenario cr_add:[KIFTestStep
                     stepToTapViewWithAccessibilityIdentifier:@"identifier12"]];

desired output:

[scenario cr_add:[KIFTestStep
    stepToTapViewWithAccessibilityIdentifier:@"identifier12"]];

The latter output is the current style used in chromium.

llvmbot commented 9 years ago

This would also be very useful for code like this:

[motion startDeviceMotionUpdatesToQueue:queue
                            withHandler:^(CMDeviceMotion* devData, NSError* error) {

                            CMAttitude* attitude = devData.attitude;
                            // ...
                            }];

Setting ObjCBlockIndentWidth to 0 doesn't help much. And since function names are quite verbose, code starts to get squished to the right side, while a lot of space is wasted on the left.

llvmbot commented 10 years ago

The current style is very prone to code being squished to the right side of the available area.

e.g.

  [scenario cr_add:[KIFTestStep stepToTapViewWithAccessibilityLabel:
                                    l10n_util::GetNSString(
                                        IDS_NAVIGATION_BAR_EDIT_BUTTON_IOS)]];

would be clearer as

  [scenario cr_add:[KIFTestStep stepToTapViewWithAccessibilityLabel:
      l10n_util::GetNSString(IDS_NAVIGATION_BAR_EDIT_BUTTON_IOS)]];