eclipse-lsp4j / lsp4j

A Java implementation of the language server protocol intended to be consumed by tools and language servers implemented in Java.

Home Page:https://eclipse.org/lsp4j

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InlineValueText JSON messages cannot be parsed

bastiandoetsch opened this issue · comments

It looks to me as if LSP4j has a problem parsing InlineValueText:

Input JSON:

{"jsonrpc":"2.0","id":"2","result":[{"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":2147483647}},"text":"IaC Test InlineValue"}]}

Exception:

com.google.gson.JsonParseException: Ambiguous Either type: token BEGIN_OBJECT matches both alternatives.
	at org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter.create(EitherTypeAdapter.java:193)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter.read(EitherTypeAdapter.java:177)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter.read(EitherTypeAdapter.java:40)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.CollectionTypeAdapter.read(CollectionTypeAdapter.java:114)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.CollectionTypeAdapter.read(CollectionTypeAdapter.java:40)
	at com.google.gson.Gson.fromJson(Gson.java:1227)
	at com.google.gson.Gson.fromJson(Gson.java:1186)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.fromJson(MessageTypeAdapter.java:345)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.parseResult(MessageTypeAdapter.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:125)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:57)
	at com.google.gson.Gson.fromJson(Gson.java:1227)
	at com.google.gson.Gson.fromJson(Gson.java:1186)
	at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:119)
	at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:114)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:193)
	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:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Reference: Came up when implementing eclipse/lsp4e#702

@bastiandoetsch Thanks for reporting the issue.

The JSON type adapter for InlineValue is missing. I'll take care of it.

Thanks!

@bastiandoetsch You can try the latest integration build with the fix: https://download.eclipse.org/lsp4j/builds/main/.