This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I like the idea of the "Add Override Annotation" hint, but I never use it (I type in the annotation by hand) because I don't like the resulting formatting. It is only a historical accident that @Override is an annotation rather than part of the Java language syntax. (In C# it is a keyword.) I would prefer it to be treated as a modifier, e.g.: protected @Override void setUp() throws Exception {...} However there is no such formatting option available.
*** Issue 117934 has been marked as a duplicate of this issue. ***
Worse, if you by hand write protected @Override void initialize() { super.initialize(); } and reformat, you get protected @Override void initialize() { super.initialize(); } which looks silly.
@Override protected void initialize() { super.initialize(); } works a bit better; at least Reformat will not touch this (unless Wrapping on Annotations is set to Always). However code generation will create @Override protected void initialize() { super.initialize(); } and Reformat will not fix it.
(In reply to comment #3) > code generation will create ImplementOverrideMethodGenerator I guess. Not sure how to fix that. > Reformat will not fix it. This part I can fix.
Created attachment 109154 [details] Proposed fix This patch implements inline @Override unconditionally; not sure if it should rather be an option?
There are certain other annotations, such as @CheckForNull, which are used as type qualifiers on methods and fields and so ought to be formatted inline as well, since they logically belong right next to the type. Not sure how to distinguish these from annotations such as @SuppressWarnings or @Deprecated which semantically apply to the entire member; could hardcode a list of them, or check for @TypeQualifier or @TypeQualifierNickname. (Certainly if the annotation follows an access modifier then we know inline formatting is appropriate, but this will not help in the case of package-private members.)
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/4f3760d0cbb1 User: Jesse Glick <jglick@netbeans.org> Log: @Override was getting reformatted badly (see #104757).