簡體   English   中英

google-java-format eclipse 插件忽略格式化程序:關閉評論

[英]google-java-format eclipse plugin ignoring formatter:off comments

我在這里使用 google-java-format 插件: https : //github.com/google/google-java-format in my eclipse STS (Version: 4.5.0.RELEASE)

在定義 Camel Java DSL Route 時,我試圖忽略格式化程序,因此我可以使用以下縮進代碼:

@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();
  }
}

現在,如果我將格式化程序從 eclipse 更改為 google-java-format:

在此處輸入圖片說明

添加忽略格式的注釋,按照說明這個帖子

仍然使用每行 1 個方法調用進行格式化,並且丟失了 choice() 縮進:

@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
}

有沒有辦法為特定文件切換格式化程序......例如,為某些需要方法鏈縮進的文件禁用google-java-format?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM