Quick fix - Auto-Import doesn't work
See original GitHub issueEnvironment
- Operating System: VS Code is installed on Windows 10 but I’m using the VS Code Remote Development extension on an Ubuntu 18.04
- JDK version:
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)
- Visual Studio Code version: 1.36.1
- Java extension version: 0.47.0
Steps To Reproduce
- Create a basic Java file
- Try to use some Java type that is not yet imported in that file. Example:
ArrayList<String> test = new ArrayList<String>();
- The type ArrayList will be marked red
- Hover your mouse of the ArrayList and click on “Quick fix…”
- All quick fix options will appear (they are correct and helpful)
- Click on the top-most line which is the correct suggestion to import the ArrayList type
- Result: the error does not go away, the import for ArrayList is not automatically added to the Java file
You can manually add the import statement and it will fix the issue.
Message tracing between VS Code and the Java Language Server It first shows a large JSON text that contains all quick fix options displayed (I skip that JSON here as the quick fix list seems correct) Then it shows
[Trace - 12:11:15 PM] Sending request ‘workspace/executeCommand - (631)’. Params: { “command”: “java.resolvePath”, “arguments”: [ “output:extension-output-%236” ] } [Trace - 12:11:15 PM] Received response ‘workspace/executeCommand - (631)’ in 3ms. Result: []
vscode-java logs
Java Language Server’s workspace logs Extract:
!ENTRY org.eclipse.jdt.ls.core 1 0 2019-07-23 12:03:53.873 !MESSAGE >> workspace/executeCommand java.getPackageData
!ENTRY org.eclipse.jdt.ls.core 4 0 2019-07-23 12:03:53.874 !MESSAGE Problem with folding range for /aws/src/main/java/com/extremenetworks/hcm/aws/mgr/ResourcesWorker.java !STACK 0 org.eclipse.jdt.core.compiler.InvalidInputException: Invalid_Char_In_String at org.eclipse.jdt.internal.core.util.PublicScanner.getNextToken(PublicScanner.java:1470) at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.computeMethodRanges(FoldingRangeHandler.java:209) at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.computeTypeRanges(FoldingRangeHandler.java:143) at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.computeTypeRootRanges(FoldingRangeHandler.java:131) at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.computeFoldingRanges(FoldingRangeHandler.java:113) at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.foldingRange(FoldingRangeHandler.java:61) at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$25(JDTLanguageServer.java:781) at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$42(JDTLanguageServer.java:915) at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602) at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577) at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:443) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
…
!ENTRY org.eclipse.jdt.ls.core 1 0 2019-07-23 12:15:14.827 !MESSAGE >> document/hover
!ENTRY org.eclipse.jdt.ls.core 1 0 2019-07-23 12:15:16.076 !MESSAGE >> workspace/executeCommand java.resolvePath
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:20 (4 by maintainers)
Top GitHub Comments
Closing then
I have the same problem. “Add unimplemented methods”, “Remove argument to match …”, “Create constructor” and “Add package declaration” are also not working. I’m not using remote development.