I'm using the google-java-format plugin here: https://github.com/google/google-java-format in my eclipse STS (Version: 4.5.0.RELEASE)
When defining a Camel Java DSL Route , I am trying to ignore the formatter so I can have the following indented code:
@Component
public class MyRoute extends SpringRouteBuilder
{
@Override
public void configure() throws Exception
{
super.configure();
from("direct:myendpointh").routeId("foo")
.setBody().method(MyClass.class, "calc(${body})")
.setHeader("bar").method(BarCalc.class, "compute(${body})")
.choice()
.when().ognl("request.body.isConditionMet")
.to("direct:ConditionalRoute").endChoice()
.otherwise()
.routingSlip(header("mySlip"))
.end();
}
}
Now If I change the formatter from eclipse to google-java-format:
and add the ignore format comments, following the instructions in this post
it still formats with 1 method call per line, and loses the choice() indentation:
@Component
public class MyRoute extends SpringRouteBuilder
{
//@formatter:off
@Override
public void configure() throws Exception
{
super.configure();
from("direct:myendpointh")
.routeId("foo")
.setBody()
.method(MyClass.class, "calc(${body})")
.setHeader("bar")
.method(BarCalc.class, "compute(${body})")
.choice()
.when()
.ognl("request.body.isConditionMet")
.to("direct:ConditionalRoute")
.endChoice()
.otherwise()
.routingSlip(header("mySlip"))
.end();
}
//@formatter:on
}
Is there a way to toggle formatters for a specific file ... e.g. disable google-java-format for certain files requiring method chained indentation?
Looks like they didn't implement that. https://github.com/google/google-java-format/wiki/FAQ#why-cant-i-use-magic-comments-to-disable-formatting-for-certain-sections-of-code