public void visitLabelled(JCLabeledStatement tree) { try { print(tree.label + ":"); if (isEmptyStat(tree.body) || tree.body instanceof JCSkip) { print(" ;"); } else if (tree.body instanceof JCBlock) { print(" "); printStat(tree.body); } else { println(); align(); printStat(tree.body); } } catch (IOException e) { throw new UncheckedIOException(e); } }
public void visitLabelled(JCLabeledStatement tree) { // Check that label is not used in an enclosing statement Env<AttrContext> env1 = env; while (env1 != null && env1.tree.getTag() != JCTree.CLASSDEF) { if (env1.tree.getTag() == JCTree.LABELLED && ((JCLabeledStatement) env1.tree).label == tree.label) { log.error(tree.pos(), "label.already.in.use", tree.label); break; } env1 = env1.next; } attribStat(tree.body, env.dup(tree)); result = null; }
protected int diffLabelled(JCLabeledStatement oldT, JCLabeledStatement newT, int[] bounds) { int localPointer = bounds[0]; if (nameChanged(oldT.label, newT.label)) { copyTo(localPointer, localPointer = getOldPos(oldT)); printer.print(newT.label); localPointer += oldT.label.length(); } int[] bodyBounds = getBounds(oldT.body); copyTo(localPointer, bodyBounds[0]); localPointer = diffTree(oldT.body, newT.body, bodyBounds); copyTo(localPointer, bounds[1]); return bounds[1]; }
@Override public void visitLabelled(JCLabeledStatement tree) { aPrint(tree.label); print(":"); if (tree.body instanceof JCSkip || suppress(tree)) { println(" ;", tree); } else if (tree.body instanceof JCBlock) { print(" "); print(tree.body); } else { println(tree); print(tree.body); } }
public void visitLabelled(JCLabeledStatement that) { try { print("JCLabeledStatement:"); } catch (Exception e) { } super.visitLabelled(that); }
@Override public Choice<State<JCLabeledStatement>> visitLabeledStatement( final LabeledStatementTree node, State<?> state) { return chooseSubtrees( state, s -> unifyStatement(node.getStatement(), s), stmt -> maker().Labelled((Name) node.getLabel(), stmt)); }
public void visitLabelled(JCLabeledStatement tree) { try { print(tree.label + ": "); printStat(tree.body); } catch (IOException e) { throw new UncheckedIOException(e); } }
private boolean matchLabelled(JCLabeledStatement t1, JCLabeledStatement t2) { return t1.label == t2.label && treesMatch(t1.body, t2.body); }
public JCLabeledStatement Labelled(Name label, JCStatement body) { return invoke(Labelled, label, body); }
public AJCLabeledStatement(JCLabeledStatement ltree) { super(ltree.label, ltree.body); }
public AJCLabeledStatement(JCLabeledStatement ltree, String lcomment) { this(ltree); setComment(lcomment); }
@Override public void visitLabelled(JCLabeledStatement tree) { printNode(tree); property("label", tree.label); child("body", tree.body); indent--; }
@Override public void visitLabelled(JCLabeledStatement node) { Identifier lbl = new Identifier().astValue(node.getLabel().toString()); set(node, new LabelledStatement().rawStatement(toTree(node.getStatement())).astLabel(lbl)); }
@Override public JCLabeledStatement inline(Inliner inliner) throws CouldNotResolveImportException { return inliner .maker() .Labelled(inlineLabel(getLabel(), inliner), getStatement().inline(inliner)); }
/** Return the target of a break or continue statement, if it exists, * report an error if not. * Note: The target of a labelled break or continue is the * (non-labelled) statement tree referred to by the label, * not the tree representing the labelled statement itself. * * @param pos The position to be used for error diagnostics * @param tag The tag of the jump statement. This is either * Tree.BREAK or Tree.CONTINUE. * @param label The label of the jump statement, or null if no * label is given. * @param env The environment current at the jump statement. */ private JCTree findJumpTarget(DiagnosticPosition pos, int tag, Name label, Env<AttrContext> env) { // Search environments outwards from the point of jump. Env<AttrContext> env1 = env; LOOP: while (env1 != null) { switch (env1.tree.getTag()) { case JCTree.LABELLED: JCLabeledStatement labelled = (JCLabeledStatement)env1.tree; if (label == labelled.label) { // If jump is a continue, check that target is a loop. if (tag == JCTree.CONTINUE) { if (labelled.body.getTag() != JCTree.DOLOOP && labelled.body.getTag() != JCTree.WHILELOOP && labelled.body.getTag() != JCTree.FORLOOP && labelled.body.getTag() != JCTree.FOREACHLOOP) log.error(pos, "not.loop.label", label); // Found labelled statement target, now go inwards // to next non-labelled tree. return TreeInfo.referencedStatement(labelled); } else { return labelled; } } break; case JCTree.DOLOOP: case JCTree.WHILELOOP: case JCTree.FORLOOP: case JCTree.FOREACHLOOP: if (label == null) return env1.tree; break; case JCTree.SWITCH: if (label == null && tag == JCTree.BREAK) return env1.tree; break; case JCTree.METHODDEF: case JCTree.CLASSDEF: break LOOP; default: } env1 = env1.next; } if (label != null) log.error(pos, "undef.label", label); else if (tag == JCTree.CONTINUE) log.error(pos, "cont.outside.loop"); else log.error(pos, "break.outside.switch.loop"); return null; }