1 package spoon.template; 2 3 import spoon.reflect.code.CtBlock; 4 import spoon.reflect.declaration.CtClass; 5 import spoon.reflect.declaration.CtMethod; 6 import spoon.reflect.declaration.CtSimpleType; 7 8 17 public abstract class TypedBlockTemplateParameter<R> implements 18 TemplateParameter<R> { 19 20 23 public TypedBlockTemplateParameter() { 24 } 25 26 29 public abstract R block() throws Throwable ; 30 31 @SuppressWarnings ("unchecked") 32 public CtBlock<R> getSubstitution(CtSimpleType targetType) { 33 CtClass<?> c; 34 c= targetType.getFactory().Template().get(this.getClass()); 35 if(c==null) { 36 c=targetType.getFactory().Class().get(this.getClass()); 37 } 38 CtMethod<R> m = (CtMethod<R>) c.getMethod("block"); 39 if (this instanceof Template) { 40 return Substitution.substitute(targetType, (Template) this, m 41 .getBody()); 42 } else { 43 return targetType.getFactory().Core().clone(m.getBody()); 44 } 45 } 46 47 public R S() { 48 return null; 49 } 50 } 51 | Popular Tags |