vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Imports for Java packages

Open pfuetzma opened this issue 1 year ago • 7 comments

Imports for Java packages such as java.util.* or java.time.* are no longer suggested or added in the Code Editor.

Environment
  • Operating System: Win10Pro
  • JDK version: 21
  • Visual Studio Code version: 1.92.2
  • Java extension version: Extension Pack for Java v0.29.0
Steps To Reproduce
  1. open *.java file
  2. type LocalDateTime

Only imports from third-party libraries are offered, e.g com.fasterxml... or com.springframework...

pfuetzma avatar Aug 30 '24 07:08 pfuetzma

Do you see any other errors in the problems view, or just the ones about those imports not being found ? Seems like a misconfigured JDK might cause this, given that you're still seeing import suggestions from other 3rd party libraries.

rgrunber avatar Sep 03 '24 19:09 rgrunber

I've been having this problem on & off while now. When it happens I run the "Clean Java Language Server Workspace" command which sorts it out. Nothing obvious in the Problem / Output panels.

Environment

  • Operating System: Windows 11 Pro
  • JDK version: 17
  • Visual Studio Code version: 1.92.2
  • Java extension version: Extension Pack for Java v0.29.0 (Language support v1.34.0)

Ill have a play around to see if I can figure out what is triggering the issue.

andywarren86 avatar Sep 04 '24 01:09 andywarren86

Duplicate of https://github.com/redhat-developer/vscode-java/issues/3715

andywarren86 avatar Sep 04 '24 02:09 andywarren86

I almost expected the reaction to be a misconfigured JDK. But that is not the case. The projects work and can be compiled and executed. I can't find anything about this in the problems view.

pfuetzma avatar Sep 04 '24 05:09 pfuetzma

Yeah it definitely seems like #3715 . I've run into it once or twice before, and also found it went away when I cleaned the workspace. I saved my client/server logs from around when this happened and can clearly see the imports not being sent back during that period of time. However there isn't anything odd in terms of errors. Just that the server completely left out the code actions regarding imports but did include others (so it wasn't an outright failure).

rgrunber avatar Sep 04 '24 20:09 rgrunber

I also have this issue where the java.util.* package is not being suggested, which is quite frustrating. It happens from time to time, and I have to restart VSCode or clear the cache. When will this issue be fixed? Environment Operating System: macOS 14.6.1 JDK version: 21 Visual Studio Code version: 1.93.0 Java extension version: Extension Pack for Java v0.29.0

yinweixx avatar Sep 11 '24 03:09 yinweixx

I would try the vscode-java pre-release build tomorrow. There's a good chance this has been fixed now.

rgrunber avatar Oct 16 '24 19:10 rgrunber

Marking as closed as I really think this was fixed in https://github.com/redhat-developer/vscode-java/issues/3797 (or even #3715 , there were many duplicates of the same problem).

rgrunber avatar Nov 05 '24 16:11 rgrunber