// Path: src/main/java/fr/inria/gforge/spoon/transformation/bound/template/BoundTemplate.java
// public class BoundTemplate extends AbstractTemplate<CtStatement> {
// 
// 	@Parameter
// 	public CtTypeReference<Double> typeReference;
// 
// 	@Parameter
// 	public String _parameter_;
// 
// 	@Parameter
// 	public double _minBound_;
// 
// 	@Parameter
// 	public double _maxBound_;
// 
// 	@Local
// 	public BoundTemplate(CtTypeReference<Double> typeReference, String parameterName, double minBound, double maxBound) {
// 		this.typeReference = typeReference;
// 		_parameter_ = parameterName;
// 		_maxBound_ = maxBound;
// 		_minBound_ = minBound;
// 	}
// 
// 	public void test(Double _parameter_) throws Throwable {
// 		if (_parameter_ > _maxBound_) {
// 			throw new RuntimeException("out of max bound (" + _parameter_ + ">" + _maxBound_);
// 		}
// 		if (_parameter_ < _minBound_) {
// 			throw new RuntimeException("out of min bound (" + _parameter_ + "<" + _minBound_);
// 		}
// 	}
// 
// 	@Override
// 	public CtStatement apply(CtType<?> targetType) {
// 		return Substitution.substituteMethodBody((CtClass) targetType, this, "test", typeReference);
// 	}
// }


import fr.inria.gforge.spoon.transformation.bound.annotation.Bound;
import fr.inria.gforge.spoon.transformation.bound.template.BoundTemplate;
import spoon.processing.AbstractAnnotationProcessor;
import spoon.reflect.code.CtBlock;
import spoon.reflect.code.CtStatement;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtExecutable;
import spoon.reflect.declaration.CtParameter;
import spoon.template.Template;
package fr.inria.gforge.spoon.transformation.bound.processing;


public class BoundTemplateProcessor extends AbstractAnnotationProcessor<Bound, CtParameter<?>> {

	public void process(Bound annotation, CtParameter<?> element) {
		// Is to be process?
		CtExecutable<?> e = element.getParent();
		if (e.getBody() == null) {
			return;
		}

		// Use template.
		CtClass<?> type = e.getParent(CtClass.class);
// Path: src/main/java/fr/inria/gforge/spoon/transformation/bound/template/BoundTemplate.java
// public class BoundTemplate extends AbstractTemplate<CtStatement> {
// 
// 	@Parameter
// 	public CtTypeReference<Double> typeReference;
// 
// 	@Parameter
// 	public String _parameter_;
// 
// 	@Parameter
// 	public double _minBound_;
// 
// 	@Parameter
// 	public double _maxBound_;
// 
// 	@Local
// 	public BoundTemplate(CtTypeReference<Double> typeReference, String parameterName, double minBound, double maxBound) {
// 		this.typeReference = typeReference;
// 		_parameter_ = parameterName;
// 		_maxBound_ = maxBound;
// 		_minBound_ = minBound;
// 	}
// 
// 	public void test(Double _parameter_) throws Throwable {
// 		if (_parameter_ > _maxBound_) {
// 			throw new RuntimeException("out of max bound (" + _parameter_ + ">" + _maxBound_);
// 		}
// 		if (_parameter_ < _minBound_) {
// 			throw new RuntimeException("out of min bound (" + _parameter_ + "<" + _minBound_);
// 		}
// 	}
// 
// 	@Override
// 	public CtStatement apply(CtType<?> targetType) {
// 		return Substitution.substituteMethodBody((CtClass) targetType, this, "test", typeReference);
// 	}
// }


// Path: src/main/java/fr/inria/gforge/spoon/transformation/bound/processing/BoundTemplateProcessor.java
import fr.inria.gforge.spoon.transformation.bound.annotation.Bound;
import fr.inria.gforge.spoon.transformation.bound.template.BoundTemplate;
import spoon.processing.AbstractAnnotationProcessor;
import spoon.reflect.code.CtBlock;
import spoon.reflect.code.CtStatement;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtExecutable;
import spoon.reflect.declaration.CtParameter;
import spoon.template.Template;

package fr.inria.gforge.spoon.transformation.bound.processing;


public class BoundTemplateProcessor extends AbstractAnnotationProcessor<Bound, CtParameter<?>> {

	public void process(Bound annotation, CtParameter<?> element) {
		// Is to be process?
		CtExecutable<?> e = element.getParent();
		if (e.getBody() == null) {
			return;
		}

		// Use template.
		CtClass<?> type = e.getParent(CtClass.class);
		Template t = new BoundTemplate(getFactory().Type().createReference(Double.class), element.getSimpleName(), annotation.min(), annotation.max());