Apache Camel and Intellij Idea format

Intellij Idea formats the code on camel routes as follows:

from("direct:loop") .log("Loop: ${header[loopCount]}") .choice() .when(simple("header[loopCount] < 10")) .process(exchange -> { Message in = exchange.getIn(); in.setHeader("loopCount", in.getHeader("loopCount", Integer.class) + 1); }) .to("direct:loop") .otherwise() .log("Exiting loop") .end(); 

Are there any plugins or other ways to do this:

 from("direct:loop") .log("Loop: ${header[loopCount]}") .choice() .when(simple("header[loopCount] < 10")) .process(exchange -> { Message in = exchange.getIn(); in.setHeader("loopCount", in.getHeader("loopCount", Integer.class) + 1); }) .to("direct:loop") .otherwise() .log("Exiting loop") .end(); 

?

+5
source share
2 answers

I don’t think there is still a good plugin that can format Java DSL code as desired.

In the best case, we can disable the formatting of individual parts of the DSL in Java code. I would recommend using the on / off formatting function in IntelliJ IDEA for Camel DSL routes:

 // @formatter:off ... // @formatter:on 

Formatter Control parameters can be found in Preferences... β†’ Editor β†’ Code Style (starting from 2017.2.3).

Refer to other StackOverflow questions, such as this, for more information on the IntelliJ function:
How to disable code formatting for some part of the code using comments?

+6
source

There is a ticket for the Camel IDEA plugin: https://github.com/camel-idea-plugin/camel-idea-plugin/issues/309

You can use +1 to indicate your wish.

I personally would also like to have this opportunity, but I did not have much free time to work on this, since I do regular work, and also end my Camel book.

+5
source

Source: https://habr.com/ru/post/1272348/


All Articles