Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Problem in a helper
Problem in a helper [message #1058091] Sat, 11 May 2013 00:25 Go to next message
Basma Moukhtar is currently offline Basma MoukhtarFriend
Messages: 27
Registered: June 2010
Junior Member
Dears,

I have a helper that gets all instances of a certain class in my meta model, as follows:

helper   def: getNodes() : Sequence(Flowchart!Node) = 
    Flowchart!Node.allInstances();


But it returns a sequence as follows:

{IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>}

Note that the number of the "IN!<unnamed>" elements in the result sequence is the same number of the nodes in the input file.

Anyone can help?
Re: Problem in a helper [message #1058307 is a reply to message #1058091] Mon, 13 May 2013 14:12 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 616
Registered: July 2009
Senior Member
Hello,

How do you obtain the following display: {IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>}?
Have you tried to use the result of the helper in one of your transformation rules? The result may actually be correct.

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Problem in a helper [message #1058398 is a reply to message #1058307] Mon, 13 May 2013 23:01 Go to previous messageGo to next message
Basma Moukhtar is currently offline Basma MoukhtarFriend
Messages: 27
Registered: June 2010
Junior Member
I obtained this output when I print it in the helper

When I use the result in another rule, it throws exception and the sequence as nulls.
The rule is as follows:


rule DecisionNode2IFStatement
{
	
	from 
		node : Flowchart!Node 
		
	using{
		ifNodes : Sequence(Flowchart!Node) = thisModule.getIfStmts();
	}
		
	to 
		stmt : Java!IfStatement(
			condition<-node.title ,
			statements<-ifNodes->collect(n | thisModule.Node2Stmt )	
			)
	
}



where "Node2Stmt" is another lazy rule :


lazy rule Node2Stmt {
	
	from 
		node : Flowchart!Node 
		
	to
		javaStmt: Java!JavaStatement(
         javaStmt <- node                                   
      )
	
}


And the exception is (the important parts are red and bold):

org.eclipse.m2m.atl.engine.emfvm.VMException
at __resolve__#3(Flowchart2Java.atl)
local variables: self=Flowchart2Java : ASMModule, value=<null>
at __resolve__#26(Flowchart2Java.atl)
local variables: self=Flowchart2Java : ASMModule, value=Sequence {<null>, <null>, <null>, <null>, <null>, <null>, <null>, <null>, <null>, <null>, <null>, <null>, <null>}, e=<null>
at __applyDecisionNode2IFStatement#31(Flowchart2Java.atl[130:4-130:59])
local variables: self=Flowchart2Java : ASMModule, link=TransientLink {rule = DecisionNode2IFStatement, sourceElements = {node = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@5246e0 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false))}, targetElements = {stmt = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@a4599e (eClass: org.eclipse.emf.ecore.impl.EClassImpl@dbfedf (name: IfStatement) (instanceClassName: null) (abstract: false, interface: false))}, variables = {ifNodes = [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@84dd5c (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@e0cc83 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@92d5f0 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1babf7 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@b70709 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@2ef3ba (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@83562d (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@8ed5db (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@17a4528 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@5246e0 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1ab4552 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1543047 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false)), org.eclipse.emf.ecore.impl.DynamicEObjectImpl@2d8b20 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@17b4941 (name: Node) (instanceClassName: null) (abstract: false, interface: false))]}}, node=IN!<unnamed>, stmt=OUT!<unnamed>, ifNodes=OrderedSet {IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>, IN!<unnamed>}



Thanks a lot for your help and Sorry for the long message.

[Updated on: Tue, 14 May 2013 08:14]

Report message to a moderator

Re: Problem in a helper [message #1058622 is a reply to message #1058398] Tue, 14 May 2013 14:54 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 616
Registered: July 2009
Senior Member
Hello,

Where is your "getNodes" helper actually called from?
I cannot see it in the rules you've described.

Also, considering that your helper returns a static value, you should use a helper attribute (getNodes without parenthesis) rather than a helper function (getNodes with parenthesis) so that it is only computed once.

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Problem in a helper [message #1058759 is a reply to message #1058622] Tue, 14 May 2013 23:15 Go to previous messageGo to next message
Basma Moukhtar is currently offline Basma MoukhtarFriend
Messages: 27
Registered: June 2010
Junior Member
Sorry, My helper name is getIfStmts.
It's called in the using section in the rule "DecisionNode2IFStatement".

I don't use an attribute helper, because later I will need to send a parameter to this helper (range of nodes' ids).
But now I was just testing a small part.
Re: Problem in a helper [message #1058798 is a reply to message #1058759] Wed, 15 May 2013 07:32 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 523
Registered: July 2009
Senior Member
Have you tried the correct syntax :
statements<-ifNodes->collect(n | thisModule.Node2Stmt(n) )	
?
Re: Problem in a helper [message #1058821 is a reply to message #1058798] Wed, 15 May 2013 09:12 Go to previous message
Basma Moukhtar is currently offline Basma MoukhtarFriend
Messages: 27
Registered: June 2010
Junior Member

Yes it worked now.

Thanks a lot.
Previous Topic:Refining mode: problems with drop feature
Next Topic:Resolved: Uml2Uml: dynamic packagedElement Creation
Goto Forum:
  


Current Time: Sat Dec 20 13:43:52 GMT 2014

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

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