lsp4j
lsp4j copied to clipboard
Initialization-state handling
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.
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?
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.
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.