Wrapping chained method calls on a separate line in Eclipse for Java

后端 未结 7 1577
南方客
南方客 2020-12-02 05:10

I haven\'t been successful in figuring out how to wrap each method call in Eclipse. For example, I have this:

someObject.A().B().C();

7条回答
  •  心在旅途
    2020-12-02 05:48

    If you are willing to do the formatting of those segments yourself, you can prevent eclipse from reformatting those segments by using:

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

    You might need to enable this in your preferences: http://archive.eclipse.org/eclipse/downloads/drops/R-3.6-201006080911/eclipse-news-part2.html#JavaFormatter

    See also: How to turn off the Eclipse code formatter for certain sections of Java code?

提交回复
热议问题