/** * Creates a constructor call. The correct constructor is inferred based on parameters * * @param type the decelerating type of the constructor * @param parameters the arguments of the constructor call * @param <T> the actual type of the decelerating type of the constructor if available * @return the constructor call */ public <T> CtConstructorCall<T> createConstructorCall(CtTypeReference<T> type, CtExpression<?>...parameters) { CtConstructorCall<T> constructorCall = factory.Core() .createConstructorCall(); CtExecutableReference<T> executableReference = factory.Core() .createExecutableReference(); executableReference.setType(type); executableReference.setDeclaringType(type == null ? type : type.clone()); executableReference.setSimpleName(CtExecutableReference.CONSTRUCTOR_NAME); List<CtTypeReference<?>> typeReferences = new ArrayList<>(); for (CtExpression<?> parameter : parameters) { typeReferences.add(parameter.getType()); } executableReference.setParameters(typeReferences); constructorCall.setArguments(Arrays.asList(parameters)); constructorCall.setExecutable(executableReference); return constructorCall; }
@java.lang.Override public <T> void visitCtConstructorCall(final spoon.reflect.code.CtConstructorCall<T> ctConstructorCall) { spoon.reflect.code.CtConstructorCall<T> aCtConstructorCall = ctConstructorCall.getFactory().Core().createConstructorCall(); this.builder.copy(ctConstructorCall, aCtConstructorCall); aCtConstructorCall.setAnnotations(this.cloneHelper.clone(ctConstructorCall.getAnnotations())); aCtConstructorCall.setTypeCasts(this.cloneHelper.clone(ctConstructorCall.getTypeCasts())); aCtConstructorCall.setExecutable(this.cloneHelper.clone(ctConstructorCall.getExecutable())); aCtConstructorCall.setTarget(this.cloneHelper.clone(ctConstructorCall.getTarget())); aCtConstructorCall.setArguments(this.cloneHelper.clone(ctConstructorCall.getArguments())); aCtConstructorCall.setComments(this.cloneHelper.clone(ctConstructorCall.getComments())); this.cloneHelper.tailor(ctConstructorCall, aCtConstructorCall); this.other = aCtConstructorCall; }