Apache的骆驼和IntelliJ IDEA的代码格式
的IntelliJ IDEA格式代码般地击溃这样的:Apache的骆驼和IntelliJ IDEA的代码格式
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();
是否有任何插件或其他方式来这样做:
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();
?
我不认为这是又一个很好的插件,根据需要,可以格式的Java代码的DSL。
充其量我们只能禁用格式在Java代码中特定的DSL部分。我会建议使用开/关功能的格式化的IntelliJ IDEA的骆驼DSL线路:
// @formatter:off
...
// @formatter:on
可以在Preferences...
找到Formatter Control
设置 - >Editor
- >Code Style
(截至2017年2月3日)。
参见上的IntelliJ功能的其他StackOverflow的问题,像这样的更多细节:
How to disable code formatting for some part of the code using comments?
是的,我以前找到过这个解决方案,但我认为应该有更好的方法来做到这一点。谢谢你的回答。 – well
有一个关于本作的骆驼IDEA插件票:https://github.com/camel-idea-plugin/camel-idea-plugin/issues/309
您可以使用+1以表明它想要的东西。
我个人也想有这样的功能,但没有太多的空余时间在这方面努力,因为我忙于日常工作,也完成我的骆驼书。
见https://www.jetbrains.com/help/idea/configuring-code-style.html。 – Namphibian
关闭选民 - 为什么这是题外话?这是一个关于DSL和编程工具的明确问题。如果你不明白这个问题,请问为什么。 – vikingsteve
@well - 我从来没有找到办法做到这一点,所以只是不要格式化代码。在DSL代码中进行缩进是很好的...只是从不使用自动格式功能。 – vikingsteve