@Override public <T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatement statement) { for (CtStatement e : Query.getElements(this, insertionPoints)) { e.insertAfter(statement); } return (T) this; }
@Override public <T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatementList statements) { for (CtStatement e : Query.getElements(this, insertionPoints)) { e.insertAfter(statements); } return (T) this; }
@Override public <T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatement statement) { for (CtStatement e : Query.getElements(this, insertionPoints)) { e.insertAfter(statement); } return (T) this; }
@Override public <T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatement statement) { for (CtStatement e : Query.getElements(this, insertionPoints)) { e.insertAfter(statement); } return (T) this; }
@Override public <T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatementList statements) { for (CtStatement e : Query.getElements(this, insertionPoints)) { e.insertAfter(statements); } return (T) this; }
@Override public <T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatementList statements) { for (CtStatement e : Query.getElements(this, insertionPoints)) { e.insertAfter(statements); } return (T) this; }
@Override public <T extends CtStatementList> T insertBegin(CtStatement statement) { if (this.shouldInsertAfterSuper()) { getStatements().get(0).insertAfter(statement); return (T) this; } this.statements.add(0, statement); return (T) this; }
@Override public <T extends CtStatementList> T insertBegin(CtStatementList statements) { if (this.shouldInsertAfterSuper()) { getStatements().get(0).insertAfter(statements); return (T) this; } List<CtStatement> copy = new ArrayList<>(statements.getStatements()); statements.setStatements(null); this.statements.addAll(0, copy); return (T) this; }
@Override public <T extends CtBlock<R>> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatement statement) { for (CtStatement e : Query.getElements(this, insertionPoints)) { e.insertAfter(statement); } return (T) this; }
@Override public <T extends CtBlock<R>> T insertAfter( Filter<? extends CtStatement> insertionPoints, CtStatementList statements) { for (CtStatement e : Query.getElements(this, insertionPoints)) { e.insertAfter(statements); } return (T) this; }
private void addAtCorrectPlace(String id, CtStatement lastStmt, CtStatement assertStatement, CtStatement statementToBeAsserted) { if (id.endsWith("end")) { statementToBeAsserted.getParent(CtBlock.class).insertEnd(assertStatement); } else { lastStmt.insertAfter(assertStatement); } } }
@Override public <T extends CtBlock<R>> T insertBegin(CtStatement statement) { try { if (getParent() != null && getParent() instanceof CtConstructor && getStatements().size() > 0) { CtStatement first = getStatements().get(0); if (first instanceof CtInvocation && ((CtInvocation<?>) first) .getExecutable().getSimpleName() .startsWith("<init>")) { first.insertAfter(statement); return (T) this; } } } catch (ParentNotInitializedException ignore) { // CtBlock hasn't a parent. So, it isn't in a constructor. } ensureModifiableStatementsList(); this.statements.add(0, statement); return (T) this; }
public static void insertAfterUnderSameParent(CtStatement toBeInserted, CtStatement insertionPoint) { CtElement parent; if (isBlock(insertionPoint)) { CtBlock<?> block = (CtBlock<?>) insertionPoint; block.insertEnd(toBeInserted); parent = block; } else { insertionPoint.insertAfter(toBeInserted); parent = insertionPoint.getParent(); } setParent(parent, toBeInserted); }
@Override public <T extends CtBlock<R>> T insertBegin(CtStatementList statements) { if (getParent() != null && getParent() instanceof CtConstructor && getStatements().size() > 0) { CtStatement first = getStatements().get(0); if (first instanceof CtInvocation && ((CtInvocation<?>) first).getExecutable() .getSimpleName() .startsWith("<init>")) { first.insertAfter(statements); return (T) this; } } if (this.statements == CtElementImpl.<CtStatement>emptyList()) { this.statements = new ArrayList<CtStatement>( statements.getStatements().size() + BLOCK_STATEMENTS_CONTAINER_DEFAULT_CAPACITY); } this.statements.addAll(0, statements.getStatements()); return (T) this; }
private CtMethod<?> apply(CtMethod<?> method, CtInvocation<?> invocation) { final CtStatementList ctStatementList = AmplifierHelper.getParent(invocation); final int indexOfInvocation = ctStatementList.getStatements().indexOf(invocation) - 1; ctStatementList.removeStatement(invocation); invocation.delete(); final CtMethod<?> cloned = CloneHelper.cloneTestMethodForAmp(method, "_remove"); if (indexOfInvocation == -1) { ctStatementList.insertBegin(invocation); } else { ctStatementList.getStatements().get(indexOfInvocation).insertAfter(invocation); } Counter.updateInputOf(cloned, 1); return cloned; }
@Override public boolean applyChangesInModel(OperatorInstance operation, ProgramVariant p) { StatementOperatorInstance stmtoperator = (StatementOperatorInstance) operation; boolean successful = false; CtStatement ctst = (CtStatement) operation.getOriginal(); CtStatement fix = (CtStatement) operation.getModified(); CtBlock parentBlock = stmtoperator.getParentBlock(); if (parentBlock != null) { ctst.insertAfter((CtStatement) fix); fix.setParent(parentBlock); successful = true; operation.setSuccessfulyApplied(successful); StatementSupporter.updateBlockImplicitly(parentBlock, true); } else { log.error("Operation not applied. Parent null"); } return successful; }
lastStatement.insertBefore(list_call); } else { lastStatement.insertAfter(list_call);
insertAfter.insertAfter(invocationToObjectLog);