Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Xtend Recursive method issues(Xtend Recursive method issues)
Xtend Recursive method issues [message #1080649] Tue, 06 August 2013 08:02 Go to next message
Ankit Agarwal is currently offline Ankit AgarwalFriend
Messages: 35
Registered: March 2012
Member
Hi,

I have a java class with two methods like :

public List<Node> collectSubNodes(Node node)
{
List<Node> nodeList = new ArrayList<Node>();
collectSubStatesOfState(node, nodeList );
return nodeList ;
}

private void collectSubNodesOfNode(Node node, List<Node> nodeList )
{
if(node!= null)
{
EList<Vertex> subnodes = node.getSubNodes();
for(Vertex vertex : subnodes )
{
if(vertex instanceof Node )
{
Node subNode = (Node )vertex;
nodeList.add(subNode );
collectSubNodesOfNode(subNode, nodeList);
}
}

}
}


I want to write this in an *.ext class, i tried with

cached List[Node ] collectSubNodes(Node this) :
subNodes.typeSelect(Node).addAll(subNodes.typeSelect(Node).collectSubNodes())
;

but i am getting StackOverflow exception, May be it is going in infinite loop.
but i am struggling to write as it is recursive method and should return a list with all the details. Please help me in writing the same.
Re: Xtend Recursive method issues [message #1081031 is a reply to message #1080649] Tue, 06 August 2013 18:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

i actually cannot reproduce this. sure you have a tree and not a graph?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtend Recursive method issues [message #1081392 is a reply to message #1080649] Wed, 07 August 2013 07:11 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

The method collectSubNodes() calls collectSubStatesOfState(), and not the method collectSubNodesOfNode().

You should write a unit test to test your Java method.


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Previous Topic:[Acceleo] Access to siblings of resource roots
Next Topic:JET2 Transform slow on Mac
Goto Forum:
  


Current Time: Thu Apr 18 14:40:18 GMT 2024

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

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

Back to the top