'Put each statement in if-clause on new line in Eclipse
In Eclipse formatter for Java how can I format if-statements like
if (x != null
&& x.getSomething() != null
&& x.getSomething().getSomethingMore()) {
y.doSomething();
}
if they exceed the max line width (each statement on new line!). I thought it should be done with
but somehow I am wrong. Result:
if (x != null && x.getSomething() != null
&& x.getSomething().getSomethingMore()) {
y.doSomething();
}
Solution 1:[1]
I'd recommend you to select the following options:
- Wrap all elements, every element on a new line
I do:
- Wrap before operators
- Wrap all elements, every element on a new line
- Force split
- Indent by one
Screenshot:
I hope this help you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | AndreasInfo |