/** * Some extra information is needed per variable inside the snippet to generate the parts. This * information is wrapped in an extra * * <p>Build the set of template wrappers for the input variables of the loop * * @return */ public List<TemplateInputVariable> getTemplateAccessesWrappers() { // TODO: Unit test for this if (templateAccessesWrappers != null) return templateAccessesWrappers; ArrayList<TemplateInputVariable> result = new ArrayList<>(); for (CtVariableAccess access : getAccesses()) { TemplateInputVariable var = new TemplateInputVariable(); var.initialize(this, access); if (printer instanceof DefaultJavaPrettyPrinter) { var.setPrinter(new DefaultJavaPrettyPrinter(astElement.getFactory().getEnvironment())); } else var.setPrinter(new AJMHPrettyPrinter(this)); result.add(var); } boolean canSerializeThiz = getPreconditions().checkTypeRef(getASTElement().getParent(CtClass.class).getReference()); if (canSerializeThiz && getMustSerializeThiz()) { // astElement.getFactory().Code().createVariableAccess() TemplateInputVariable thiz = new TemplateInputVariable(); thiz.initializeAsThiz(this); if (printer instanceof DefaultJavaPrettyPrinter) { thiz.setPrinter(new DefaultJavaPrettyPrinter(astElement.getFactory().getEnvironment())); } else thiz.setPrinter(new AJMHPrettyPrinter(this)); result.add(thiz); } templateAccessesWrappers = result; return result; }
/** Sets the printer to be de default printer */ public void setPrinterToDefault() { this.printer = new DefaultJavaPrettyPrinter(astElement.getFactory().getEnvironment()); for (TemplateInputVariable v : getTemplateAccessesWrappers()) { v.setPrinter(new DefaultJavaPrettyPrinter(astElement.getFactory().getEnvironment())); } }
/** Sets the printer to be the AJMH printer */ public void setPrinterToAJMH() { this.printer = new AJMHPrettyPrinter(this); for (TemplateInputVariable v : getTemplateAccessesWrappers()) { v.setPrinter(new AJMHPrettyPrinter(this)); } }