Repository navigation
Extra newlines on type annotations #1
Description
Activity
I think it is a bug. Part of the point of in-line mode annotations (vs.
vertical mode annotations) is supposed to be no longer forcing extra line
breaks.On Fri, May 15, 2015 at 7:00 AM, Jesse Wilson [email protected]
wrote:Input: one group of fields:
private DbIncomingEmail incomingEmail; private CreationMechanism creationMechanism; private @Nullable String creationUserAgent; private ClientId clientId; private Token externalId;Output: three groups of fields, because the 3rd field has @nullable.
private DbIncomingEmail incomingEmail; private CreationMechanism creationMechanism; private @Nullable String creationUserAgent; private ClientId clientId; private Token externalId;Is this a bug?
—
Reply to this email directly or view it on GitHub
#1.Kevin Bourrillion | Java Librarian | Google, Inc. | [email protected]
Note there is a slight wrinkle, though.
The formatter cannot always tell whether an annotation is a type annotation
or not. It will have to use a pretty gross heuristic. But for now, Google
isn't on Java 8 yet, so it's going to always assume they are not type
annotations (because they can't be), but of course it won't go so far as to
physically move them before the modifiers, so that people in your situation
won't get annoyed. At some point we will have to turn that on and, well,
Liam could show you the proposal for how to guess at whether something is a
type annotation or not...On Fri, May 15, 2015 at 7:06 AM, Kevin Bourrillion [email protected]
wrote:I think it is a bug. Part of the point of in-line mode annotations (vs.
vertical mode annotations) is supposed to be no longer forcing extra line
breaks.On Fri, May 15, 2015 at 7:00 AM, Jesse Wilson [email protected]
wrote:Input: one group of fields:
private DbIncomingEmail incomingEmail; private CreationMechanism creationMechanism; private @Nullable String creationUserAgent; private ClientId clientId; private Token externalId;Output: three groups of fields, because the 3rd field has @nullable.
private DbIncomingEmail incomingEmail; private CreationMechanism creationMechanism; private @Nullable String creationUserAgent; private ClientId clientId; private Token externalId;Is this a bug?
—
Reply to this email directly or view it on GitHub
#1.Kevin Bourrillion | Java Librarian | Google, Inc. | [email protected]
Kevin Bourrillion | Java Librarian | Google, Inc. | [email protected]
I created #5 to track possible heuristics for type annotations.
I'm working on a fix for this issue that will suppress the blank lines unless the annotations end up being formatted vertically.
a7cd9c5 was buggy, and would do things like format:
class Test { @Nullable int x = 1; @Nullable int y = 2; @Nullable int z = 2; }
into:
class Test { @Nullable int x = 1; @Nullable int y = 2; @Nullable int z = 2; }
All known badness with blank lines around annotated field declarations has been fixed by fb109b9, so please file bugs if you see other issues with that.
- added a commit that references this issue
on Jan 17, 2026
Input: one group of fields:
Output: three groups of fields, because the 3rd field has
@Nullable.Is this a bug?