node.parent null for non-root nodes
While training myself about generators I have found a case with the condition stated into the subject. I thought this condition would be true only for root nodes.
The case is the EntityType defined into the Markus Voelter tutorial about entities and attributes. I expect node.parent to be Attribute. node is a parameter of the referent function of the ReferenceMacro.
It's an expected behavior?? Version is 3.1.5 .
Thx,
Mar
The case is the EntityType defined into the Markus Voelter tutorial about entities and attributes. I expect node.parent to be Attribute. node is a parameter of the referent function of the ReferenceMacro.
It's an expected behavior?? Version is 3.1.5 .
Thx,
Mar
Please sign in to leave a comment.
And I think you misunderstood which Attribute concept I'm speaking about, it's not related with smodel.
I'm referring to a simple Entity/Attribute language which instances could be Person and Department.
You define a type EntityType to be able to have for example Person.dept of type Department, a pattern that you probably know very well.
I the instance of EntityType that define the type of the instance Attribute "dept" to be Department, it has parent = null whereas I thought it should point to the "dept" instance.
Could it be that you are returning a calculated type in the "$COPY_SRC$[string] someMember" macro when LOOPing over attributes of an entity? This would then result in an orphaned EntityType instance being reduced and thus passed into the reference macro, I think.
I wonder if the completion dialog in the inspector for the $COPY_SRC$ macro gives you two options for "type", one being the calculate type and the other being the type child of Attribute.
Vaclav
Even if I don't understand why, thanks for your explanation now I know I should not rely on parent in these contexts.
Mine code, which follows the tutorial, behaves as you'd expect:
Inspector for the $COPY_SRC$ macro:
Vaclav
Probably I misunderstood it, see my code below for your curiosity.
I put an extra System.out.println() into the code for clarity.
Into my language I can define an Attribute of type List, in this case I can specify the type of its elements:
The reduction rule for ListType is:
Inside the COPY_SRC macro I have:
During generation I get this on standard ouput:
I'd still be curious to see the details of the $COPY_SRC$ macro that is used to specify the type of the generated Java fields - the one wrapped in a $LOOP$ over entity's attribute, defined inside the root template for Entity. I suspect this might be the place that needs tweaking.
Below the piece of the EntityReference template that generate the Java field:
Inside LOOP node is EntityReference so the LOOP macro is as follow:
The COPY_SRC macro you requested is:
Finally the property macro for myField is:
Let me know if you are interested in further details.
In case I can zip and post here the whole project.
The show warning message you are interested in is inside the reduction rule for ListType.
hearepy.tgz (174KB)
sorry for the delay - we needed to do some investigation on this one, because normally the nodes passed into macros are contained in the AST and thus have their parents properly set.
In your project, however, the model containing the ListType is a different model from the model being generated (containing the EntityContainer), which is not a typical scenario.
Since it causes these troubles, we will revisit the mechanism of generating nodes from the other models in one of the next releases.
Vaclav