The xmlPersistence module implements the persistence logic. The persistence type in MPS is set on the per-model level. In our simplified case, the sample can store a model, which is restricted to a single XMLFile root element of the jetbrains.mps.core.xml language, into plain XML documents. The actual The actual XML parsing logic resides in the XmlConverter class, while the XmlModelPersistence class implements the essential interfaces for hooking into the internal workings of MPS.
You need to implement the method #getPreferredDataSourceTypes() which returns the data source types which this model factory associates itself with. We have several bundled data source types in the PreinstalledDataSourceTypes class.
If one does not introduce new types of data sources then he could return just the data source types of the bundled data sources. Otherwise he needs to provide the data source type of his specific data source.
Also it is absolutely important for each ModelFactory implementor to provide the identifier of the implementing factory. That means that one needs to implement the ModelFactory#getType() method.
The purpose of this method is to make each ModelFactory replacable (anyone can register a model factory with the same id thus effectively replacing the persistence format logic).
The getFormatTitle() method is worth a special mention here, since the string it returns will be used to represent the storage format to the future users.
Additionally, the getFileExtension() method will register our custom persistence for .xml files.
Also notice that the module has a Plugin ID set a Plugin ID set in the Idea Plugin tab of its module properties:
The identifier must match the plugin identifier declared in the plugin (xml) descriptor inside the xmlPersistence.ideaPlugin solution. We add an IDEA plug-in identifier to the properties of the xmlPersistence solution in order to specify that the solution is part of the plugin and thus can reference (or load at runtime) any plugin's classes.