metals-eclipse icon indicating copy to clipboard operation
metals-eclipse copied to clipboard

Plugin breaks when goto definition is used with a source file from jar

Open tgodzik opened this issue 5 years ago • 3 comments

I was playing around with the Metals Eclipse plugin nad it seems that some new version broke goto definition. After doing go to definition on an outside symbol it goes to .metals/readonly and the server stops responding altogether. The only messages we get it seem is something about broken Json RPC messages:

SEVERE: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
	at com.google.gson.Gson.fromJson(Gson.java:900)
	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.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
	at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:92)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:55)
	at com.google.gson.Gson.fromJson(Gson.java:888)
	... 10 more

Oct 21, 2019 9:59:42 PM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
{"jtent-Length: 725der Content-Length in input "

"
{"jtent-Length: 725ateException: Missing header Content-Length in input "

"
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:91)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

@mundacho Any idea what might be going on and where we can look?

I was planning on showing a bit of Eclipse integration during EclipseCon.

tgodzik avatar Oct 21 '19 20:10 tgodzik

Hello, I'm traveling right now. However the problem there seems to be with lps4e or LSP4j, when I'm back (next week) I'll check in the LSP4e-dev mailing lists to see if I can get some hints. If you can. I think Mickael Istria from the LSP4e mailing list might be able to throw some light on the issue at least.

mundacho avatar Oct 22 '19 09:10 mundacho

Hello, I'm back. Do you have some project where I can reproduce this problem?

mundacho avatar Oct 29 '19 19:10 mundacho

This was on a very simple project like: https://github.com/tgodzik/metals-sample Walked around the code for a while and clicked goto definition on outside symbols Some/Int etc. Might be a flake, haven't managed to get to the bottom of that. Looks like some kind of encoding issue.

tgodzik avatar Oct 30 '19 14:10 tgodzik