@java.lang.Override public void set(spoon.reflect.code.CtStatement replace) { this.element.setElseStatement(replace); } }
@Override public <T, U> void setValue(T element, U value) { castTarget(element).setElseStatement(castValue(value)); } }
} else { lastIf.setElseStatement(ifStmt); lastIf = ifStmt; lastIf.setElseStatement(lastElse);
@Override public void visitCtIf(CtIf e) { super.visitCtIf(e); boolean inThen = true; CtStatement stat = e.getThenStatement(); if (stat != target) { stat = e.getElseStatement(); inThen = false; } if (stat != target) { throw new IllegalArgumentException("should not happen"); } if (stat instanceof CtBlock) { insertType.insert((CtBlock<?>) stat, statementsToBeInserted); } else { CtBlock<?> block = insertNewBlock(stat); if (inThen) { e.setThenStatement(block); } else { e.setElseStatement(block); } } }
@Override public void visitCtIf(CtIf ifElement) { if (ifElement.getCondition() == null && child instanceof CtExpression) { ifElement.setCondition((CtExpression<Boolean>) child); return; } else if (child instanceof CtStatement) { CtStatement child = (CtStatement) this.child; // we create implicit blocks everywhere for facilitating transformation if (!(this.child instanceof CtBlock)) { child = jdtTreeBuilder.getFactory().Code().createCtBlock(child); child.setImplicit(true); child.setPosition(this.child.getPosition()); } IfStatement ifJDT = (IfStatement) this.parentJDT; if (ifJDT.thenStatement == this.childJDT) { //we are visiting `then` of `if` ifElement.setThenStatement(child); return; } else if (ifJDT.elseStatement == this.childJDT) { //we are visiting `else` of `if` ifElement.setElseStatement(child); return; } else { throw new SpoonException("Unexpected call of ParentExiter on CtIf"); } } super.visitCtIf(ifElement); }
public void visitCtIf(final spoon.reflect.code.CtIf ifElement) { spoon.reflect.code.CtIf aCtIf = ifElement.getFactory().Core().createIf(); this.builder.copy(ifElement, aCtIf); aCtIf.setAnnotations(this.cloneHelper.clone(ifElement.getAnnotations())); aCtIf.setCondition(this.cloneHelper.clone(ifElement.getCondition())); aCtIf.setThenStatement(this.cloneHelper.clone(((spoon.reflect.code.CtStatement) (ifElement.getThenStatement())))); aCtIf.setElseStatement(this.cloneHelper.clone(((spoon.reflect.code.CtStatement) (ifElement.getElseStatement())))); aCtIf.setComments(this.cloneHelper.clone(ifElement.getComments())); this.cloneHelper.tailor(ifElement, aCtIf); this.other = aCtIf; }
ifRes.setElseStatement((CtStatement) evaluate(ifElement.getElseStatement()));
public static CtIf newIf(Factory factory, CtExpression<Boolean> condition, CtStatement thenBranch, CtStatement elseBranch) { CtIf newIf = newIf(factory, condition, thenBranch); elseBranch = asBlock(elseBranch, newIf); setParent(newIf, elseBranch); newIf.setElseStatement(elseBranch); return newIf; }
private static CtIf originalLoopReplacement(Factory factory, LoopMonitor monitor, While loop) { CtExpression<Boolean> monitoredCondition = newExpressionFromSnippet(factory, conditionName(monitor), Boolean.class); CtIf newIf = newIf(factory, monitoredCondition, loop.loopBody(), newBreak(factory)); CtStatement increment = newStatementFromSnippet(factory, format("%s += 1", counterName(monitor))); insertBeforeUnderSameParent(increment, newIf.getThenStatement()); if (loop.isUnbreakable()) { newIf.setElseStatement(null); } return newIf; }
@Override public void visitCtIf(CtIf ifElement) { if (ifElement.getCondition() == null && child instanceof CtExpression) { ifElement.setCondition((CtExpression<Boolean>) child); return; } else if (child instanceof CtStatement) { if (ifElement.getThenStatement() == null) { ifElement.setThenStatement((CtStatement) child); return; } else if (ifElement.getElseStatement() == null) { ifElement.setElseStatement((CtStatement) child); return; } } super.visitCtIf(ifElement); }
block.addStatement(elem.getElseStatement()); block.setParent(elem); elem.setElseStatement(block); } else { CtBlock<?> block = (CtBlock<?>) elem.getElseStatement(); CtBlock<?> block = getFactory().Core().createBlock(); block.addStatement(call); elem.setElseStatement(block);
((CtIf) targetParent).setThenStatement(block); } else { ((CtIf) targetParent).setElseStatement(block);
@Override public void visitCtIf(CtIf element) { super.visitCtIf(element); if(!(element.getThenStatement() instanceof CtBlock)){ CtStatement c = element.getThenStatement() ; CtBlock nBlock = MutationSupporter.getFactory().Core().createBlock(); nBlock.addStatement(c); element.setThenStatement(nBlock); } if( element.getElseStatement() != null && !(element.getElseStatement() instanceof CtBlock)){ CtStatement c = element.getElseStatement() ; CtBlock nBlock = MutationSupporter.getFactory().Core().createBlock(); nBlock.addStatement(c); element.setElseStatement(nBlock); } }
ifRes.setElseStatement((CtStatement) evaluate(ifRes, ifElement.getElseStatement()));