[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] [ATL] Varying rule behavior

Hi,

We have a rule that behaves differently depending on the order of one of its target destinations.

We can see (below) that the difference between A & B is the order of the kdmSig to target. The first rule (A) throws the method unit at the end of the generated model and rule B produces a correctly structured output model, but without the correct XMI.

What are the "rules" about ordering of target and why are we getting those results? I would have thought that it either didn't matter or that A would have been the correct choice. Other area of our transformation use the pattern in A (based on the Modisco work).

Next, what is it that can affect the XMI in the output?

Cheers,
Alain


Rule A :
rule CreateMethods {
from stmConcreteNode : STM!StConcreteNode (
stmConcreteNode.concreteId = 'MethodDeclaration'
)
using {
exportKind:String = stmConcreteNode.getVisibility('./StConcreteNode[@concreteId=\'MethodDeclaration_Modifier\']/StToken[1]/@image');
}
to
kdmSig : kdm!Signature (
name <- 'sig'
),
kdmClass: kdm!MethodUnit (
name <- stmConcreteNode.getChildren('MethodDeclarator') -> collect (e | e.children) -> flatten().first().image,
export <- stmConcreteNode.getExport(exportKind),
codeElement <- kdmSig
)


}

Rule B :
rule CreateMethods {
from stmConcreteNode : STM!StConcreteNode (
stmConcreteNode.concreteId = 'MethodDeclaration'
)
using {
exportKind:String = stmConcreteNode.getVisibility('./StConcreteNode[@concreteId=\'MethodDeclaration_Modifier\']/StToken[1]/@image');
}
to
kdmClass: kdm!MethodUnit (
name <- stmConcreteNode.getChildren('MethodDeclarator') -> collect (e | e.children) -> flatten().first().image,
export <- stmConcreteNode.getExport(exportKind),
codeElement <- kdmSig
),
kdmSig : kdm!Signature (
name <- 'sig'
)


}


Result A :
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:code="http://kdm.castortech.com/spec/KDM/1.0/code"; xmlns:kdm="http://kdm.castortech.com/spec/KDM/1.0/kdm";>
<kdm:Segment>
<model xsi:type="code:CodeModel" name="My project">
<codeElement xsi:type="code:Package" name="abc">
<codeElement xsi:type="code:ClassUnit" name="MyTestJavaCode">
<codeElement xsi:type="code:MemberUnit" name="myField" export="private"/>
<codeElement xsi:type="code:MemberUnit" name="myIntegrateField" export="private"/>
</codeElement>
</codeElement>
<codeElement xsi:type="code:LanguageUnit" name="Common Java datatypes">
<codeElement xsi:type="code:BooleanType" name="boolean"/>
<codeElement xsi:type="code:CharType" name="char"/>
<codeElement xsi:type="code:FloatType" name="float"/>
<codeElement xsi:type="code:FloatType" name="double"/>
<codeElement xsi:type="code:IntegerType" name="int"/>
<codeElement xsi:type="code:IntegerType" name="long"/>
<codeElement xsi:type="code:VoidType" name="void"/>
<codeElement xsi:type="code:VoidType" name="null"/>
</codeElement>
</model>
</kdm:Segment>
<code:MethodUnit name="myMethod1">
<codeElement xsi:type="code:Signature" name="sig"/>
</code:MethodUnit>
<code:MethodUnit name="myMethod2">
<codeElement xsi:type="code:Signature" name="sig"/>
</code:MethodUnit>
<code:MethodUnit name="getProduct">
<codeElement xsi:type="code:Signature" name="sig"/>
</code:MethodUnit>
</xmi:XMI>



Result B :
<?xml version="1.0" encoding="ISO-8859-1"?>
<kdm:Segment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:code="http://kdm.castortech.com/spec/KDM/1.0/code"; xmlns:kdm="http://kdm.castortech.com/spec/KDM/1.0/kdm";>
<model xsi:type="code:CodeModel" name="My project">
<codeElement xsi:type="code:Package" name="abc">
<codeElement xsi:type="code:ClassUnit" name="MyTestJavaCode">
<codeElement xsi:type="code:MethodUnit" name="myMethod1">
<codeElement xsi:type="code:Signature" name="sig"/>
</codeElement>
<codeElement xsi:type="code:MethodUnit" name="myMethod2">
<codeElement xsi:type="code:Signature" name="sig"/>
</codeElement>
<codeElement xsi:type="code:MethodUnit" name="getProduct">
<codeElement xsi:type="code:Signature" name="sig"/>
</codeElement>
<codeElement xsi:type="code:MemberUnit" name="myField" export="private"/>
<codeElement xsi:type="code:MemberUnit" name="myIntegrateField" export="private"/>
</codeElement>
</codeElement>
<codeElement xsi:type="code:LanguageUnit" name="Common Java datatypes">
<codeElement xsi:type="code:BooleanType" name="boolean"/>
<codeElement xsi:type="code:CharType" name="char"/>
<codeElement xsi:type="code:FloatType" name="float"/>
<codeElement xsi:type="code:FloatType" name="double"/>
<codeElement xsi:type="code:IntegerType" name="int"/>
<codeElement xsi:type="code:IntegerType" name="long"/>
<codeElement xsi:type="code:VoidType" name="void"/>
<codeElement xsi:type="code:VoidType" name="null"/>
</codeElement>
</model>
</kdm:Segment>