Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organize imports fails to work #508

Closed
paperant opened this issue Apr 15, 2018 · 6 comments
Closed

Organize imports fails to work #508

paperant opened this issue Apr 15, 2018 · 6 comments

Comments

@paperant
Copy link

[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

Current Result
Expected Result
Additional Informations
@fbricon
Copy link
Collaborator

fbricon commented Apr 16, 2018

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

@paperant
Copy link
Author

paperant commented Apr 18, 2018

@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.

@gentunian
Copy link

gentunian commented Jul 3, 2018

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"

@olfek
Copy link

olfek commented Sep 13, 2018

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

@brunoborges
Copy link

Hey all... any update on this?

@fbricon
Copy link
Collaborator

fbricon commented Dec 6, 2018

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.

@fbricon fbricon added this to the Mid December 2018 milestone Dec 18, 2018
@fbricon fbricon closed this as completed Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants