| Why does a statement that was removed from it's block still appear in the serialized model? [message #982852] |
Tue, 13 November 2012 08:21  |
Andreas Brieg Messages: 48 Registered: November 2012 |
Member |
|
|
I would like to know, why a Java statement that was removed from it's block by applying a transformation still shows up in the refined model when the transformation was applied? The transformation removes all if statements from it's blocks and looks like this:
-- @atlcompiler atl2010
-- @nsURI Java=http://www.eclipse.org/MoDisco/Java/0.2.incubation/java
module DropIfStatements;
create outputJava: Java refining javaInput: Java;
rule removeIfStatementsFromBlocks {
from
inputBlock: Java!Block
using {
filteredStatements: Sequence(Java!Statement) = inputBlock.statements -> select(e
| not e.oclIsKindOf(Java!IfStatement));
}
to
outputBlock: Java!Block (
comments <- inputBlock.comments,
originalClassFile <- inputBlock.originalClassFile,
originalCompilationUnit <- inputBlock.originalCompilationUnit,
statements <- filteredStatements
)
}
I tested this on a small Java model, where only a single if statement exists. The if statement still appears in it's block after the above transformation was applied.
I'm using Juno with ATL SDK 3.3.1.
|
|
|
| Re: Why does a statement that was removed from it's block still appear in the serialized model? [message #983030 is a reply to message #982852] |
Tue, 13 November 2012 11:13   |
Hugo Bruneliere Messages: 447 Registered: July 2009 |
Senior Member |
|
|
One general comment first: the following lines are not required as already implied by the ATL Refining Mode.
comments <- inputBlock.comments,
originalClassFile <- inputBlock.originalClassFile,
originalCompilationUnit <- inputBlock.originalCompilationUnit,
About the computed filteredStatements variable, are you sure that the Java!Block you are matching with your rule is actually the direct container of the Java!IfStatement (in other words, that the Java!IfStatement is not actually contained into a sub-element of this Java!Block)?
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
|
|
| Re: Why does a statement that was removed from it's block still appear in the serialized model? [message #983850 is a reply to message #983089] |
Wed, 14 November 2012 02:36  |
Andreas Brieg Messages: 48 Registered: November 2012 |
Member |
|
|
This is related to a bug where the editor removes the drop keyword from the to clause. The complete transformation I used was:
-- @atlcompiler atl2010
-- @nsURI Java=http://www.eclipse.org/MoDisco/Java/0.2.incubation/java
module DropIfStatements;
create outputJava: Java refining javaInput: Java;
rule dropIfStatements {
from
statement: Java!IfStatement
to drop
}
rule removeIfStatementsFromBlocks {
from
inputBlock: Java!Block
using {
filteredStatements: Sequence(Java!Statement) = inputBlock.statements -> select(e
| not e.oclIsKindOf(Java!IfStatement));
}
to
outputBlock: Java!Block (
statements <- filteredStatements
)
}
But accidentally I executed the transformation after I have formatted it. So the drop keyword wasn't there.
I tried again and the if statement is removed from the model. I can also confirm that I only need the rule dropIfStatements. The removal of the if statements from their block isn't necessary.
Thanks for help.
|
|
|
Powered by
FUDForum. Page generated in 0.04728 seconds