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

ZLS causes LSP4IJ to throw UnsupportedOperationException by requesting workspace/semanticTokens/refresh #385

Closed
fbricon opened this issue Jun 24, 2024 · 5 comments
Assignees
Labels
bug Something isn't working semantic tokens
Milestone

Comments

@fbricon
Copy link
Contributor

fbricon commented Jun 24, 2024

zls requests workspace/semanticTokens/refresh on startup, which LSP4IJ doesn't support, which causes this UnsupportedOperationException:

Internal error: java.lang.reflect.InvocationTargetException

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$recursiveFindRpcMethods$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 com.redhat.devtools.lsp4ij.LanguageServerWrapper.lambda$start$1(LanguageServerWrapper.java:260)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
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:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$recursiveFindRpcMethods$0(GenericEndpoint.java:65)
	... 11 more
Caused by: java.lang.UnsupportedOperationException
	at org.eclipse.lsp4j.services.LanguageClient.refreshSemanticTokens(LanguageClient.java:193)
	... 16 more

Language Servers should not cause LSP4IJ to crash. We should provide no-op implementations of unsupported features instead.

@fbricon fbricon added the bug Something isn't working label Jun 24, 2024
@fbricon
Copy link
Contributor Author

fbricon commented Jun 24, 2024

@FalsePattern have you seen that problem with your semantic highlighting hack?

@FalsePattern
Copy link
Contributor

FalsePattern commented Jun 24, 2024

Known issue, as a workaround, the LSP4IJ branch of ZigBrains uses a custom LanguageClient class provided through the language server factory, which does implement that specific method.

Once lsp4ij 0.3.0 is released, I will finish migrating ZigBrains to it and release 16.0.0 with builtin zls support via lsp4ij instead of the custom ZLS client.

@angelozerr
Copy link
Contributor

angelozerr commented Jun 26, 2024

This issue will be covered correctly when #238 will be done.

I have started to implement in my spare time something by using IJ RainbowVisitor and I can highlight tokens (with awfull color), now I need to manage a better mapping between existing IJ TextAttributes (which manage coloration) and LSP semantic tokens + modifiers.

I'm trying to mimic the same idea than vscode https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#semantic-token-scope-map

@angelozerr angelozerr self-assigned this Jul 4, 2024
@angelozerr angelozerr added this to the 0.3.0 milestone Jul 4, 2024
@angelozerr
Copy link
Contributor

This bug has been fixed since 0.3.0 implements rhis refresh support

@angelozerr
Copy link
Contributor

fixed with #392

@fbricon fbricon closed this as completed Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working semantic tokens
Projects
None yet
Development

No branches or pull requests

3 participants