eclipsesource / graphical-lsp

Graphical language server platform for building web-based diagram editors
https://www.eclipse.org/glsp
Eclipse Public License 2.0
36 stars 8 forks source link

Introduce EMF-based graph model on the server #272

Closed planger closed 5 years ago

planger commented 5 years ago

This change introduces an EMF-based graph (called GModel) in place of the SModel on the server. The serialization and deserialization of SModel compatible JSON is done with Gson customizations that are used for LSP4J as well as for loading and writing models from the file system. Therefore a type map indicates which type (e.g. "task:manual") is mapped to which EClass. This type map is configured DI of type GraphGsonConfiguratorFactory, which can register custom EPackages alongside the base GraphPackage and a type map. This is then picked up by the Gson configuration as well as in a few other places (e.g. to create an instance of a node).

We also introduce a dedicated GModelIndex instead of the old SModelIndex which builds on EMF's cross referencer and content adapter. So it is not necessary anymore to explicitly add or remove added or removed elements to the index.

With the help of the index and custom code in GEdge, we can resolve ID based references, such as source and target and therefore have support for edge.getSource() : GModelElement as well as edge.setSource(GModelElement). You can choose whether you want to read and write those references via ID or via the actual object reference.

Things to be done in follow up changes (I'll create issues for them as soon as this is merged):

Closes #231

planger commented 5 years ago

Thanks a lot for the fast review!

If I'm not mistaken there are now only some minor dependencies to the sprotty server plugins. Maybe we could remove these dependencies entirely in a follow-up PR. This would be especially helpful for the p2-generation.

Yes, you're right! I think the only reason we need the dependency is the HtmlRoot, which would be easy to add. I'll open up a ticket for a follow-up change.

On a side note: What formatting settings for Eclipse are you using? I think we do not use the same settings which causes a lot of (more or less) unnecessary changes like adding/removing blank lines Maybe we should agree on standard settings here.

I use the default Eclipse built-in formatter of a 2019-3 Eclipse IDE. However, it may well be the case that I added/removed blank lines here and there for my personal code feng shui -- sorry about that.

I addressed your feedback in 3fcc48a. Nice catch re the min width and height, btw! :+1:

tortmayr commented 5 years ago

:+1: Looks good to me. I have to do some preparatory steps in the glsp-p2 repository to ensure succesfull deployment before we can merge this.