Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Why does a statement that was removed from it's block still appear in the serialized model?
Why does a statement that was removed from it's block still appear in the serialized model? [message #982852] Tue, 13 November 2012 13:21 Go to next message
Andreas Brieg is currently offline Andreas BriegFriend
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 16:13 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 612
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 #983089 is a reply to message #983030] Tue, 13 November 2012 17:10 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 523
Registered: July 2009
Senior Member
In refining I think you can't filter like that, instead you have to drop the elements that are not needed.
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 07:36 Go to previous message
Andreas Brieg is currently offline Andreas BriegFriend
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.
Previous Topic:Why is the ATL editor removing the drop keyword?
Next Topic:How to compare model attribute that contains an enum with an enum constant?
Goto Forum:
  


Current Time: Wed Nov 26 21:57:51 GMT 2014

Powered by FUDForum. Page generated in 0.01642 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software