netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Run long-spanning tasks cancellably on background in the (Java) LSP server.

Open lahodaj opened this issue 5 months ago • 1 comments

@jtulach reported the code completion inside VS Code is sometimes slow for him. I was thinking of that, and experimenting, and I think at least part of the problem is that tasks that should be background tasks are not properly cancellable in the VS Code (Java) server.

I was doing experiments on: https://github.com/openjdk/jdk/blob/master/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java

and it seemed there were two (current) particular pain points:

  • diagnostics (especially hints) computation, which can take a fairly long time to compute
  • semantic coloring computation, which can also take some time to compute

Neither of these can be cancelled when the request to compute code completion. This draft is attempting to improve that, and run diagnostics and semantic coloring in a cancellable way.

It only properly cancels for Java sources at this time, for other sources runs only the CompletableFuture cancel will work. Some work on Schedulers will be needed to fully enable this for non-Java sources, but I suspect this can wait

I also have a separate PR that adds additional logging for code completion: https://github.com/apache/netbeans/pull/7815

lahodaj avatar Aug 29 '24 11:08 lahodaj