@Override
public void emitIf(IIfNode node)
{
IConditionalNode conditional = (IConditionalNode) node.getChild(0);
IContainerNode xnode = (IContainerNode) conditional
.getStatementContentsNode();
write("if");
write(" ");
write("(");
getWalker().walk(conditional.getChild(0)); // conditional expression
write(")");
if (!isImplicit(xnode))
write(" ");
getWalker().walk(conditional.getChild(1)); // BlockNode
IConditionalNode[] nodes = node.getElseIfNodes();
if (nodes.length > 0)
{
for (int i = 0; i < nodes.length; i++)
{
IConditionalNode enode = nodes[i];
IContainerNode snode = (IContainerNode) enode
.getStatementContentsNode();
final boolean isImplicit = isImplicit(snode);
if (isImplicit)
write("\n");
else
write(" ");
write("else if");
write(" ");
write("(");
getWalker().walk(enode.getChild(0));
write(")");
if (!isImplicit)
write(" ");
getWalker().walk(enode.getChild(1)); // ConditionalNode
}
}
ITerminalNode elseNode = node.getElseNode();
if (elseNode != null)
{
IContainerNode cnode = (IContainerNode) elseNode.getChild(0);
// if an implicit if, add a newline with no space
final boolean isImplicit = isImplicit(cnode);
if (isImplicit)
write("\n");
else