question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quick fix - Auto-Import doesn't work

See original GitHub issue
Environment
  • 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
  1. Create a basic Java file
  2. Try to use some Java type that is not yet imported in that file. Example: ArrayList<String> test = new ArrayList<String>();
  3. The type ArrayList will be marked red
  4. Hover your mouse of the ArrayList and click on “Quick fix…”
  5. All quick fix options will appear (they are correct and helpful)
  6. Click on the top-most line which is the correct suggestion to import the ArrayList type image
  7. 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 image

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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:20 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fbriconcommented, Aug 11, 2019

Closing then

1reaction
Nukepayload2commented, Jul 25, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio Code - Auto Imports / Quick Fix does not work
I've tried to make it work on two PCs and one Mac - the result is the same: No suggestions to import as...
Read more >
Auto import/quick fix for imports not working with venv #2075
Actual behaviour. Any other import found is suggested, but not from packages in venv. This also doesn't work with auto-imports.
Read more >
Client: Scala: Auto-import quick-fix is offered only after some ...
Go to Client and check whether the imports are suggested now. ACTUAL: There exists or does not exist import quick-fix suggested on the...
Read more >
New to neovim, how to get the quick fix menu to import like ...
Hi guys, I been using nvim for a couple of days without using LSP i see that a lot of people use it...
Read more >
Visual Studio Code - Auto Imports/Quick Fix Does Not Work
It will do automatic importing (powered by LSP), but this is very flaky which I found imports (like built-in modules) saying there is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found