Reputation: 4462
I have the following code in a Java file within Eclipse:
@Annotation({"arg1", "arg2"})
public void method() {
...
}
I have an issue whereby CheckStyle dislikes that particular formatting and warns that:
Whitespace Around: '}' is not preceded with whitespace.
However the eclipse formatter will not allow me to add any whitespace and will remove it whenever I format.
If I just wanted to remove the warning then I would have to disable the Whitespace Around
rule for }
within CheckStyle, but then it won't warn me when I screw up in other places, so don't want to do that.
The authors of CheckStyle have added the option I would need, by allowing you to ignore Annotation Array Initialization curlies as it does for Array Initialization outside of annotations. However, CheckStyle have not released a new version with the update and have no roadmap for when they will do so.
In any case, lets say that I agree with CheckStyle and would like a space before the }
, how can I configure the formatter with my preference, or at the least, to not care about this issue?
I am aware of @formatter:off
, I am hoping for a one off solution in the formatter configuration, not something I have to use every time I use an array within an annotation.
Upvotes: 2
Views: 1186
Reputation: 349
Check your settings under Preferences
-> Java
-> Code Style
-> Formatter
. Then Edit
your active profile and check under White Space
-> Arrays
-> Array initializers
.
There you can tell Eclipse to use White Space
characters before and after the brackets.
Upvotes: 2