Bug 571977 - [AutoRefactor immigration #64/151] [cleanup & saveaction]
Initialize array with curly
Replace the new instance syntax by curly brackets to create an array
when possible:
- It must be an initialization of a declaration,
- The declaration must have the same type.
Given:
double[] doubleArray = new double[] { 0.0 };
int[][] intArray = new int[][] { { 42 } };
When:
Clean up the code enabling "Create array with curly when possible"
Then:
double[] doubleArray = { 0.0 };
int[][] intArray = { { 42 } };
Change-Id: Id9551e3d3f405b60aad4f1dd844648a4e08d565d
Signed-off-by: Fabrice Tiercelin <fabrice.tiercelin@yahoo.fr>
Depends-On: I303fa771248ade0a37551bdf6d432bdf0b3eacf7diff --git a/4.20/images/array-with-curly-after.png b/4.20/images/array-with-curly-after.png
new file mode 100644
index 0000000..709bb8c
--- /dev/null
+++ b/4.20/images/array-with-curly-after.png
Binary files differ
diff --git a/4.20/images/array-with-curly-before.png b/4.20/images/array-with-curly-before.png
new file mode 100644
index 0000000..6b40c7b
--- /dev/null
+++ b/4.20/images/array-with-curly-before.png
Binary files differ
diff --git a/4.20/images/array-with-curly-preferences.png b/4.20/images/array-with-curly-preferences.png
new file mode 100644
index 0000000..5c6b066
--- /dev/null
+++ b/4.20/images/array-with-curly-preferences.png
Binary files differ
diff --git a/4.20/jdt.html b/4.20/jdt.html
index a4dca85..587953a 100644
--- a/4.20/jdt.html
+++ b/4.20/jdt.html
@@ -117,6 +117,29 @@
</td>
</tr>
+ <tr id="array-with-curly"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=571977 -->
+ <td class="title"><a href="#array-with-curly">Initialize array with curly clean up</a></td>
+ <td class="content">
+ A new clean up has been added that replaces the new instance syntax by curly brackets to create an array.
+ <p>
+ It must be an initialization of a declaration.
+ The declaration must have the same type.
+ </p>
+ <p>
+ To apply the clean up, select <b>Create array with curly when possible</b> check box on the <b>Unnecessary Code</b> tab in your clean up profile.
+ </p>
+ <p><img src="images/array-with-curly-preferences.png" alt="Preferences" width="800"/></p>
+ <p>
+ For the given code:
+ </p>
+ <p><img src="images/array-with-curly-before.png" alt="Before"/></p>
+ <p>
+ One gets:
+ </p>
+ <p><img src="images/array-with-curly-after.png" alt="After"/></p>
+ </td>
+ </tr>
+
<!-- ******************* End of Java Editor ************************************* -->
<!-- ******************* Java Views and Dialogs ************************************* -->