clang-format doesn't handle single-statement Java lambdas very well |
||
Issue description
clang-format produced code that (choose all that apply):
X Doesn't match Chromium style
- Doesn't match blink style
X Riles my finely honed stylistic dander
- No sane human would ever choose
Here's the code before formatting:
paramName -> {
doSomething();
}
Here's the code after formatting:
paramName -> { doSomething(); }
Here's how it ought to look:
paramName -> doSomething()
Code review link for full files/context:
clank-team discussion: https://groups.google.com/a/google.com/forum/#!topic/clank-team/hKuyfkrPKcE
Example CL I encountered this on: https://chromium-review.googlesource.com/c/chromium/src/+/624996/3/android_webview/javatests/src/org/chromium/android_webview/test/SafeBrowsingTest.java#1023
In my example, I want to write a Java lambda for ValueCallback<Boolean> [1], which accepts a Boolean and returns void. I only need my lambda to call another void method (doSomething) for its side effects.
Our style guide [2] is vague on what to do for single-statement lambdas, however I suspect the "code after formatting" breaks chromium style because `git cl presubmit` gives the error:
'{' at column 14 should have line break after
We discussed this in the thread linked above, and nobody raised a strong opinion on "correct" stylistic format. Given that, I think acceptable solutions would be any of:
* change clang-format to produce the "ought to look" output
* relax git cl presubmit checks here, or
* disable clang-format for this case
[1] https://developer.android.com/reference/android/webkit/ValueCallback.html
[2] https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md
,
Oct 26 2017
|
||
►
Sign in to add a comment |
||
Comment 1 by thakis@chromium.org
, Sep 25 2017