I am unable to find these line wrapping rules for the Eclipse code formatter:
- Not starting new lines with "throws" (since easily mistaken for "throw")
- Not starting new lines with dots (e.g. when method chaining)
Have I missed those or don't they exist? Here are a few examples what the standard formatter produces and what i would like to have as a result:
Method definition: Line wrapping for closing parentheses in front of throws
Standard:
String someMethodWithARatherLongName(String someParameter)
throws Exception;
Desired:
String someMethodWithARatherLongName(String someParameter
) throws Exception;
Method chaining: Line wrapping
Standard:
return new StringBuilder("Hello ").append(name)
.append(", how are you today?").toString();
Desired:
return new StringBuilder("Hello ").append(name).append(
", how are you today?").toString();
or:
return new StringBuilder("Hello ").append(name
).append(", how are you today?").toString();
Any specific help regarding these settings would be much appreciated!
You can achieve this with
Line Wrapping -> Method Declaration -> 'throws' clause
. ChangeLine Wrapping Policy
toDo not wrap
and the throws clause will be on the same line as the Method Declaration. You can do this for the Constructor Declaration too.It seems like this isn't possible in Eclipse, but I'd appreciate such a setting too.