[git cl format] java: same line type annotations should be allowed |
|
Issue description
private int getTargetSheetState(float sheetHeight, float yVelocity) {
// ...
@SheetState int nextState = sStates[0];
@SheetState int prevState = nextState;
// ...
}
is "corrected" to
private int getTargetSheetState(float sheetHeight, float yVelocity) {
// ...
@SheetState
int nextState = sStates[0];
@SheetState
int prevState = nextState;
// ...
}
The annotation sandwich looks unappealing and not as clear as having the whole variable declaration on a single line. Because git cl now runs as part of presubmit checks, we can't even situationally use the single line notation when it looks better.
Context: https://codereview.chromium.org/2670863004/diff/80001/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java#newcode279
Nico, could you please help triage?
,
Feb 14 2017
There's an exception for this case isn't there? It's the "single parameterless annotation" case.
,
Feb 14 2017
I see single hits for "single parameterless annotation" on https://source.android.com/source/code-style.html#use-standard-java-annotations . I do see one on https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations , but re-read that cl description: "Chromium follows the Android style guide for Java code, and that doesn't make the distinction between fields and non-fields that the Google Java style guide makes". We use android style, not google style, for our java code.
,
Feb 14 2017
Also: "Annotations applying to a field also appear immediately after the documentation block, but in this case, multiple annotations (possibly parameterized) may be listed on the same line; for example: @Partial @Mock DataLoader loader; There are no specific rules for formatting annotations on parameters, local variables, or types." The last paragraph is the one that is most relevant for this report.
,
Feb 14 2017
That, too, is cited from the wrong guide.
,
Feb 14 2017
sorry, didn't see #c3 earlier. Makes #c4 irrelevant. Still, the android style says: "Simple marker annotations (e.g. @Override) can be listed on the same line with the language element." |
|
►
Sign in to add a comment |
|
Comment 1 by thakis@chromium.org
, Feb 14 2017Status: WontFix (was: Assigned)
Summary: [git cl format] java: same line type annotations should be allowed (was: [git cl format] same line type annotations should be allowed)