Written by Rudy D'hauwe on August 8, 2013.
As of version 3.6 Eclipse allows you to selectively turn off code formatting for certain sections of Java code by using a special @formatter comment.
// @formatter:off ... // @formatter:on
Because Whizu uses a fluent builder API, it comes in handy to be able to selectively turn off the code formatter for readability purposes. Here's an example.
// @formatter:off HeaderBuilder.create() .title("Tournament") .button("Add player") .onClick(playerList.addEvent()) .build() .build() .on(page); // @formatter:on
Without being able to selectively turn off the code formatter, this piece of code would be auto-formatted by Eclipse as follows.
HeaderBuilder.create().title("Tournament").button("Add player") .onClick(playerList.addEvent()).build().build().on(page);
The @formatter on/off feature has to be turned “on” in Eclipse preferences.
Window > Eclipse preferences > Java > Code Style > Formatter
Click on the “Edit” button, the “Off/On Tags” tab, and check “Enable Off/On tags”.