How to properly debug an interface plugin "correctly" using eclipse?

I just created a generator for some smooth interfaces. Now I have a lot of code looking like this:

new MyFluentInterface() .setFirst( "first" ) .setSecond( "second" ) .setThird( "third" ) .invoke( obj ); 

I like the indentation shown above, but I cannot find a way to properly configure eclipse to indent.

eclipse always has such indentation:

 new MyFluentInterface() .setFirst( "first" ) .setSecond( "second" ) .setThird( "third" ) .invoke( obj ); 

How to configure eclipse so that it departs from this smooth interface, as shown in the first code example?

+46
java eclipse indentation
Nov 13 2018-10-11
source share
1 answer

With Eclipse 3.6, this seems doable by customizing your Java user profile > Code Style> Formatting . Edit it and go to the Line Pack tab and select Feature Call> Skilled Calls . Then, in Settings for qualified calls, configure the following things:

alt text

This (should) lead to the expected result:

 SomeEntity e1 = new SomeEntity.Builder() .age(10) .amount(10.0d) .firstname("foo") .lastname("bar") .build(); 

But this, obviously, will affect all the code that I personally donโ€™t like. Therefore, I use the new Off / On Tags from Eclipse 3.6 (last tab when editing a profile):

alt text

And attach the parts that are not formatted the way I want, and do it yourself:

 // @formatter:off SomeEntity e2 = new SomeEntity.Builder() .age(10) .amount(10.0d) .firstname("foo") .lastname("bar") .build(); // @formatter:on 

Choose your poison :)

+62
Nov 13 2018-10-11
source share



All Articles