lsp4j icon indicating copy to clipboard operation
lsp4j copied to clipboard

Initialization-state handling

Open PerMildner opened this issue 6 years ago • 3 comments

When implementing a LSP server it would be nice if LSP4J could maintain the initialization-state, e.g. automatically respond with the required errors if a request arrives before initialize or after shutdown.

A bug in Sublime Text (LSP 0.8.5) sometimes cause it to send a spurious shutdown message before a didOpen and with automatic state-handling in LSP4J these kinds of client bugs would be easier to pinpoint (and it would attach the blame with the buggy client instead of with a possibly crashing server).

It is of course trivial to do the necessary state handling in (all) the server(s) without support in LSP4J but it seems reasonable to move such common functionality to LSP4J.

PerMildner avatar Aug 03 '19 12:08 PerMildner

LanguageServer is an interface. How could LSP4J provide this functionality? Add an abstract class that implements that interface, to be used as superclass for your implementation?

spoenemann avatar Aug 19 '19 08:08 spoenemann

Indeed. This functionality does not belong in the LanguageServer interface. It would reside in the parts of LSP4J that call methods in LanguageServer.

For instance, before LSP4J has called LanguageServer.initialize(), LSP4J knows that most LSP requestes and notifications should return an error to the client immediately, and LSP4J should not call the corresponding method in LanguageServer.

PerMildner avatar Aug 19 '19 09:08 PerMildner

I tend to regard such default method implementations as out of scope for LSP4J, but we can keep this open to see whether there is more interest about that.

spoenemann avatar Aug 19 '19 12:08 spoenemann