[2.0M4] Dependencies between models within same Solution Follow
Hi,
i have some trouble with dependencies between models (within same solution, but i think that doesn't matter here) when generating:
Model1 contains nodes that are being reduced/transformed to j.m.b.s.ClassConcept-instances during generation. The nodes have a Type can be used from within baseLanguage.
Model2 contains direct instances of j.m.b.s.ClassConcept-instances, which reference the nodes in Model1.
When the generator finished, the reference from the j.m.b.s.ClassConcept-instances in Model2 doesn't link to the (generated) j.m.b.s.ClassConcept-instances in Model1 (btw: if i put all into the same model it works perfectly!).
To drag the problem down (or to find a suitable workaround) i created a simpler example:
Created Test-Solution with two models containing an j.m.b.s.ClassConcept-instance each, let's say Test1 (ModelA) and Test2 (ModelB) whereas Test1 references Test2. If i now "Make that Solution" it actually works, but the transient Test1 in ModelA@1_0 still reference the Test2 from the Solutions ModelB! Shouldn't transient Test1 in ModelA@1_0 reference transient Test2 in ModelB@1_0??
I think, that is actually what makes the sample from the beginning NOT WORK: The ClassConcepts from Model2 still reference the unreduced/untransformed nodes from Solutions Model1 which obviously are no ClassConcept-instances (though they are correctly generated into Model1@x_x)!
Is it a bug in MPS or am i doing something wrong? Is there a solution in shipped MPS-languages where something similar is done and i can have a look at it? Do i have to label the transformation
Regards,
Mirko
i have some trouble with dependencies between models (within same solution, but i think that doesn't matter here) when generating:
Model1 contains nodes that are being reduced/transformed to j.m.b.s.ClassConcept-instances during generation. The nodes have a Type can be used from within baseLanguage.
Model2 contains direct instances of j.m.b.s.ClassConcept-instances, which reference the nodes in Model1.
When the generator finished, the reference from the j.m.b.s.ClassConcept-instances in Model2 doesn't link to the (generated) j.m.b.s.ClassConcept-instances in Model1 (btw: if i put all into the same model it works perfectly!).
To drag the problem down (or to find a suitable workaround) i created a simpler example:
Created Test-Solution with two models containing an j.m.b.s.ClassConcept-instance each, let's say Test1 (ModelA) and Test2 (ModelB) whereas Test1 references Test2. If i now "Make that Solution" it actually works, but the transient Test1 in ModelA@1_0 still reference the Test2 from the Solutions ModelB! Shouldn't transient Test1 in ModelA@1_0 reference transient Test2 in ModelB@1_0??
I think, that is actually what makes the sample from the beginning NOT WORK: The ClassConcepts from Model2 still reference the unreduced/untransformed nodes from Solutions Model1 which obviously are no ClassConcept-instances (though they are correctly generated into Model1@x_x)!
Is it a bug in MPS or am i doing something wrong? Is there a solution in shipped MPS-languages where something similar is done and i can have a look at it? Do i have to label the transformation
Regards,
Mirko
Please sign in to leave a comment.
i think it has something to do with the subsequential generator-execution of the two involved models. I have a Label "remembering" the transformation of nodes in Model1 to j.m.b.s.ClassConcept-instances. For generation od j.m.b.s.ClassConcept-instances in Model2 that label doesn't seem to exist anymore.
Do i have to possibility to transfer labels across models? If yes, how do i handle the order of model-generation when generating the whole solution/project (obviously Model1 must be generated in precedence to Model2)? Or is MPS able to resolve the order itself?
Thanks in advance,
Mirko
1. It is simple. Each model can be regenerated independently (one by one). There is no required order of generation, thus there is no cycles. To handle a cycle we need to generate all models together and it is time and especially memory consuming.
2. Only your generator knows which external transient models it requires. It is tricky to build the right order before the generation starts. Your generator participates at some point during the generation whereas at the very beginning there can be no statements using its language.
3. Ok, we store all intermediate models in the cache (at least if you have incremental generation with caches on). Besides the order there is another problem - different models are handled using different sets of generators. If you generator is executed at step 3 for model A, for model B it's step number can be any positive number. There is no evident mapping between steps for different models.
How we solve it in MPS:
1. Refer to the last model in the sequence. In case of java, refer to generated java classes (using stubs).
http://forum.jetbrains.com/thread/Meta-Programming-System-486
How one could reference static inner class? If I simply use "[" + node.model.name + "]" + node.name, MPS tries reference this class as if it is a root class and not the inner one.