public TypeDeclaration findClass(String className, TypeDeclaration referencePoint) { return env.getTypeDeclaration(className); }
public TypeDeclaration getTypeDeclaration(String name) { return delegate.getTypeDeclaration(name); }
public TypeDeclaration findClass(String className, TypeDeclaration referencePoint) { return env.getTypeDeclaration(className); }
public TypeDeclaration asDecl(Class c) { return env.getTypeDeclaration(getSourceClassName(c)); }
SpecCompliantClassAP(AnnotationProcessorEnvironment env) { this.env = env; specCompliantAnnotation = (AnnotationTypeDeclaration) env .getTypeDeclaration("org.apache.vysper.compliance.SpecCompliant"); specCompliantCollectionAnnotation = (AnnotationTypeDeclaration) env .getTypeDeclaration("org.apache.vysper.compliance.SpecCompliance"); try { fileWriter = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "", new File("spec_compliance.html"), null); } catch (IOException e) { throw new RuntimeException("could not write to output file", e); } }
public TypeDeclaration asDecl(Class c) { return env.getTypeDeclaration(getSourceClassName(c)); }
public TypeDeclaration getSuperClass(TypeDeclaration t) { if (t instanceof ClassDeclaration) { ClassDeclaration c = (ClassDeclaration) t; ClassType sup = c.getSuperclass(); if(sup!=null) return sup.getDeclaration(); else return null; } return env.getTypeDeclaration(Object.class.getName()); }
public TypeDeclaration getSuperClass(TypeDeclaration t) { if (t instanceof ClassDeclaration) { ClassDeclaration c = (ClassDeclaration) t; ClassType sup = c.getSuperclass(); if(sup!=null) return sup.getDeclaration(); else return null; } return env.getTypeDeclaration(Object.class.getName()); }
@Override public TypeMirror getEnumBaseClass() { TypeDeclaration decl = isUriBaseType() ? getEnv().getTypeDeclaration(URI.class.getName()) : getEnv().getTypeDeclaration(QName.class.getName()); return getEnv().getTypeUtils().getDeclaredType(decl); }
/** * 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)); }
/** * 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)); }
public TypeMirror ref(Class c) { if(c.isArray()) return env.getTypeUtils().getArrayType( ref(c.getComponentType()) ); if(c.isPrimitive()) return getPrimitive(c); TypeDeclaration t = env.getTypeDeclaration(getSourceClassName(c)); // APT only operates on a set of classes used in the compilation, // and it won't recognize additional classes (even if they are visible from javac) // and return null. // // this is causing a problem where we check if a type is collection. // so until the problem is fixed in APT, work around the issue // by returning a dummy token if(t==null) return DUMMY; return env.getTypeUtils().getDeclaredType(t); }
public TypeMirror ref(Class c) { if(c.isArray()) return env.getTypeUtils().getArrayType( ref(c.getComponentType()) ); if(c.isPrimitive()) return getPrimitive(c); TypeDeclaration t = env.getTypeDeclaration(getSourceClassName(c)); // APT only operates on a set of classes used in the compilation, // and it won't recognize additional classes (even if they are visible from javac) // and return null. // // this is causing a problem where we check if a type is collection. // so until the problem is fixed in APT, work around the issue // by returning a dummy token if(t==null) return DUMMY; return env.getTypeUtils().getDeclaredType(t); }
public void visitInterfaceType(InterfaceType interfaceType) { AdapterType adapterType = AdapterUtil.findAdapterType(interfaceType.getDeclaration()); if (adapterType == null) { //the interface isn't adapted, check for @XmlTransient and if it's there, narrow it to java.lang.Object. //see https://jira.codehaus.org/browse/ENUNCIATE-660 if (interfaceType.getDeclaration() != null && interfaceType.getDeclaration().getAnnotation(XmlTransient.class) != null) { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); this.result = env.getTypeUtils().getDeclaredType(env.getTypeDeclaration(Object.class.getName())); } } }
/** * The enum type containing the known qnames for this qname enum accessor, or null is this accessor doesn't reference a known qname type. * * @return The enum type containing the known qnames for this qname enum accessor. */ public TypeMirror getQNameEnumRef() { XmlQNameEnumRef enumRef = getAnnotation(XmlQNameEnumRef.class); TypeMirror qnameEnumType = null; if (enumRef != null) { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); try { TypeDeclaration decl = env.getTypeDeclaration(enumRef.value().getName()); qnameEnumType = env.getTypeUtils().getDeclaredType(decl); } catch (MirroredTypeException e) { qnameEnumType = e.getTypeMirror(); } } return qnameEnumType; }
/** * Determines whether the class declaration is an instance of the declared type of the given fully-qualified name. * * @param classDeclaration The class declaration. * @param fqn The FQN. * @return Whether the class declaration is an instance of the declared type of the given fully-qualified name. */ protected boolean isInstanceOf(ClassDeclaration classDeclaration, String fqn) { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); Types utils = env.getTypeUtils(); DeclaredType declaredType = utils.getDeclaredType(env.getTypeDeclaration(classDeclaration.getQualifiedName())); DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaredType); return decorated.isInstanceOf(fqn); }
/** * Validates a response wrapper. * * @param wrapper The wrapper. * @param alreadyVisited The list of bean names already visited. * @return The validation result. */ public ValidationResult validateResponseWrapper(ResponseWrapper wrapper, Set<String> alreadyVisited) { AnnotationProcessorEnvironment ape = Context.getCurrentEnvironment(); ValidationResult result = new ValidationResult(); String responseBeanName = wrapper.getResponseBeanName(); if (!alreadyVisited.add(responseBeanName)) { result.addError(wrapper.getWebMethod(), responseBeanName + " conflicts with another generated bean name. Please use the @ResponseWrapper " + "annotation to customize the bean name."); } else if (ape.getTypeDeclaration(responseBeanName) != null) { result.addError(wrapper.getWebMethod(), responseBeanName + " is an existing class. Either move it, or customize the response bean " + "class name with the @ResponseWrapper annotation."); } return result; }
/** * Determines whether the class declaration is an instance of the declared type of the given fully-qualified name. * * @param classDeclaration The class declaration. * @param fqn The FQN. * @return Whether the class declaration is an instance of the declared type of the given fully-qualified name. */ protected boolean isInstanceOf(ClassDeclaration classDeclaration, String fqn) { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); Types utils = env.getTypeUtils(); DeclaredType declaredType = utils.getDeclaredType(env.getTypeDeclaration(classDeclaration.getQualifiedName())); DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaredType); return decorated.isInstanceOf(fqn); }
/** * Determines whether the class declaration is an instance of the declared type of the given fully-qualified name. * * @param classDeclaration The class declaration. * @param fqn The FQN. * @return Whether the class declaration is an instance of the declared type of the given fully-qualified name. */ protected boolean isInstanceOf(ClassDeclaration classDeclaration, String fqn) { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); Types utils = env.getTypeUtils(); DeclaredType declaredType = utils.getDeclaredType(env.getTypeDeclaration(classDeclaration.getQualifiedName())); DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaredType); return decorated.isInstanceOf(fqn); }
public void process() { PrintWriter outJAXB = openClassFile( "Jaxb" ); PrintWriter outJSON = openClassFile( "Json" ); PrintWriter outXML = openClassFile( "Xml" ); if ( outJAXB == null && outJSON == null && outXML == null ) { return; } final AnnotationTypeDeclaration annotationType = (AnnotationTypeDeclaration) processingEnv.getTypeDeclaration( "com.google.code.facebookapi.FacebookReturnType" ); Collection<Declaration> elements = processingEnv.getDeclarationsAnnotatedWith( annotationType ); AnnotationVisitor visitor = new AnnotationVisitor( outJAXB, outJSON, outXML ); for ( Declaration element : elements ) { element.accept( visitor ); } closeClassFile( outJAXB ); closeClassFile( outJSON ); closeClassFile( outXML ); }