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

Candidates missing from autocomplete and automatic importing not working

Open bgx90 opened this issue 5 years ago • 4 comments

vim version: NVIM v0.3.4
node version: v10.16.0
coc.nvim version: 0.0.72-20462895da
term: xterm-256color
platform: linux

After updating to the latest commit on the coc release branch and updating coc-java and the language server, some candidates are missing from the completion option list that were available before. For example, I now only see the hibernate Entity annotation offered, but before the javax.persistence.Entity annotation (the one I want) had been available as well. However, I still get the option of importing javax.persistence.Entity when I get available code actions. Autocompletion is also not triggering imports on completions anymore.

I see the following error in the trace when I try autocompletion:

[Trace - 1:27:51 PM] Sending request 'completionItem/resolve - (14)'.
Params: {
    "label": "Entity - org.hibernate.annotations",
    "kind": 8,
    "sortText": "999998748",
    "filterText": "Entity",
    "insertText": "Entity",
    "data": {
        "decl_signature": "Lorg.hibernate.annotations.Entity;",
        "pid": "1",
        "rid": "4",
        "uri": "file:///home/user/udemy/spring5/spring5webapp/src/main/java/guru/springframework/spring5webapp/model/Publisher.java"
    }
}


[Trace - 1:27:51 PM] Received response 'completionItem/resolve - (14)' in 51ms. Request failed: Internal error. (-32603).
Error data: "java.lang.RuntimeException: java.lang.reflect.InvocationTargetException\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)\n\tat org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.lambda$0(ParentProcessWatcher.java:121)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)\n\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:834)\nCaused by: java.lang.reflect.InvocationTargetException\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:566)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)\n\t... 12 more\nCaused by: java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Property must not be null: value\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)\nCaused by: java.lang.IllegalArgumentException: Property must not be null: value\n\tat org.eclipse.lsp4j.MarkupContent.setValue(MarkupContent.java:84)\n\tat org.eclipse.jdt.ls.core.internal.handlers.CompletionResolveHandler.resolve(CompletionResolveHandler.java:178)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$5(JDTLanguageServer.java:490)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$40(JDTLanguageServer.java:892)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n"


[Error  - 1:27:51 PM] Request completionItem/resolve failed.
  Message: Internal error.
  Code: -32603 
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.lambda$0(ParentProcessWatcher.java:121)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 12 more
Caused by: java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Property must not be null: value
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.lang.IllegalArgumentException: Property must not be null: value
	at org.eclipse.lsp4j.MarkupContent.setValue(MarkupContent.java:84)
	at org.eclipse.jdt.ls.core.internal.handlers.CompletionResolveHandler.resolve(CompletionResolveHandler.java:178)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$5(JDTLanguageServer.java:490)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$40(JDTLanguageServer.java:892)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	... 6 more

bgx90 avatar Jul 10 '19 18:07 bgx90

It's problem of your jdt.ls, you can download older version of jdt.ls.

chemzqm avatar Jul 10 '19 19:07 chemzqm

Okay, thanks. I updated the server via the CocCommand java.updateLanguageServer. Does that command just download the absolute latest version of jdt.ls? I was thinking that it would download the latest version of jdt.ls known to work with the installed version of coc; could it be made to do that to prevent this problem in the future?

bgx90 avatar Jul 10 '19 19:07 bgx90

I reverted back to the version of jdt.ls that was working for me before I upgraded (jdt-language-server-0.37.0-201904162228.tar.gz). Automatic imports work again, but the missing candidates problem persists as before. When adding an Entity annotation I only see the org.hibernate.annotations.Entity option in the autocompletion list, but importing javax.persistence.Entity is still an option in the code actions, so I know the server is aware of that class. I did not have this issue before with this version jdt.ls, so is it possible that the newest version of coc is removing javax.persistence.Entity from the autocomplete options as if it were a duplicate of the org.hibernate.annotations.Entity list item?

BTW, I am now on this commit from the coc release branch

## versions

vim version: NVIM v0.3.4
node version: v10.16.0
coc.nvim version: 0.0.72-d87103178f
term: xterm-256color
platform: linux

bgx90 avatar Jul 10 '19 21:07 bgx90

The missing autocomplete candidate problem seems to be with coc. I reverted to commit 25e10368d5f9b61ee3a448fb7810597bdd5533ca on the release branch and now see both javax.persistence.Entity and org.hibernate.annotations.Entity in the autocomplete options list.

Now on this version:

## versions

vim version: NVIM v0.3.4
node version: v10.16.0
coc.nvim version: 0.0.72-8c7241d7e3
term: xterm-256color
platform: linux

bgx90 avatar Jul 10 '19 21:07 bgx90

Should be fixed on recent version of coc-java, try upgrade coc.nvim to latest release and coc-java to version 1.14.0.

chemzqm avatar Jan 29 '23 09:01 chemzqm