Skip to content

Commit 0d9fe77

Browse files
jjohnstnakurtakov
authored andcommitted
N&N for new clean-up features for 4.34
- eclipse-jdt/eclipse.jdt.ui#1632 - eclipse-jdt/eclipse.jdt.ui#1726
1 parent d76a3ec commit 0d9fe77

File tree

6 files changed

+26
-0
lines changed

6 files changed

+26
-0
lines changed
51.5 KB
Loading
55.1 KB
Loading
41.4 KB
Loading
30.2 KB
Loading
39.7 KB
Loading

news/4.34/jdt.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ <h2>JUnit</h2>
6565
<h2>Java Editor </h2>
6666
</td>
6767
</tr>
68+
<tr id="boolean-if-else-cleanup">
69+
<td class="title"><a href="#boolean-if-else-cleanup">New boolean if/else clean-up</a></td>
70+
<td class="content">
71+
A new clean-up has been created to combine two opposite boolean returns controlled by an if statement into a single return where possible.
72+
<p>To use the clean-up, go to the <b>Code Style</b> tab of the clean-up configuration dialog under <b>Control statements</b> and select: <b>Simplify boolean if/else to single return if possible</b>.</p>
73+
<p>For example, applying the clean-up to the following code:</p>
74+
<p><img src="images/ifelseboolean-before.png" alt="convert boolean if/else to single return before"/></p>
75+
<p>results in:</p>
76+
<p><img src="images/ifelseboolean-after.png" alt="convert boolean if/else to single return after"/></p>
77+
</td>
78+
</tr>
79+
<tr id="if-else-to-switch-null-handling">
80+
<td class="title"><a href="#if-else-to-switch-null-handling">Null handling for if/else to switch clean-up</a></td>
81+
<td class="content">
82+
The if/else to switch clean-up has been enhanced to properly handle the case where the value can be null. In the if/else statement, this is handled intrinsically either by an else statement or falling through the if/else if, but when converting to a switch statement, either the switch must be embedded in an if statement to test for null or for Java 21 or above, a <b>case null</b> statement needs to be added.
83+
<p>The clean-up is accessed on the <b>Code style</b> tab of the clean-up configuration dialog under <b>Control statements</b> and selecting: <b>Convert if/else if/else chain with 3 blocks min to switch</b>.</p>
84+
<p>Applying the clean-up to the following code:<p>
85+
<p><img src="images/ifelse-to-switch-null-before.png" alt="convert if/else to switch before"/></p>
86+
<p>results in the following when Java version is less than 21</p>
87+
<p><img src="images/ifelse-to-switch-null-after.png" alt="convert if/else to switch after"/></p>
88+
<p>and results in the following when the Java release is set to 21 and up:</p>
89+
<p><img src="images/ifelse-to-switch-null-21-after.png" alt="convert if/else to switch after for Java 21 and up"/></p>
90+
91+
</td>
92+
</tr>
93+
6894
<!-- ******************* End of Java Editor ************************************* -->
6995

7096
<!-- ******************* Java Views and Dialogs ************************************* -->

0 commit comments

Comments
 (0)