Skip to content

Latest commit

 

History

History
159 lines (106 loc) · 5.5 KB

converter-lang.adoc

File metadata and controls

159 lines (106 loc) · 5.5 KB

Reference for LionWeb Converter Language

LionWeb-MPS converts Languages and instance models between several different representations. We provide concepts to easily configure and execute all available converters.

To use the converters, add the language io.lionweb.mps.converter.lang to your model. Create the desired converter as root node. Execute the conversion through an intention on the converter. Check the Messages Pane for results.

1. MPS Language → JSON

1.1. Export MPS Language to JSON

Technical name: ExportMpsLanguageToJson / Language2JsonConverter

Converts a list of MPS Languages to LionCore JSON. We use MPS' Runtime Language representation.

Requires a file path to write the JSON file to. We can use path variables.

Caution
Existing files will be overwritten without notice!

MPS Language A depends on all languages that are listed in A.structure's Model Properties Dependencies.

We can choose the scope of conversion:

listed

Only convert the listed languages. Fails if any of the converted languages depends on a non-listed language.

indirect

Convert all listed languages, and (transitive) dependencies.

fineGrainedClosure

Converts all listed languages completely. If any element in the listed languages uses an element from a non-listed language, we include the element of the non-listed language — but not any other elements of that non-listed language. We apply this strategy (known as tree shaking) transitively until we included all used elements.

We can set some flags for special annotation handling:

export description annotations

Whether concept descriptions should be exported as instances of io.lionweb.mps.specific.lang.MPS-specific annotations.ConceptDescription.

export special annotations

Whether special concept annotations should be exported:

  • jetbrains.mps.lang.structure.structure.DeprecatedNodeAnnotationio.lionweb.mps.specific.lang.MPS-specific annotations.Deprecated

2. MPS Instance Model ↔ JSON

2.1. Export Instance to JSON

Technical name: ExportInstanceToJson / AMps2LionWebConverter

Converts a list of MPS nodes to LionWeb JSON.

Requires a file path to write the JSON file to. We can use path variables.

Caution
Existing files will be overwritten without notice!

We can choose the scope of conversion:

listed

Only converts the listed nodes.

descendants

Converts the listed nodes, and all descendants of each listed node.

closure

Converts the listed nodes, all descendants, and all referenced nodes. We apply this strategy until we include all Annotation, Containment, and Reference targets.

Inclusion of nodes and ids

The following table lists for each scope whether we include the target node / target node’s id into the conversion. Example: For descendants scope, we include both the target node and the target id of annotations and children; we do not include the target node of references, but we do include the target id of references.

Scope Annotations + Children References Parents

listed

no / yes

no / yes

no / yes

descendants

yes / yes

no / yes

no / yes

closure

yes / yes

yes / yes

no / yes

2.2. Import Instance from JSON

Technical name: ImportInstanceFromJson / MergingLionWeb2MpsConverter

Converts a LionWeb JSON file into MPS nodes, stored into the current model. If the current model already contains a node with the same id as an imported node, we merge them.

Requires a file path of the JSON file to read. We can use path variables.

3. LionCore M3 ↔ JSON

3.1. Export Language to JSON

Technical name: ExportLanguageToJson / LionCore2JsonConverter

Converts a list of io.lionweb.mps.m3 instances to LionCore JSON.

Requires a file path to write the JSON file to. We can use path variables.

Caution
Existing files will be overwritten without notice!

3.2. Import Language from JSON

Technical name: ImportLanguageFromJson / Json2LionCoreConverter

Converts a LionCore JSON file to io.lionweb.mps.m3 instances, stored into the current model.

Requires a file path of the JSON file to read. We can use path variables.

4. MPS Language ↔ LionCore M3

4.1. Convert Language to LionCore

Technical name: ConvertLanguageToLionCore / Language2LionCoreConverter / Mps2LionCoreConverter

Converts a list of MPS Languages to io.lionweb.mps.m3 instances.

We can convert either the Language Nodes (i.e. the structure aspect of the MPS Language) or the Runtime Language (i.e. SLanguage). In doubt, use Language Nodes.

4.2. Convert Language from LionCore

Note
This converter is currently not maintained, but might be reactivated in the future.

Technical name: ConvertLanguageFromLionCore / LionCore2MpsConverter

Converts a list of io.lionweb.mps.m3 instances to MPS Language structure aspects.