IntelliJ IDEA keeps amazing me. Last week I learned the code formatter of IntelliJ IDEA 12 supports Spock specific where:
block formatting. Spock has great a great feature called data tables. We can define a fixed set of data values in a table-like format where cells are separated with pipe (|
) symbols. These tables are easiest to read if formatted in fixed size columns. The IntelliJ IDEA formatter will do this for us automatically.
Look at the following source code with a data table just typed with pipe symbols as separators, but not clearly formatted in fixed size columns:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj20fiYvVuYhLLMel4sHhyphenhyphenD786GkKSkHDtbL1J-Yj2y4wYp9UNxWj9dU0dtZNE_BgCzSfXl_aZXU_sXOjC90E1lrVTjfcJxQIxBdLkYq25p-F9eHwwj8Uvc53LhlzP_-FKNaMMxUkINB3Q/s1600/spock-unformatted1.png)
If we run the code reformat command with Cmd+Alt+L (Windows/Linux: Ctrl+Alt+L) or use the menu option Code | Reformat Code... we get a dialog and select Run button to format the code:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqOykRkEOd5nFFYvTWdlbN4jP0q_v1AVOxsNzKhGbv13d3if0CtW_0KLu8Kv4j04M9bosCqgMSEwrRa0UaC7br-I1IqQEt6Wmcrg3-AuPxlCxN_BE2N4rVmT7y-cTfPsyLlgQlPUPK4eFQ/s1600/spock-format.png)
The result is that our data table in the where:
block is now correctly formatted:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhccn9iaoo7iZahFmpcZ2hCNOhLAux2lwi8zeuIZM3JMP_HqIpNvgBPSgQqsYAbQKrjggVHYd-XnmVgshDW5dUY_ZGYTbAZU2T1GZN9qo_hHz3tif_QMbNT1iEGHPU4YMG7lQG8GvtWBMAZ/s1600/spock-formatted1.png)
Example with IntelliJ IDEA 12.1