Community
Participate
Working Groups
While the eclipse JDT code formatter is definitely excellent and has gone a *long* way there are still a few things that I can not tweak to my liking, esp. re. line wrapping: 1.) Method arguments: I still miss an option that allows me to wrap all but the first argument, i.e. even if a line is too long I would like to see: // max. length, say, here ---| int someLongMethodName(int foo, // (1) boolean bar, // (2) someType yetAnotherArg) { ... } Remarks: (1) the 1st arg should always remain with the method name even if it exceeds the max. line length (2) all following lines are wrapped and "indented on column", again not mattering whether they exceed the max. line length or not. The closest approach I was able to so far yields: ---------- ... int someLongMethodName( int foo, boolean bar, someType yetAnotherArg) { ... } ... ---------- but I *hate* that linebreak for the first argument. The first arg. should remain on the same line! Similar for the qualified method invocation. I don't see the point in the following formatting (which is what I get now): ---------- ... // max. length, say, here ------------------| someIdentifier(someArg).someFieldName .someMethodName( foo, bar) .otherMethod(arg0, arg1); ... ---------- That should either be: ---------- ... someIdentifier(someArgHere).someFieldName .someMethodName(foo, bar) .otherMethod(arg0, arg1); ... ---------- (i.e. indenting all on the first qualification-'.' and wrapping args if necessary) or: ---------- ... someIdentifier(someArg).someFieldName.someMethodName(foo, bar).someMethod(arg0, arg1); ... ---------- (i.e. ignoring the max. line length for the qualifications and only wrapping the arguments, but those in the style described above). Michael
*** This bug has been marked as a duplicate of 59891 ***
This issue will be considered separately from bug 59891.
Hence reopen...
Looks like this task is about "Wrap all elements, except first if not necessary" wrapping policy, which was added a long time ago.
Verified for 4.7 M2 using I20160912-2000 build. Just one observation though - the policy gives different results for MethodDeclarations and qualified invocations, so formatting the example below with the line wrapping policy set to "Wrap all elements, except first if not necessary" , the declaration looks as expected but the invocation doesn't have all arguments wrapped. public class Test { Test t = new Test(); public void someMethodDeclarationWithAVeryLongNameThatExceedsLineLength(int first, boolean second, Runnable third) { // } public void foo() { if (true) { this.t.someMethodDeclarationWithAVeryLongNameThatExceedsLineLength( 0, false, () -> { }); } } }