* @param aRootParseTree root node of ParseTree
* @return root of DetailNode tree
*/
public DetailNode convertParseTree2DetailNode(ParseTree aRootParseTree)
{
final ParseTree currentParseTreeNode = aRootParseTree;
final JavadocNodeImpl rootJavadocNode = createJavadocNode(currentParseTreeNode, null, -1);
int childCount = currentParseTreeNode.getChildCount();
JavadocNodeImpl[] children = (JavadocNodeImpl[]) rootJavadocNode.getChildren();
for (int i = 0; i < childCount; i++) {
final JavadocNodeImpl child = createJavadocNode(currentParseTreeNode.getChild(i)
, rootJavadocNode, i);
children[i] = child;
}
JavadocNodeImpl currentJavadocParent = rootJavadocNode;
ParseTree currentParseTreeParent = currentParseTreeNode;
while (currentJavadocParent != null) {
children = (JavadocNodeImpl[]) currentJavadocParent.getChildren();
childCount = children.length;
for (int i = 0; i < childCount; i++) {
final JavadocNodeImpl currentJavadocNode = children[i];
final ParseTree currentParseTreeNodeChild = currentParseTreeParent.getChild(i);
final JavadocNodeImpl[] subChildren = (JavadocNodeImpl[]) currentJavadocNode
.getChildren();
for (int j = 0; j < subChildren.length; j++) {
final JavadocNodeImpl child =
createJavadocNode(currentParseTreeNodeChild.getChild(j)
, currentJavadocNode, j);
subChildren[j] = child;
}
}
if (childCount > 0) {
currentJavadocParent = children[0];
currentParseTreeParent = currentParseTreeParent.getChild(0);
}
else {
JavadocNodeImpl nextJavadocSibling = (JavadocNodeImpl) JavadocUtils
.getNextSibling(currentJavadocParent);
ParseTree nextParseTreeSibling = getNextSibling(currentParseTreeParent);
if (nextJavadocSibling == null) {
JavadocNodeImpl tempJavadocParent =
(JavadocNodeImpl) currentJavadocParent.getParent();
ParseTree tempParseTreeParent = currentParseTreeParent.getParent();
while (nextJavadocSibling == null && tempJavadocParent != null) {
nextJavadocSibling = (JavadocNodeImpl) JavadocUtils
.getNextSibling(tempJavadocParent);
nextParseTreeSibling = getNextSibling(tempParseTreeParent);
tempJavadocParent = (JavadocNodeImpl) tempJavadocParent.getParent();
tempParseTreeParent = tempParseTreeParent.getParent();
}
}
currentJavadocParent = nextJavadocSibling;
currentParseTreeParent = nextParseTreeSibling;
}