@Override public <T extends CtSynchronized> T setBlock(CtBlock<?> block) { if (block != null) { block.setParent(this); } getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, BODY, block, this.block); this.block = block; return (T) this; }
@Override public <T extends CtTry> T setFinalizer(CtBlock<?> finalizer) { if (finalizer != null) { finalizer.setParent(this); } getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, FINALIZER, finalizer, this.finalizer); this.finalizer = finalizer; return (T) this; }
@Override public <T extends CtTry> T setFinalizer(CtBlock<?> finalizer) { finalizer.setParent(this); this.finalizer = finalizer; return (T) this; }
@Override public <T extends CtSynchronized> T setBlock(CtBlock<?> block) { block.setParent(this); this.block = block; return (T) this; }
@Override public <T extends CtTry> T setBody(CtBlock<?> body) { body.setParent(this); this.body = body; return (T) this; }
@Override public <B extends R, T extends CtExecutable<R>> T setBody(CtBlock<B> body) { body.setParent(this); this.body = body; return (T) this; }
@Override public <T extends CtCatch> T setBody(CtBlock<?> body) { body.setParent(this); this.body = body; return (T) this; }
@Override public <T extends CtAnonymousExecutable> T setBody(CtBlock<?> block) { block.setParent(this); body = block; return (T) this; }
@Override public <T extends CtBodyHolder> T setBody(CtStatement statement) { if (statement != null) { CtBlock<?> body = getFactory().Code().getOrCreateCtBlock(statement); getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, BODY, body, this.body); if (body != null) { body.setParent(this); } this.body = body; } else { getFactory().getEnvironment().getModelChangeListener().onObjectDelete(this, BODY, this.body); this.body = null; } return (T) this; }
@Override public <T extends CtBodyHolder> T setBody(CtStatement statement) { if (statement != null) { CtBlock<?> body = getFactory().Code().getOrCreateCtBlock(statement); getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, BODY, body, this.body); if (body != null) { body.setParent(this); } this.body = body; } else { getFactory().getEnvironment().getModelChangeListener().onObjectDelete(this, BODY, this.body); this.body = null; } return (T) this; }
@Override public <T extends CtBodyHolder> T setBody(CtStatement statement) { if (statement != null) { CtBlock<?> body = getFactory().Code().getOrCreateCtBlock(statement); getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, BODY, body, this.body); if (body != null) { body.setParent(this); } this.body = body; } else { getFactory().getEnvironment().getModelChangeListener().onObjectDelete(this, BODY, this.body); this.body = null; } return (T) this; }
@SuppressWarnings("unchecked") @Override public <T extends CtBodyHolder> T setBody(CtStatement statement) { if (statement != null) { CtBlock<?> body = getFactory().Code().getOrCreateCtBlock(statement); getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, BODY, body, this.body); if (body != null) { body.setParent(this); } this.body = body; } else { getFactory().getEnvironment().getModelChangeListener().onObjectDelete(this, BODY, this.body); this.body = null; } return (T) this; }
@Override public <C extends CtBodyHolder> C setBody(CtStatement statement) { if (statement != null) { CtBlock<?> body = getFactory().Code().getOrCreateCtBlock(statement); getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, BODY, body, this.body); if (expression != null && body != null) { throw new SpoonException("A lambda can't have two bodys."); } if (body != null) { body.setParent(this); } this.body = body; } else { getFactory().getEnvironment().getModelChangeListener().onObjectDelete(this, BODY, this.body); this.body = null; } return (C) this; }
@Override public <B extends T, C extends CtExecutable<T>> C setBody(CtBlock<B> body) { if (expression != null) { throw new SpoonException("A lambda can't have two bodys."); } body.setParent(this); this.body = body; return (C) this; }
protected <T> CtMethod<T> createSimpleMethod(CtTypeReference<T> returnType, String name) { CtMethod<T> method = f().Method().create( declaringType, EnumSet.of(PUBLIC), returnType, name, emptyList(), emptySet()); method.setParent(declaringType); CtBlock<T> body = f().Core().createBlock(); method.setBody(body); body.setParent(method); return method; }
CtBlock movedBlock = (CtBlock) movedElement; statementToRemove.replace(movedBlock.getStatements()); movedBlock.setParent(parentBlock); for (CtStatement newStmtBlock : movedBlock.getStatements()) { newStmtBlock.setParent(parentBlock);