public static CtStatement lastStatementOf(CtMethod<?> method) { return method.getBody().getLastStatement(); }
.getLastStatement(); if (lastStatement instanceof CtReturn) { lastStatement.insertBefore(list_call);
boolean isInMethod = parent.getParent() instanceof CtMethod; if (isInMethod) { if (((CtBlock) parent).getLastStatement() == element && !((CtMethod) parent.getParent()).getType().box().equals(element.getFactory().Class().VOID)) { return false;
.map(Object::toString) .map("// AssertGenerator add assertion\n"::concat) .anyMatch(testWithAssert.getBody().getLastStatement().toString()::equals)) { continue;
@Override public boolean canBeAppliedToPoint(ModificationPoint point) { if (!(point.getCodeElement() instanceof CtStatement)) return false; // Do not remove local declaration if (point.getCodeElement() instanceof CtLocalVariable) { CtLocalVariable lv = (CtLocalVariable) point.getCodeElement(); boolean shadow = false; CtClass parentC = point.getCodeElement().getParent(CtClass.class); List<CtField> ff = parentC.getFields(); for (CtField<?> f : ff) { if (f.getSimpleName().equals(lv.getSimpleName())) shadow = true; } if (!shadow) return false; } // do not remove the last statement CtMethod parentMethd = point.getCodeElement().getParent(CtMethod.class); if (point.getCodeElement() instanceof CtReturn && parentMethd.getBody().getLastStatement().equals(point.getCodeElement())) { return false; } // Otherwise, accept the element return true; }