if (node != null) {
matchedNodes.add(node);
}
break;
case CLOSE_TAG:
CloseTagToken token = (CloseTagToken) currentToken;
TagNode tag = null;
int openIndex = -1;
for (int i = matchedNodes.size() - 1; i != -1; i--) {
TemplateNode n = matchedNodes.get(i);
if (n instanceof TagNode) {
TagNode tn = (TagNode) n;
if (tn.getEndLine() == 0 && tn.getEndColumn() == 0 && tn.tagNameString.equals(token.getTagName())) {
tag = tn;
openIndex = i;
break;
}
}
}
if (openIndex != -1 && tag != null) {
ArrayList<TemplateNode> sub = new ArrayList<TemplateNode>();
for (int i = openIndex + 1; i < matchedNodes.size(); i++) {
TemplateNode n = matchedNodes.get(i);
n.setParent(tag);
sub.add(n);
}
tag.addChildren(sub);
matchedNodes.removeAll(sub);
tag.setCloseText(token.getActualValue());
tag.setEndLine(peek(1).getLineNo());
tag.setEndColumn(peek(1).getColumn());
} else {
node = new TextNode();
TextNode text = (TextNode) node;