0

We're currently testing the connection between the Language Server with an instance of the EMFCloud.ModelServer. We're able to save/edit our Semantic Model in the Model Server workspace as it is described in the following answer. Basically, the Language Server handles our custom language using *.abcl files and when the user saves changes in the file, the Language Server reacts on the didSave action and saves the AST (EMF model) in the Model Server (using XMI) in a file *.abc (foo.abcl converted to -> foo.abc). The AST (EMF model) is now available for other EMF modelling editors (i.e. a Theia tree editor) where we can, for example rename a node or change attributes in a different manner.

What we're currently trying to achieve now is the Language Server to react on changes done by other editors on our AST (*.abc files). To do so, the Language Server is subscribed to events on the Model Server and eventually receive a "fullUpdate" event indicating that the AST changed.

Our problem is how to proceed now. We can think about the following workflow:

  1. Model Server sends new model to Language Server (via subscription mechanism)
  2. The Language Server replaces the AST with the new model
  3. Serialize the new AST and cache it into a Document?
  4. At this point the *.abcl file (opened by the editor) is not in sync with the internal AST
    • Maybe the Language Server forwards the serialization (text representation) to the editor ?
    • Maybe the Language Server overwrites the *.abcl file in the workspace ?

Some guidance would be really appreciated

EDIT: Posted also a question on Eclipse Forums

1 Answers1

0

During research of the internals of the Language Server and after doing some testing, I've figured out a way how the Language Server can react when the semantic model (AST) is updated/changed externally by means of another editor (i.e. a tree editor). The following is a possible workflow:

  1. The Model Server notifies an external change (i.e. full model update) to the Language Server by sending a new full model instance. See subscribe method
  2. Language Server reads a copy of the internal semantic model (AST).
  3. Language Server replaces the contents of the semantic model copy with the new full model instance.
  4. Language Server serializes (transforms from EMF to textual representation) the new full model instance to a String object.
  5. Language Server notifies the Language Server client about the update received and asks whether the changes are accepted.
    • If the user accepts the changes
      1. the model serialization (String) is sent to the client to replace the current contents of the text representation (workspace/applyEdit LSP method). "null" is sent as version value so the client decides the new version.
      2. client receives the changes and automatically sends a "didChange" notification back to the server with the new status of the text representation. This requests will trigger an internal build in the Language Server resulting in an update of the actual semantic model (AST)
      3. At this point the client + AST + Model Server model will be in sync.
    • user rejects the changes
      1. At this point the client + AST will still be in sync
      2. The model in the Model Server will not be in sync with the client + AST
      3. Text editor will show different information as other editors