eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
663 stars 61 forks source link

Improve unknown file type handling in language server #1455

Closed msujew closed 2 months ago

msujew commented 2 months ago

Closes https://github.com/eclipse-langium/langium/issues/1408

Adds a few safeguards for cases in which the language client sends document updates/LSP requests for unknown file types. This is pretty simple to reproduce by renaming a file to another file that cannot be handled by the language server. For the requirements example, from *.tst to *.tstx.

We now filter those updates out before they arrive at the document builder and handle errors for other LSP requests better by returning a ResponseError instead of throwing an error in the code. This massively improves the UX for any user that hits this behavior by accident.

Also fixes a few exports from the ./lsp folder to enable overrides of existing services.

msujew commented 2 months ago

cc @cdietrich the behavior implemented in DocumentUpdateHandler can also be implemented in the DocumentBuilder#update method directly in the existing version of 3.0.