1 package spoon.template; 2 3 import spoon.reflect.code.CtBlock; 4 import spoon.reflect.code.CtStatementList; 5 import spoon.reflect.declaration.CtClass; 6 import spoon.reflect.declaration.CtSimpleType; 7 8 19 public abstract class TypedStatementListTemplateParameter<R> implements 20 TemplateParameterList<R> { 21 22 25 public TypedStatementListTemplateParameter() { 26 } 27 28 public CtStatementList<R> getSubstitution(CtSimpleType targetType) { 29 CtClass<?> c; 30 CtBlock<?> b; 31 c= targetType.getFactory().Template().get(this.getClass()); 32 if(c==null) { 33 c=targetType.getFactory().Class().get(this.getClass()); 34 } 35 CtStatementList<R> l = targetType.getFactory().Core() 36 .createStatementList(); 37 if (this instanceof Template) { 38 b = Substitution.substitute(targetType, (Template) this, c 39 .getMethod("statements").getBody()); 40 } else { 41 b = targetType.getFactory().Core().clone(c.getMethod("statements") 42 .getBody()); 43 } 44 l.setStatements(b.getStatements()); 45 return l; 46 } 47 48 public R S() { 49 return null; 50 } 51 52 55 public abstract R statements() throws Throwable ; 56 } 57 | Popular Tags |