diff options
author | Fabrice Tiercelin | 2020-10-06 13:38:40 +0000 |
---|---|---|
committer | Fabrice Tiercelin | 2020-10-06 13:38:40 +0000 |
commit | 2996363b6f98c355ff1cd9d091515e538746e2f4 (patch) | |
tree | 98de8a09f6703c3321f6254c3c26b1fa4dfb2c46 | |
parent | 6fbae9a1828b44e618bcda7aa0f99fbb3f55f2e4 (diff) | |
download | news-2996363b6f98c355ff1cd9d091515e538746e2f4.tar.gz news-2996363b6f98c355ff1cd9d091515e538746e2f4.tar.xz news-2996363b6f98c355ff1cd9d091515e538746e2f4.zip |
Bug 567264 - [AutoRefactor immigration #23/136] [cleanup & saveaction]
Use Arrays.fill()
Change-Id: I08d2071797d8147d76bbb7937260a6e0ee033a41
Signed-off-by: Fabrice Tiercelin <fabrice.tiercelin@yahoo.fr>
Depends-On: I54b0388fc39f0de2cc2851c85502c5b0cf458f7e
-rw-r--r-- | 4.18/images/arrays-fill-after.png | bin | 0 -> 9479 bytes | |||
-rw-r--r-- | 4.18/images/arrays-fill-before.png | bin | 0 -> 7360 bytes | |||
-rw-r--r-- | 4.18/jdt.html | 45 |
3 files changed, 33 insertions, 12 deletions
diff --git a/4.18/images/arrays-fill-after.png b/4.18/images/arrays-fill-after.png Binary files differnew file mode 100644 index 00000000..56e06711 --- /dev/null +++ b/4.18/images/arrays-fill-after.png diff --git a/4.18/images/arrays-fill-before.png b/4.18/images/arrays-fill-before.png Binary files differnew file mode 100644 index 00000000..fa028a3d --- /dev/null +++ b/4.18/images/arrays-fill-before.png diff --git a/4.18/jdt.html b/4.18/jdt.html index 81655752..79d694e5 100644 --- a/4.18/jdt.html +++ b/4.18/jdt.html @@ -123,12 +123,12 @@ ul {padding-left: 13px;} <td class="content"> A new quick-assist and clean up has been added that converts switch statements to new switch expressions (Java 14 or higher) where possible. <p> - Switch statements that use control statements such as nested switch statements, if/else blocks, for/while loops are not considered as is the case - for return/continue statements. All cases - of the switch statement must either have a last assignment statement that sets the same variable/field as other cases or else has a <b>throw</b> statement. - Fall-through is allowed between cases but only if there are no other statements between. The - switch statement must have a <b>default</b> case unless the switch expression - is an enum type and all possible enum values are represented in the cases. + Switch statements that use control statements such as nested switch statements, if/else blocks, for/while loops are not considered as is the case + for return/continue statements. All cases + of the switch statement must either have a last assignment statement that sets the same variable/field as other cases or else has a <b>throw</b> statement. + Fall-through is allowed between cases but only if there are no other statements between. The + switch statement must have a <b>default</b> case unless the switch expression + is an enum type and all possible enum values are represented in the cases. </p> <p> To select the quick-assist, click <b>CTRL+1</b> on the targeted switch statement and select <b>Convert to switch expression</b> if offered. @@ -153,14 +153,14 @@ ul {padding-left: 13px;} <td class="content"> A new clean up has been added that uses <code>Collection.addAll()</code>, <code>Collection.removeAll()</code>, <code>Collections.addAll()</code> or <code>Collections.removeAll()</code> instead of a <code>for</code> loop. <p> - It refactors <code>for</code> loops with index, <code>for</code> loops with iterator and <code>foreach</code> loops. + It refactors <code>for</code> loops with index, <code>for</code> loops with iterator and <code>foreach</code> loops. </p> <p> - It only uses <code>Collection.removeAll()</code> on <code>Set</code> because the behavior may change on list with double values. + It only uses <code>Collection.removeAll()</code> on <code>Set</code> because the behavior may change on list with double values. </p> <p> - If the source is an array, the list is raw and the JVM is Java 1.5 or higher, we use Arrays.asList() to handle the erasure type. - It doesn't decrease the performance. + If the source is an array, the list is raw and the JVM is Java 1.5 or higher, we use Arrays.asList() to handle the erasure type. + It doesn't decrease the performance. </p> <p> To select the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog select <b>Add or remove elements in collections without loop</b> box on the <b>Code Style</b> tab. @@ -182,10 +182,10 @@ ul {padding-left: 13px;} <td class="content"> A new clean up has been added that uses pattern matching for the <code>instanceof</code> operator when possible. <p> - It is only enabled for Java 14 or higher enabling the feature preview. + It is only enabled for Java 14 or higher enabling the feature preview. </p> <p> - The variable must be final. + The variable must be final. </p> <p> To select the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog select <b>Pattern matching for instanceof</b> box on the <b>Unnecessary Code</b> tab. @@ -202,6 +202,27 @@ ul {padding-left: 13px;} </td> </tr> + <tr id="arrays-fill"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567264 --> + <td class="title"><a href="#arrays-fill">Use Arrays.fill()</a></td> + <td class="content"> + A new clean up has been added that replaces for loops to use <code>Arrays.fill()</code> where possible. + <p> + The value must be hard-coded. + </p> + <p> + To select the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog select <b>Use Arrays.fill()</b> box on the <b>Unnecessary Code</b> tab. + </p> + <p> + For the given code: + </p> + <p><img src="images/arrays-fill-before.png" alt="Before"/></p> + <p> + One gets: + </p> + <p><img src="images/arrays-fill-after.png" alt="After"/></p> + </td> + </tr> + <!-- ******************* End of Java Editor ************************************* --> <!-- ******************* Java Views and Dialogs ************************************* --> |