I'm currently trying to figure out how to "connect" an Xtext Language Server with an EMFCloud.ModelServer instance so each time a client (VS Code extension in my case) saves a custom DSL text file, the Language Server saves the AST as XMI
(or JSON
). So then later the model can be included in the Model Server workspace and other editors can react to changes on my model (XMI
, JSON
)
So far I've seen that the current Xtext LS version does nothing with the "textDocument/didSave" notifications:
@Override
public void didSave(DidSaveTextDocumentParams params) {
// nothing to do
}
I'd like to enhance my LS instance to provide logic to that method and persist the current AST to XMI/JSON
.
So far I was able to see that there is a generator
class which the doGenerate
method is called when the save is triggered on client side. However, taking a look to the call hierarchy of that method, it seems that is called within a "code generation" process. The documentation found for this is always related to other language generation (i.e. Java
or c++
) and I'm not sure if this would be the right place also because it seems that the file URI is not accessible (as it is in the didSave
method of the LS part)
As summary, is there a way to access the semantic model (AST) from the Language Server "didSave" operation?