protected StringBuffer writeTemplate(final Map<String, Object> ctxt, final String path) throws GenerationException { //Generate code final StringWriter sw = new StringWriter(); final BufferedWriter bw = new BufferedWriter(sw); try { final Template template = config.getTemplate(path + ".ftl"); template.process(ctxt, bw); } catch (IOException ioe) { throw new GenerationException(ioe); } catch (TemplateException te) { throw new GenerationException(te); } finally { try { bw.close(); sw.close(); } catch (IOException ioe) { throw new GenerationException(ioe); } } return sw.getBuffer(); }
private void generateRuleCode(final AbstractGenerator generator, final Messager messager, final TypeElement classElement, final PackageElement packageElement, final String classNameActivity) { try { final String packageName = packageElement.getQualifiedName().toString(); //Try generating code for each required class messager.printMessage(Diagnostic.Kind.NOTE, "Generating ryke code for [" + classNameActivity + "]"); generator.generate(packageName, packageElement, classNameActivity, classElement, processingEnv); } catch (GenerationException ge) { final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg, classElement); } }
protected StringBuffer writeTemplate(final String packageName, final String className, final Map<String, Object> ctxt, final Messager messager) throws GenerationException { //Generate code final StringWriter sw = new StringWriter(); final BufferedWriter bw = new BufferedWriter(sw); try { final Template template = config.getTemplate(getTemplatePath()); template.process(ctxt, bw); } catch (IOException ioe) { throw new GenerationException(ioe); } catch (TemplateException te) { throw new GenerationException(te); } finally { try { bw.close(); sw.close(); } catch (IOException ioe) { throw new GenerationException(ioe); } } messager.printMessage(Diagnostic.Kind.NOTE, "Successfully generated code for [" + packageName + "." + className + "]"); return sw.getBuffer(); }
private boolean processLastRoundDefinitionAdapter() throws Exception { final Messager messager = processingEnv.getMessager(); try { // Ensure visible on both backend and client sides. final String packageName = getGeneratedPackageName() + ".definition.adapter.binding"; final String className = getSetClassPrefix() + DEFINITION_ADAPTER_CLASSNAME; final String classFQName = packageName + "." + className; messager.printMessage(Diagnostic.Kind.NOTE, "Starting ErraiBinderAdapter adf named " + classFQName); final StringBuffer ruleClassCode = definitionAdapterGenerator.generate(packageName, className, processingContext, messager); writeCode(packageName, className, ruleClassCode); } catch (GenerationException ge) { final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg); } return true; }
bw); } catch (IOException ioe) { throw new GenerationException(ioe); } catch (TemplateException te) { throw new GenerationException(te); } finally { try { sw.close(); } catch (IOException ioe) { throw new GenerationException(ioe);
final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Kind.ERROR, msg,
bw); } catch (IOException ioe) { throw new GenerationException(ioe); } catch (TemplateException te) { throw new GenerationException(te); } finally { try { sw.close(); } catch (IOException ioe) { throw new GenerationException(ioe);
final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Kind.ERROR, msg,
bw); } catch (IOException | TemplateException ioe) { throw new GenerationException(ioe); } finally { try { sw.close(); } catch (IOException ioe) { throw new GenerationException(ioe);
final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Kind.ERROR, msg,
bw); } catch (IOException | TemplateException ioe) { throw new GenerationException(ioe); } finally { try { sw.close(); } catch (IOException ioe) { throw new GenerationException(ioe);
final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Kind.ERROR, msg,
throw new GenerationException(te);
final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Kind.ERROR, msg,
final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Kind.ERROR, msg,
throw new GenerationException("Multiple methods with @" + fqcnToSimpleName(annotationName) + " detected.");
final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Kind.ERROR, msg,
throw new GenerationException("Multiple methods with @" + fqcnToSimpleName(annotationName) + " detected.");
final String msg = ge.getMessage(); processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg,