vscode-java
vscode-java copied to clipboard
The autosuggestion function does not suggest JDK standard classes after the laptop wakes up from sleep
The language server fails to suggest JDK classes after the laptop wakes up from sleep mode.
- Java 17
- macOS 15.1 Beta (24B5055e) but the same happens on the stable macOS 15
- VSCode Version: 1.91.1
- Language server version 1.35.0 (September 26th, 2024)
Steps to reproduce:
- Open VSCode
- Leave the laptop until it goes to sleep.
- Wake up and try to use some standard class from JDK
- Observer the issue
Actually, restart of the VScode makes the language server to work again, but not sure if it is expected.
Seems like the duplicate of https://github.com/redhat-developer/vscode-java/issues/3715
However, I can't be 100% sure since I encounter my issue after my laptop wakes from sleep.
I am experiencing the same issue…
Running "Clean Java Language Server Workspace" temporarily resolves the issue, but it reoccurs eventually.
However, there is a peculiar phenomenon.
When the issue occurs, instead of running "Clean Java Language Server Workspace", if I close and reopen VSCode, the import suggestions for standard libraries work fine while the project is loading, but once the loading is complete, the import suggestions stop working.
I am wondering if this issue is only related to macOS. Does it affect all operating systems?
I have seen similar behaviour (Linux) but it happened maybe once or twice ever. If it's the same issue, it definitely seems to have started happening more frequently (based on users filing it). I was able to capture the code action before when this happened but nothing really stands out :
code action difference
--- response_good.txt 2024-08-14 10:46:30.022031338 -0400
+++ response_bad.txt 2024-08-14 10:43:11.265681603 -0400
@@ -1,12 +1,12 @@
{
- message: "[Trace - 14:18:26] Received response 'textDocument/codeAction - (28)' in 750ms.",
+ message: "[Trace - 14:16:15] Received response 'textDocument/codeAction - (2477)' in 85ms.",
level: 'info',
- timestamp: '2024-08-13 14:18:26.557'
+ timestamp: '2024-08-13 14:16:15.226'
}
{
message: 'Result: [\n' +
' {\n' +
- ` "title": "Import 'JsonArray' (com.google.gson)",\n` +
+ ` "title": "Create class 'JsonArray'",\n` +
' "kind": "quickfix",\n' +
' "diagnostics": [\n' +
' {\n' +
@@ -50,11 +50,11 @@
' ],\n' +
' "data": {\n' +
' "pid": "0",\n' +
- ' "rid": "0"\n' +
+ ' "rid": "257"\n' +
' }\n' +
' },\n' +
' {\n' +
- ' "title": "Add all missing imports",\n' +
+ ` "title": "Create enum 'JsonArray'",\n` +
' "kind": "quickfix",\n' +
' "diagnostics": [\n' +
' {\n' +
@@ -98,11 +98,11 @@
' ],\n' +
' "data": {\n' +
' "pid": "1",\n' +
- ' "rid": "0"\n' +
+ ' "rid": "257"\n' +
' }\n' +
' },\n' +
' {\n' +
- ` "title": "Create class 'JsonArray'",\n` +
+ ` "title": "Create interface 'JsonArray'",\n` +
' "kind": "quickfix",\n' +
' "diagnostics": [\n' +
' {\n' +
@@ -146,11 +146,11 @@
' ],\n' +
' "data": {\n' +
' "pid": "2",\n' +
- ' "rid": "0"\n' +
+ ' "rid": "257"\n' +
' }\n' +
' },\n' +
' {\n' +
- ` "title": "Create enum 'JsonArray'",\n` +
+ ` "title": "Add type parameter 'JsonArray' to 'BuildWorkspaceHandler'",\n` +
' "kind": "quickfix",\n' +
' "diagnostics": [\n' +
' {\n' +
@@ -194,11 +194,11 @@
' ],\n' +
' "data": {\n' +
' "pid": "3",\n' +
- ' "rid": "0"\n' +
+ ' "rid": "257"\n' +
' }\n' +
' },\n' +
' {\n' +
- ` "title": "Create interface 'JsonArray'",\n` +
+ ` "title": "Add type parameter 'JsonArray' to 'buildWorkspace(boolean, IProgressMonitor)'",\n` +
' "kind": "quickfix",\n' +
' "diagnostics": [\n' +
' {\n' +
@@ -242,125 +242,104 @@
' ],\n' +
' "data": {\n' +
' "pid": "4",\n' +
- ' "rid": "0"\n' +
+ ' "rid": "257"\n' +
' }\n' +
' },\n' +
' {\n' +
- ` "title": "Add type parameter 'JsonArray' to 'BuildWorkspaceHandler'",\n` +
- ' "kind": "quickfix",\n' +
- ' "diagnostics": [\n' +
- ' {\n' +
- ' "range": {\n' +
- ' "start": {\n' +
- ' "line": 99,\n' +
- ' "character": 4\n' +
- ' },\n' +
- ' "end": {\n' +
- ' "line": 99,\n' +
- ' "character": 13\n' +
- ' }\n' +
- ' },\n' +
- ' "severity": 1,\n' +
- ' "code": "16777218",\n' +
- ' "source": "Java",\n' +
- ' "message": "JsonArray cannot be resolved to a type",\n' +
- ' "data": [\n' +
- ' "JsonArray"\n' +
- ' ]\n' +
- ' },\n' +
- ' {\n' +
- ' "range": {\n' +
- ' "start": {\n' +
- ' "line": 99,\n' +
- ' "character": 25\n' +
- ' },\n' +
- ' "end": {\n' +
- ' "line": 99,\n' +
- ' "character": 34\n' +
- ' }\n' +
- ' },\n' +
- ' "severity": 1,\n' +
- ' "code": "16777218",\n' +
- ' "source": "Java",\n' +
- ' "message": "JsonArray cannot be resolved to a type",\n' +
- ' "data": [\n' +
- ' "JsonArray"\n' +
- ' ]\n' +
- ' }\n' +
- ' ],\n' +
+ ' "title": "Add Javadoc comment",\n' +
+ ' "kind": "quickassist",\n' +
' "data": {\n' +
' "pid": "5",\n' +
- ' "rid": "0"\n' +
+ ' "rid": "257"\n' +
' }\n' +
' },\n' +
' {\n' +
- ` "title": "Add type parameter 'JsonArray' to 'buildWorkspace(boolean, IProgressMonitor)'",\n` +
- ' "kind": "quickfix",\n' +
- ' "diagnostics": [\n' +
- ' {\n' +
- ' "range": {\n' +
- ' "start": {\n' +
- ' "line": 99,\n' +
- ' "character": 4\n' +
- ' },\n' +
- ' "end": {\n' +
- ' "line": 99,\n' +
- ' "character": 13\n' +
- ' }\n' +
- ' },\n' +
- ' "severity": 1,\n' +
- ' "code": "16777218",\n' +
- ' "source": "Java",\n' +
- ' "message": "JsonArray cannot be resolved to a type",\n' +
- ' "data": [\n' +
- ' "JsonArray"\n' +
- ' ]\n' +
- ' },\n' +
- ' {\n' +
- ' "range": {\n' +
- ' "start": {\n' +
- ' "line": 99,\n' +
- ' "character": 25\n' +
- ' },\n' +
- ' "end": {\n' +
- ' "line": 99,\n' +
- ' "character": 34\n' +
- ' }\n' +
- ' },\n' +
- ' "severity": 1,\n' +
- ' "code": "16777218",\n' +
- ' "source": "Java",\n' +
- ' "message": "JsonArray cannot be resolved to a type",\n' +
- ' "data": [\n' +
- ' "JsonArray"\n' +
- ' ]\n' +
- ' }\n' +
- ' ],\n' +
+ ` "title": "Add final modifier for 'uris'",\n` +
+ ' "kind": "quickassist",\n' +
+ ' "diagnostics": [],\n' +
' "data": {\n' +
' "pid": "6",\n' +
- ' "rid": "0"\n' +
+ ' "rid": "257"\n' +
' }\n' +
' },\n' +
' {\n' +
- ' "title": "Add Javadoc comment",\n' +
- ' "kind": "quickassist",\n' +
+ ' "title": "Organize imports",\n' +
+ ' "kind": "source.organizeImports",\n' +
+ ' "diagnostics": [],\n' +
' "data": {\n' +
' "pid": "7",\n' +
- ' "rid": "0"\n' +
+ ' "rid": "257"\n' +
' }\n' +
' },\n' +
' {\n' +
- ` "title": "Add final modifier for 'uris'",\n` +
- ' "kind": "quickassist",\n' +
+ ' "title": "Add all missing imports",\n' +
+ ' "kind": "source",\n' +
' "diagnostics": [],\n' +
' "data": {\n' +
' "pid": "8",\n' +
- ' "rid": "0"\n' +
+ ' "rid": "257"\n' +
' }\n' +
' },\n' +
' {\n' +
- ' "title": "Organize imports",\n' +
- ' "kind": "source.organizeImp'... 15248 more characters,
+ ' "title": "Generate Getters",\n' +
+ ' "kind": "source.generate.accessors",\n' +
+ ' "diagnostics": [],\n' +
+ ' "data": {\n' +
+ ' "pid": "9",\n' +
+ ' "rid": "257"\n' +
+ ' }\n' +
+ ' },\n' +
+ ' {\n' +
+ ' "title": "Generate Constructors...",\n' +
+ ' "kind": "source.generate.constructors",\n' +
+ ' "diagnostics": [],\n' +
+ ' "command": {\n' +
+ ' "title": "Generate Constructors...",\n' +
+ ' "command": "java.action.generateConstructorsPrompt",\n' +
+ ' "arguments": [\n' +
+ ' {\n' +
+ ' "textDocument": {\n' +
+ ' "uri": "file:///home/rgrunber/git/eclipse.jdt.ls/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/BuildWorkspaceHandler.java"\n' +
+ ' },\n' +
+ ' "range": {\n' +
+ ' "start": {\n' +
+ ' "line": 99,\n' +
+ ' "character": 37\n' +
+ ' },\n' +
+ ' "end": {\n' +
+ ' "line": 99,\n' +
+ ' "character": 37\n' +
+ ' }\n' +
+ ' },\n' +
+ ' "context": {\n' +
+ ' "diagnostics": [\n' +
+ ' {\n' +
+ ' "range": {\n' +
+ ' "start": {\n' +
+ ' "line": 99,\n' +
+ ' "character": 4\n' +
+ ' },\n' +
+ ' "end": {\n' +
+ ' "line": 99,\n' +
+ ' "character": 13\n' +
+ ' }\n' +
+ ' },\n' +
+ ' "severity": 1,\n' +
+ ' "code": "16777218",\n' +
+ ' "source": "Java",\n' +
+ ' "message": "JsonArray cannot be resolved to a type",\n' +
+ ' "data": [\n' +
+ ' "JsonArray"\n' +
+ ' ]\n' +
+ ' },\n' +
+ ' {\n' +
+ ' "range": {\n' +
+ ' "start": {\n' +
+ ' "line": 99,\n' +
+ ' "character": 25\n' +
+ ' },\n' +
+ ' "end": {\n' +
+ ' "line":'... 12557 more characters,
level: 'info',
- timestamp: '2024-08-13 14:18:26.557'
+ timestamp: '2024-08-13 14:16:15.226'
}
The interesting part is that code actions continue to work. It's just the ones relating to the type (that can no longer be detected) that are removed.
For those that are encountering this, a few things to try that might help narrow this down a bit. Immediately after you see this happening :
- At the bottom left corner, there should be a Java status icon. Is it in the "Ready" state ?
- At the bottom right corner there should be a Java language mode icon. Does it clearly indicate a Java execution environment version ?
- Are there any errors in the problems view ? Maybe relating to the import of the project ?
- If you go to the command palette and call the command
Java: Open Java Language Server Log File, are there any errors/something strange being logged around the time this occurs ? - If you bring up the workspace symbol search (ctrl + t or Go -> Go To Symbol In Workspace), are you able to search for the missing type, or any other types on the classpath ?
- If "Import 'SomeType'" doesn't show up, do you see "Add all missing imports" or "Organize Imports" ? Do any of those work ?
I would try the vscode-java pre-release build tomorrow. There's a good chance this has been fixed now.
@rgrunber cool. Thanks for keeping me updated.