public Node createSwitchStatement(Node condition, Node body) { return posify(new Switch().rawCondition(condition).rawBody(body)); }
public void checkSwitchStartsWithDefaultOrCase(Switch node) { Block body = node.astBody(); if (body != null) { Statement first = body.astContents().first(); if (first != null && !(first instanceof Case) && !(first instanceof Default)) { node.addMessage(error(SWITCH_DOES_NOT_START_WITH_CASE, "switch statements should start with a default or case statement.")); } } } }
@Override public void visitSwitchStatement(SwitchStatement node) { lombok.ast.Switch switchStat = new lombok.ast.Switch(); switchStat.astCondition((lombok.ast.Expression) toTree(node.expression)); switchStat.astBody(toBlock(node.statements)); switchStat.astBody().setPosition(toPosition(node.blockStart, node.sourceEnd)); set(node, setPosition(node, switchStat)); }
@Override public void visitSwitch(JCSwitch node) { Switch s = new Switch(); JCExpression cond = node.getExpression(); setConversionPositionInfo(s, "()", getPosition(cond)); s.rawCondition(toTree(removeParens(cond))); Block b = new Block(); s.astBody(b); for (JCCase c : node.getCases()) { JCExpression rawExpr = c.getExpression(); if (rawExpr == null) b.rawContents().addToEnd(setPos(c, new Default())); else b.rawContents().addToEnd(setPos(c, new Case().rawCondition(toTree(rawExpr)))); fillList(c.getStatements(), b.rawContents()); } set(node, s); }
@Override public boolean visitSwitch(lombok.ast.Switch node) { SwitchStatement value = new SwitchStatement(); value.sourceStart = start(node); value.sourceEnd = end(node); value.blockStart = start(node.rawBody()); value.expression = toExpression(node.astCondition()); value.statements = toArray(Statement.class, node.astBody().astContents()); if (value.statements == null) { if (isUndocumented(node.astBody())) value.bits |= ASTNode.UndocumentedEmptyBlock; } else { value.explicitDeclarations = calculateExplicitDeclarations(node.astBody().astContents()); } return set(node, value); }
boolean preamble = true; for (Statement s : node.astBody().astContents()) { if (s instanceof Case || s instanceof Default) { JCExpression newPat = (s instanceof Default) ? null : toExpression(((Case)s).astCondition()); JCExpression expr = reParen(node, toExpression(node.astCondition())); return posSet(node, treeMaker.Switch(expr, cases));
formatter.append("("); formatter.nameNextElement("operand"); visit(node.rawCondition()); formatter.append(")"); formatter.space(); Node body = node.rawBody(); if (!(body instanceof Block)) { visit(body);
@Override public void visitSwitch(JCSwitch node) { Switch s = new Switch(); JCExpression cond = node.getExpression(); setConversionPositionInfo(s, "()", getPosition(cond)); s.rawCondition(toTree(removeParens(cond))); Block b = new Block(); s.astBody(b); for (JCCase c : node.getCases()) { JCExpression rawExpr = c.getExpression(); if (rawExpr == null) b.rawContents().addToEnd(setPos(c, new Default())); else b.rawContents().addToEnd(setPos(c, new Case().rawCondition(toTree(rawExpr)))); fillList(c.getStatements(), b.rawContents()); } set(node, s); }
@Override public boolean visitSwitch(lombok.ast.Switch node) { SwitchStatement value = new SwitchStatement(); value.sourceStart = start(node); value.sourceEnd = end(node); value.blockStart = start(node.rawBody()); value.expression = toExpression(node.astCondition()); value.statements = toArray(Statement.class, node.astBody().astContents()); if (value.statements == null) { if (isUndocumented(node.astBody())) value.bits |= ASTNode.UndocumentedEmptyBlock; } else { value.explicitDeclarations = calculateExplicitDeclarations(node.astBody().astContents()); } return set(node, value); }
boolean preamble = true; for (Statement s : node.astBody().astContents()) { if (s instanceof Case || s instanceof Default) { JCExpression newPat = (s instanceof Default) ? null : toExpression(((Case)s).astCondition()); JCExpression expr = reParen(node, toExpression(node.astCondition())); return posSet(node, treeMaker.Switch(expr, cases));
formatter.append("("); formatter.nameNextElement("operand"); visit(node.rawCondition()); formatter.append(")"); formatter.space(); Node body = node.rawBody(); if (!(body instanceof Block)) { visit(body);
public Node createSwitchStatement(Node condition, Node body) { return posify(new Switch().rawCondition(condition).rawBody(body)); }
@Override public void visitSwitchStatement(SwitchStatement node) { lombok.ast.Switch switchStat = new lombok.ast.Switch(); switchStat.astCondition((lombok.ast.Expression) toTree(node.expression)); switchStat.astBody(toBlock(node.statements)); switchStat.astBody().setPosition(toPosition(node.blockStart, node.sourceEnd)); set(node, setPosition(node, switchStat)); }
@Override public void visitSwitch(JCSwitch node) { Switch s = new Switch(); JCExpression cond = node.getExpression(); setConversionPositionInfo(s, "()", getPosition(cond)); s.rawCondition(toTree(removeParens(cond))); Block b = new Block(); s.astBody(b); for (JCCase c : node.getCases()) { JCExpression rawExpr = c.getExpression(); if (rawExpr == null) b.rawContents().addToEnd(setPos(c, new Default())); else b.rawContents().addToEnd(setPos(c, new Case().rawCondition(toTree(rawExpr)))); fillList(c.getStatements(), b.rawContents()); } set(node, s); }
@Override public boolean visitSwitch(lombok.ast.Switch node) { SwitchStatement value = new SwitchStatement(); value.sourceStart = start(node); value.sourceEnd = end(node); value.blockStart = start(node.rawBody()); value.expression = toExpression(node.astCondition()); value.statements = toArray(Statement.class, node.astBody().astContents()); if (value.statements == null) { if (isUndocumented(node.astBody())) value.bits |= ASTNode.UndocumentedEmptyBlock; } else { value.explicitDeclarations = calculateExplicitDeclarations(node.astBody().astContents()); } return set(node, value); }
public void checkSwitchStartsWithDefaultOrCase(Switch node) { Block body = node.astBody(); if (body != null) { Statement first = body.astContents().first(); if (first != null && !(first instanceof Case) && !(first instanceof Default)) { node.addMessage(error(SWITCH_DOES_NOT_START_WITH_CASE, "switch statements should start with a default or case statement.")); } } } }
boolean preamble = true; for (Statement s : node.astBody().astContents()) { if (s instanceof Case || s instanceof Default) { JCExpression newPat = (s instanceof Default) ? null : toExpression(((Case)s).astCondition()); JCExpression expr = reParen(node, toExpression(node.astCondition())); return posSet(node, treeMaker.Switch(expr, cases));
formatter.append("("); formatter.nameNextElement("operand"); visit(node.rawCondition()); formatter.append(")"); formatter.space(); Node body = node.rawBody(); if (!(body instanceof Block)) { visit(body);
public Node createSwitchStatement(Node condition, Node body) { return posify(new Switch().rawCondition(condition).rawBody(body)); }
@Override public void visitSwitchStatement(SwitchStatement node) { lombok.ast.Switch switchStat = new lombok.ast.Switch(); switchStat.astCondition((lombok.ast.Expression) toTree(node.expression)); switchStat.astBody(toBlock(node.statements)); switchStat.astBody().setPosition(toPosition(node.blockStart, node.sourceEnd)); set(node, setPosition(node, switchStat)); }