Skip to content

Commit c27ab7d

Browse files
committed
Add 'organizeImports' to the cleanup settings.
Signed-off-by: Roland Grunberg <[email protected]>
1 parent 8923a98 commit c27ab7d

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

document/_java.learnMoreAboutCleanUps.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,65 @@ Cleans up lambda expression wherever possible in the following ways:
344344
```java
345345
ArrayList::new;
346346
```
347+
348+
### `organizeImports`
349+
350+
Performs the "Organize Imports" operation.
351+
352+
**Note** : Since clean ups are meant to be applied without user feedback (eg. prompts about ambiguous types), this may leave some types unresolved. To properly resolve these ambiguous types, one can do so manually (code actions, source actions), or by calling "Organize Imports" through the command palette / key binding (<kbd>shift</kbd> + <kbd>alt</kbd> + <kbd>o</kbd>).
353+
354+
For example:
355+
356+
```java
357+
package test1;
358+
public class A {
359+
public void test() {
360+
List<String> a1;
361+
Iterator<String> a2;
362+
Map<String, String> a3;
363+
Set<String> a4;
364+
JarFile a5;
365+
StringTokenizer a6;
366+
Path a7;
367+
URI a8;
368+
HttpURLConnection a9;
369+
InputStream a10;
370+
Field a11;
371+
Parser a12;
372+
}
373+
}
374+
```
375+
376+
becomes:
377+
378+
```java
379+
package test1;
380+
381+
import java.io.InputStream;
382+
import java.net.HttpURLConnection;
383+
import java.net.URI;
384+
import java.nio.file.Path;
385+
import java.util.Iterator;
386+
import java.util.List;
387+
import java.util.Map;
388+
import java.util.Set;
389+
import java.util.StringTokenizer;
390+
import java.util.jar.JarFile;
391+
392+
public class A {
393+
public void test() {
394+
List<String> a1;
395+
Iterator<String> a2;
396+
Map<String, String> a3;
397+
Set<String> a4;
398+
JarFile a5;
399+
StringTokenizer a6;
400+
Path a7;
401+
URI a8;
402+
HttpURLConnection a9;
403+
InputStream a10;
404+
Field a11;
405+
Parser a12;
406+
}
407+
}
408+
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,8 @@
12801280
"lambdaExpression",
12811281
"switchExpression",
12821282
"tryWithResource",
1283-
"renameFileToType"
1283+
"renameFileToType",
1284+
"organizeImports"
12841285
]
12851286
},
12861287
"default": [

0 commit comments

Comments
 (0)