@Override public Void visitLabelStatement(final LabelStatement node, final Void data) { super.visitLabelStatement(node, data); final Statement next = node.getNextStatement(); if (next == null) { return null; } if (next instanceof LabelStatement || next instanceof LabeledStatement) { // // We have back-to-back labels; dump the first and redirect its references to the second. // final String nextLabel = next.getChildByRole(Roles.LABEL).getName(); redirectLabels(node.getParent(), node.getLabel(), nextLabel); node.remove(); } else { // // Replace LabelStatement with LabeledStatement. // next.remove(); node.replaceWith( new LabeledStatement( node.getLabel(), AstNode.isLoop(next) ? next : new BlockStatement(next) ) ); } return null; }
@Override public Void visitLabelStatement(final LabelStatement node, final Void data) { super.visitLabelStatement(node, data); final Statement next = node.getNextStatement(); if (next == null) { return null; } if (next instanceof LabelStatement || next instanceof LabeledStatement) { // // We have back-to-back labels; dump the first and redirect its references to the second. // final String nextLabel = next.getChildByRole(Roles.LABEL).getName(); redirectLabels(node.getParent(), node.getLabel(), nextLabel); node.remove(); } else { // // Replace LabelStatement with LabeledStatement. // next.remove(); node.replaceWith( new LabeledStatement( node.getLabel(), AstNode.isLoop(next) ? next : new BlockStatement(next) ) ); } return null; }
@Override public Void visitLabelStatement(final LabelStatement node, final Void data) { super.visitLabelStatement(node, data); final Statement next = node.getNextStatement(); if (next == null) { return null; } if (next instanceof LabelStatement || next instanceof LabeledStatement) { // // We have back-to-back labels; dump the first and redirect its references to the second. // final String nextLabel = next.getChildByRole(Roles.LABEL).getName(); redirectLabels(node.getParent(), node.getLabel(), nextLabel); node.remove(); } else { // // Replace LabelStatement with LabeledStatement. // next.remove(); node.replaceWith( new LabeledStatement( node.getLabel(), AstNode.isLoop(next) ? next : new BlockStatement(next) ) ); } return null; }