/** * The current annotation processor environment. * * @return The current annotation processor environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * Default implementation ensures only one APT round does any work and establishes the context before instantiating the processor. * * @param set The relevant annotation types. * @param env The environment. * @return The processor. */ public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> set, AnnotationProcessorEnvironment env) { if (++round > 1) { //we only process one round... //todo: think of some way to process more than one round? return AnnotationProcessors.NO_OP; } AnnotationProcessorEnvironment ape = decorateEnvironment(env); if (ape.getOptions().containsKey(DECLARATION_DECORATOR_OPTION)) { System.setProperty(DeclarationDecorator.class.getName(), ape.getOptions().get(DECLARATION_DECORATOR_OPTION)); } if (ape.getOptions().containsKey(TYPE_DECORATOR_OPTION)) { System.setProperty(TypeMirrorDecorator.class.getName(), ape.getOptions().get(TYPE_DECORATOR_OPTION)); } Context.setCurrentEnvironment(ape); return getProcessorFor(set); }
/** * The current annotation processing environment. * * @return The current annotation processing environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * The current annotation processing environment. * * @return The current annotation processing environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * The current environment. * * @return The current environment. */ protected AnnotationProcessorEnvironment getEnv() { return Context.getCurrentEnvironment(); }
/** * The current environment. * * @return The current environment. */ protected AnnotationProcessorEnvironment getEnv() { return Context.getCurrentEnvironment(); }
/** * The current environment. * * @return The current environment. */ protected AnnotationProcessorEnvironment getEnv() { return Context.getCurrentEnvironment(); }
/** * The current annotation processor environment. * * @return The current annotation processor environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * The current annotation processor environment. * * @return The current annotation processor environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * The current annotation processing environment. * * @return The current annotation processing environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * The current environment. * * @return The current environment. */ protected AnnotationProcessorEnvironment getEnv() { return Context.getCurrentEnvironment(); }
/** * The current annotation processing environment. * * @return The current annotation processing environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * The current annotation processing environment. * * @return The current annotation processing environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * The current annotation processor environment. * * @return The current annotation processor environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * The current annotation processing environment. * * @return The current annotation processing environment. */ protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() { return Context.getCurrentEnvironment(); }
/** * Get the messager for the current environment. * * @return The messager. */ protected Messager getMessager() { return Context.getCurrentEnvironment().getMessager(); }
/** * The collection of variables to establish in the model before processing. * * @return The collection of variables to establish in the model before processing. */ protected Collection<FreemarkerVariable> getVariables() { Collection<FreemarkerVariable> variables = new ArrayList<FreemarkerVariable>(); Map<String, String> options = Context.getCurrentEnvironment().getOptions(); String namespace = options.get(FreemarkerProcessorFactory.FM_LIBRARY_NS_OPTION); variables.add(new FreemarkerVariable(namespace, "aptOptions", options)); return variables; }
/** * Loads the type declarations for the additional API definitions. * * @return The type declarations. */ protected TypeDeclaration[] loadAdditionalApiDefinitions() { AnnotationProcessorEnvironment environment = Context.getCurrentEnvironment(); Collection<TypeDeclaration> additionalApiDefinitions = new ArrayList<TypeDeclaration>(); if (this.additionalApiClasses != null) { for (String additionalApiClass : this.additionalApiClasses) { TypeDeclaration declaration = environment.getTypeDeclaration(additionalApiClass); if (declaration != null) { additionalApiDefinitions.add(declaration); } else { this.enunciate.warn("Unable to load type definition for imported API class '%s'.", additionalApiClass); } } } return additionalApiDefinitions.toArray(new TypeDeclaration[additionalApiDefinitions.size()]); }
@Override protected void process(TemplateException e) { if (!(e instanceof ModelValidationException)) { Messager messager = Context.getCurrentEnvironment().getMessager(); StringWriter stackTrace = new StringWriter(); e.printStackTrace(new PrintWriter(stackTrace)); messager.printError(stackTrace.toString()); } this.ee = new EnunciateException(e); }
/** * Get the XML type for the specified type. * * @param type The type mirror. * @return The xml type for the specified type mirror. * @throws XmlTypeException If the type is invalid or unknown as an xml type. */ public static XmlType getXmlType(Class type) throws XmlTypeException { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); TypeDeclaration declaration = env.getTypeDeclaration(type.getName()); return getXmlType(env.getTypeUtils().getDeclaredType(declaration)); }