Vscode-java: Organize imports fails to work

Created on 15 Apr 2018  路  6Comments  路  Source: redhat-developer/vscode-java

[provide a description of the issue]

Environment
  • Operating System: macOS 10.13.3
  • JDK version: 1.8.0_112
  • Visual Studio Code version: 1.22.2
  • Java extension version: 0.22.0
Steps To Reproduce

Shift + Alt + O fails to organize imports but if I write in the configuration like:

"java.saveActions.organizeImports": true,

it works when I use Command + S, but still not work for the Shift + Alt + O combination.
[attach a sample project reproducing the error]
[attach logs](https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#enable-logging)

Current Result
Expected Result
Additional Informations
enhancement

Most helpful comment

Well, yeah kinda ;-)

If you open a single java file from vscode, it still won't work.

But, last night, we merged Microsoft's new patch to improve standalone java files support. So, with the latest CI build, if you open the folder containing that java file (including all the folders from its packages), then you'll get full java support: organize imports, compilation errors, the whole shebang. No more "incomplete classpath" warning.

This will be part of the next release, around Dec 15th.

All 6 comments

Is it for a simple java file or a complete Java project?
Can you provide a sample project reproducing your issue?

@fbricon
The combination Shift + Alt + O works for a Java project. (Like maven project)
But it doesn't work for a Java file.
While the configuration:

"java.saveActions.organizeImports": true,

works for both.

I can confirm this. Invoking "Organize imports" does not work on a single java file. Setting the option @paperant says does partially works importing some namespaces but not all. In my case it only imported 3 packages:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Reader;

And I'm having references to other packages like HttpURLConnection and so on...

Version 1.24.1
Commit 24f62626b222e9a8313213fb64b10d741a326288
Date 2018-06-13T17:47:35.732Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
Java extension version: 0.27.0 (June 18th, 2018)
openjdk version "1.8.0_172"

I too can confirm this. Organise imports doesn't work on independent java files.

Hey all... any update on this?

Well, yeah kinda ;-)

If you open a single java file from vscode, it still won't work.

But, last night, we merged Microsoft's new patch to improve standalone java files support. So, with the latest CI build, if you open the folder containing that java file (including all the folders from its packages), then you'll get full java support: organize imports, compilation errors, the whole shebang. No more "incomplete classpath" warning.

This will be part of the next release, around Dec 15th.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielcalvogonzalez picture danielcalvogonzalez  路  3Comments

BuZZ-dEE picture BuZZ-dEE  路  4Comments

zalcorshark picture zalcorshark  路  3Comments

sfariaNG picture sfariaNG  路  3Comments

xriu picture xriu  路  4Comments