You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: news/4.34/jdt.html
+21Lines changed: 21 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,27 @@ <h2>Java Editor </h2>
76
76
<p><imgsrc="images/ifelseboolean-after.png" alt="convert boolean if/else to single return after"/></p>
77
77
</td>
78
78
</tr>
79
+
<trid="unused-to-unnamed-quickfix">
80
+
<tdclass="title"><ahref="#unused-to-unnamed-quickfix">Rename unused to unnamed quickfix/cleanup</a></td>
81
+
<tdclass="content">
82
+
The quick-fix/clean-up for unused local variables has been enhanced when using Java 22 or above to rename to the unnamed variable ("_") where appropriate. These situations include:
83
+
<ul>
84
+
<li>unused lambda parameters</li>
85
+
<li>unused try-with-resources resources</li>
86
+
<li>unused pattern variables in switch</li>
87
+
<li>unused variables in enhanced for statement</li>
88
+
<li>unused variables in regular for statement</li>
89
+
</ul>
90
+
<p>In these cases, a quick-fix will be offered to rename to the unnamed variable. The quick-fix is a multi-fix and will also offer to fix multiple instances of the problem.</p>
91
+
<p>For example, hovering one of the unused variables in the file will show:</p>
92
+
<p><imgsrc="images/unnamed-quickfix-before.png" alt="rename to unnamed variable before"/></p>
93
+
<p>and selecting to fix multiple problems of the same category results in:</p>
94
+
<p><imgsrc="images/unnamed-quickfix-after.png" alt="rename to unnamed variable after"/></p>
95
+
<p>The new rename functionality is embedded into the existing <b>Remove unused local variables</b> clean-up found on the <b>Unnecessary Code</b> tab of the clean-up configuration dialog. The clean-up
96
+
will rename to the unnamed variable for unused locals or lambda parameters when
97
+
the compliance level is 22 or above.</p>
98
+
</td>
99
+
</tr>
79
100
<trid="if-else-to-switch-null-handling">
80
101
<tdclass="title"><ahref="#if-else-to-switch-null-handling">Null handling for if/else to switch clean-up</a></td>
0 commit comments