kotlin-language-server icon indicating copy to clipboard operation
kotlin-language-server copied to clipboard

Using KLS and a client in a single JVM

Open pajatopmr opened this issue 4 years ago • 2 comments

Another question: since KLS can be published to maven local, does that mean there is a way to have a client run KLS in the client JVM? This could simplify debugging, speed up tests and probably offer other benefits.

I do something similar by utilizing a fake (mock) language server that uses files to stream messages between the client and server. It helped reduce client testing time (~600 tests) from ~20 seconds to less than 1. It works by capturing the messaging used by a real LS run and putting that messaging into incoming and outgoing files. The implementation is in my Gitlab repo, in case you are interested in having a look.

pajatopmr avatar Mar 05 '21 06:03 pajatopmr

You should be able to spin up a KotlinLanguageServer instance, like in Main.kt, but with your own input/output streams.

fwcd avatar Mar 05 '21 14:03 fwcd

Yeah, I thought of that but got stuck on exactly what kind of streams to use. I know only of String, File, Process and socket but none of those seem like a right solution for a single JVM solution. What kind of streams would you be inclined to use in a case like this?

pajatopmr avatar Mar 05 '21 15:03 pajatopmr