Problem with generator context and mps.baselang.statemachine
Hi,
i developed a OfBean concept, which extends the class concept. Actually, i do not need to extend the class concept, but i want to add a mps.baselang.statemachine to my OfBean. I figured out how to get things working in the solution perspective, but generators do not work.
So in the MAPPING_BLSpecific of the statemachine, i found a weaving rule, which add statemachine s status to a class concept. I changed the weaving rule condition, to accept also OfBean, but i get an error for the generation context of the weaving rule:
"bad context for weaving rule: TestEntity is generated from TestEntity, while input node is from TestEntity state machine
TestEntity is an instance of OfBean... (of course the input node is test entity state machien... which has a reference "classConcept" to the OfBean.. So i get the context with:
genContext.get copied output for (node.classConcept)
I have also declared a reduction rule for OfBean, which creates a ClassConcept (the bean)
Any help appreciated.. or is there a cheaper solution?
Dan
i developed a OfBean concept, which extends the class concept. Actually, i do not need to extend the class concept, but i want to add a mps.baselang.statemachine to my OfBean. I figured out how to get things working in the solution perspective, but generators do not work.
So in the MAPPING_BLSpecific of the statemachine, i found a weaving rule, which add statemachine s status to a class concept. I changed the weaving rule condition, to accept also OfBean, but i get an error for the generation context of the weaving rule:
"bad context for weaving rule: TestEntity is generated from TestEntity, while input node is from TestEntity state machine
TestEntity is an instance of OfBean... (of course the input node is test entity state machien... which has a reference "classConcept" to the OfBean.. So i get the context with:
genContext.get copied output for (node.classConcept)
I have also declared a reduction rule for OfBean, which creates a ClassConcept (the bean)
Any help appreciated.. or is there a cheaper solution?
Dan
Please sign in to leave a comment.
i have a mapping rule and a waving rule in the same mapping configuration
root mapping rule:
concept OfClass –> map_OfClass
inheritors false
condition <always>
keep input root default
weaving rule:
concept OfClass –> OfClass_Weaver
inheritors false
condition <always>
context : (node, genContext, operationContext)->node< > {
System.out.println("OfClass Weaver: name is " + node.name);
System.out.println(">" + genContext.get copied output for (node));
genContext.get copied output for (node);
}
But the weaving rule does not find the generated OfClass from the mapping rule... weaving rule: cannot find context node
How comes? I m certainly doing something wrong...
Any help appreciated...
Dan
genContext.get copied output for
( genContext.outputModel.nodes(ClassConcept).first );
But is there no better solution for accessing the generated output for the OfClass?
Best,
Dan
"Bad context for weaving rule" error means that your weaving rule tries to insert (weave) node from one root into another. It breaks incremental generation in the case you need to generate only part of the model (first root is unmodified, we generate only the second one).
"cannot find context node" means your context method returned null.
Weaving rule is a kind of hack, it makes generator hard to understand, cannot be applied in parallel, etc. It's better to avoid using it if possible (replace with a copy_src macro in the appropriate places).