Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ide/lsp.client add opened documents after start #3812

Open
2 tasks done
vieiro opened this issue Mar 19, 2022 · 1 comment · May be fixed by #7759
Open
2 tasks done

ide/lsp.client add opened documents after start #3812

vieiro opened this issue Mar 19, 2022 · 1 comment · May be fixed by #7759
Labels
kind:feature A feature request

Comments

@vieiro
Copy link
Contributor

vieiro commented Mar 19, 2022

Description

ide/lsp.client could make sure that the lsp server is informed about currently opened files in the editor immediately after start

Use case/motivation

The LSP server (clangd in this case) complaining about a request of semantic highlighting for files not previously opened with didOpen:

I[10:02:13.646] <-- textDocument/semanticTokens/full("10")
I[10:02:13.646] --> reply:textDocument/semanticTokens/full("10") 0 ms, error: -32602: trying to get AST for non-added document
V[10:02:13.646] >>> {"error":{"code":-32602,"message":"trying to get AST for non-added document"},"id":"10","jsonrpc":"2.0"}

SEVERE [org.openide.util.Exceptions]
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: trying to get AST for non-added document
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	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:829)
Caused: java.util.concurrent.ExecutionException
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
[catch] at org.netbeans.modules.lsp.client.bindings.MarkOccurrences.computeHighlights(MarkOccurrences.java:102)
	at org.netbeans.modules.lsp.client.bindings.MarkOccurrences.run(MarkOccurrences.java:82)
	at org.netbeans.modules.lsp.client.LSPBindings.lambda$addBackgroundTask$14(LSPBindings.java:472)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
SEVERE [org.openide.util.Exceptions]
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: trying to get AST for non-added document
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	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:829)
Caused: java.util.concurrent.ExecutionException
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
[catch] at org.netbeans.modules.lsp.client.bindings.BreadcrumbsImpl.run(BreadcrumbsImpl.java:87)
	at org.netbeans.modules.lsp.client.LSPBindings.lambda$addBackgroundTask$14(LSPBindings.java:472)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@vieiro vieiro added kind:feature A feature request needs:triage Requires attention from one of the committers labels Mar 19, 2022
@vieiro
Copy link
Contributor Author

vieiro commented Mar 20, 2022

ide/lsp.client does indeed tell the server about opened files on start, problem is that we have many different RequestProcessors for feature, and we may want to have one RequestProcessor per server (so it's easier to send requests in proper order).

@mbien mbien removed the needs:triage Requires attention from one of the committers label Mar 21, 2022
vieiro added a commit to vieiro/netbeans-cnd that referenced this issue Apr 13, 2022
- Admits all SemanticTokenTypes and SemanticTokenModifiers in the LSP specification.
- Adds a RequestProcessor in LSPBindings to:
    - Request from different LSP clients (TypeScript and C++, for instance) do not share a single thread, blocking each other.
    - Requests to the same LSP client (C++, for instance) are properly sequenced, so that LSPBindings, BreadcrumbsImpl, LanguageClientImpl and TextDocumentSyncServerCapabilityHandler work together in harmony (see apache#3812)
vieiro added a commit to vieiro/netbeans-cnd that referenced this issue Apr 30, 2022
- Each LSP server has its own (single thread) RequestProcessor, so a
  slow LSP server doesn't slow down others.
- All LSP features use this very same RequestProcessor. On LSP server
  startup all opened files are sent to the server, so the next requests
  (BreadcrumbsImpl, etc.) don't confuse the LSP server (see apache#3812).
matthiasblaesing added a commit to matthiasblaesing/netbeans that referenced this issue Sep 16, 2024
…ment sychronously on startup

- Run open document registration in LSP servers synchronously with
  initialization
- Instead of spinning custom RequestProcessors use the existing queue
  on the LSP Bindings via runOnBackground
- Where possible drop RequestProcessor usage and run code directly

Closes: apache#3812
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature A feature request
Projects
None yet
2 participants