Hi,
how may I organize imports on file save?
The setting "java.saveActions.organizeImports": true does nothing.
Cleanup not performed on save.
Cleanup should be performed on save.
I opened a Java Maven project (Eclipse project).
works for me. Try enabling verbose logging in your settings.json ("java.trace.server": "verbose"), and paste the logs here
btw
Java extension version: please...what?
-> 0.32.0 here
Thanks for your reply. I got 0.31.0 and now upgraded to 0.32.0.
Edit: Log
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:23.573
!MESSAGE >> document/codeAction
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:23.773
!MESSAGE >> workspace/executeCommand vscode.java.test.fetch
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:23.776
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.008
!MESSAGE >> document/didChange
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.187
!MESSAGE >> document/didChange
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.432
!MESSAGE >> workspace/executeCommand vscode.java.test.fetch
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.435
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.532
!MESSAGE >> document/documentSymbol
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.581
!MESSAGE >> document/formatting
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.628
!MESSAGE >> document/didChange
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.739
!MESSAGE begin problem for /OpenInNewWindowAction.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.742
!MESSAGE 5 problems reported for /OpenInNewWindowAction.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.746
!MESSAGE Reconciled 0, validated: 1. Took 155 ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.750
!MESSAGE >> document/willSaveWailUntil
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.854
!MESSAGE >> document/didSave
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.943
!MESSAGE >> workspace/executeCommand vscode.java.test.fetch
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.946
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:24.984
!MESSAGE >> document/documentSymbol
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:25.204
!MESSAGE >> workspace/didChangeWatchedFiles
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:25.209
!MESSAGE >> workspace/executeCommand vscode.java.test.fetch
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:25.214
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:25.332
!MESSAGE begin problem for /OpenInNewWindowAction.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:25.335
!MESSAGE 5 problems reported for /OpenInNewWindowAction.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:27:25.336
!MESSAGE Reconciled 0, validated: 1. Took 187 ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:28:22.255
!MESSAGE >> document/codeAction
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:28:22.468
!MESSAGE >> workspace/executeCommand vscode.java.test.fetch
!ENTRY org.eclipse.jdt.ls.core 1 0 2018-10-05 09:28:22.470
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod
This issue is still seen in the latest vscode editor.
This issue is still seen in the latest vscode editor.
@snjeza I believe this is what I saw in https://github.com/eclipse/eclipse.jdt.ls/pull/1415#issuecomment-617941928. My guess is the Compilation Unit is not reconciled properly at that point.
@bundery could you try the following settings:
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"java.saveActions.organizeImports": false
I have also never been able to get this settings to work. This includes two completely separate installations and maven projects.
The workaround / tip provided by @snjeza does work.
Most helpful comment
@bundery could you try the following settings: