How to set the order of the mapping configurations?

I am currently trying to create a simple Entity-To-View converter. The idea is to have a custom object "Entity" and another custom object "View" and generate the JPA entity a view object and a converter between these two with MPS. So i have set up a generator which contains (among other things) two mappings:

One which converts the "View" into a java class (called "views") and another which converts the "View" into a converter java class (called "converters"). Now since the converter requires the view, i want the "converters" mapping to run after the "views" mapping so that I can use mapping labels to get the generated view class.

I tried to set this up in the "Generator Priorities" (as shown here: but once I set that priority, the "converters" mapping configuration is no longer executed anymore and therefore no converter is being generated.


I am probably setting something up the wrong way. Can someone help me in setting this dependency up correctly?
Could it be that the View is no longer present in the input model, when the converters are generated? I suspect it may have been consumed when views were generated. Maybe the "keep input roots" option in the root mapping rule could be of help here?

You may try the "Show Generation Plan" option in model's context menu to see the plan that the generation has built.

BTW, the link to the doc points to an MPS 3.0 version. Not that there have been so many changes, but would be safer.
Ok i will try that. Thank you. On a related note, am I supposed to get email notification on starred forum topics? Sending a test email from the profile works but I am not notified when someone answers to my watched threads.
I'm not sure, I would expect the star on a thread to guarantee notifications. Maybe you need to mark the whole MPS forum as "Watching" or "Daily Digest" as well, if the star has no effect and provided the e-mail has not been blocked by your spam filter.
Okay, so "Keep Input Roots" definitely helped. I'm not really able to decipher the output of "Show Generation Plan", is there some description about what all the outputted text actually means?

  Ignored mapping priority rules:  
Generator for language jetbrains.mps.lang.generator.generationContext defines invalid priority rule [jetbrains.mps.lang.generator.generationContext/:*] strictly_together [jetbrains.mps.lang.pattern/:*], with no mapping configurations specified at one side. The rule is ignored.  
---------------------  mappings partitioning  -----------------------------------  
 [ 1 ]  
 [ 2 ]  
 [ 3 ]  
 [ 4 ]  
 [ 5 ]  
 [ 6 ]  
 [ 7 ]  
 [ 8 ]  
 [ 9 ]**  
 [ 10 ]*  
13 roots, 1 components  
#0(13):  entities Converter converters weave_ViewProperty View views reduce_ViewProperty returnTypeOf_Finder reduce_Finder daos Dao reduce_Property Entity  
13 roots, 12 components  
#0(1):  Entity  
#1(1):  reduce_Property  
#2(1):  entities  
#3(1):  Dao  
#4(1):  returnTypeOf_Finder  
#5(1):  reduce_Finder  
#6(1):  daos  
#7(1):  View  
#8(2):  views reduce_ViewProperty  
#9(1):  Converter  
#10(1):  weave_ViewProperty  
#11(1):  converters   


With the "keep input roots" enabled, generation now goes a bit further but I am getting strange error messages that the context node for my one weaving template could not be defined. Is there some way to debug all the scripts that you enter, so you can basically see what kind of node a script is currently working on and what it is returning?
You can enable showing transient models (the bottom right corner of the MPS window), so that after generation all the intermediate models get stored at the bottom of your project tree (in the left-hand side project view).
Some more details are to be found here:

The generation plan shows the names and order of all generators that will be run when generating the selected model.
Hi Vaclav, thank you very much for these instructions. From what I see, the generation order now seems to be OK however I still struggle to get references resolved in my "Converter" class. As you can see first the "views" generator runs, which creates my AgentView class from the AgentView element of my custom language.
. Then the second step runs both the "entities" and "converter" generators. The generated AgentViewConverter class references both to the AgentView class generated by "views" and the Agent class generated by "entities". It uses the genContext.get output <mapping label> for (<node>) method to reference both outputs.


However in the final output only the references to the Agent class are resolved but not the references to the AgentView class.

This leads to compilation errors further down the road. Are mapping labels only valid within the same generator phase? If so, how can I reference stuff that has been generated in an earlier phase?
Hello Jan,

indeed, mapping configurations are not visible across different generation steps.

Is there anything that prevents you from joining the two phases into one, maybe even a single mapping configuration with two (or more) root mapping rules? The reference macros should be processed correctly only after all classes have been generated and added to mapping labels.

Hi Vaclav,

it seems that I fundamentally misunderstood the way in which root mapping rules work. I thought that once a root mapping rule processed an input element, that input element will not be processed by another root mapping rule. Therefore I thought that you cannot have two root mapping rules which use the same concept as input. And that's why I came up with multiple mapping configurations when I in fact don't even need them. I just tried adding multiple root mappings and it indeed solves my problem :) Thank you very much for this eye-opener.


>Is there anything that prevents you from joining the two phases into one, maybe even a single mapping configuration with two (or more) root mapping rules?


I've got similar problem and I tried to reuse mapping labels from one mapping configuration in subsequent one. It looks like mapping labels are not accessible in between mapping configurations. Are there ways to workaround that except merging all the configs into single mapping config? (I use multiple languages so it is not quite possible to use single mapping configuration)

By the way, multiple mapping configurations produce multiple transient models, so they make it easier to debug the generation.


I believe the mapping configurations need to be run in the same phase of generation (and the model with the labels has to be imported in the other generator model).


I could add that running mapping configurations in the same generation step is achieved either by generator priorities (generator module properties dialog, priorities tab) which is the old method, or with the help of a new feature


Please sign in to leave a comment.