Package com.sun.mirror.apt

Examples of com.sun.mirror.apt.AnnotationProcessorEnvironment


        keyType = argIt.next();
        valueType = argIt.next();
      }

      if ((keyType == null) || (valueType == null)) {
        AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
        TypeMirror objectType = env.getTypeUtils().getDeclaredType(env.getTypeDeclaration(Object.class.getName()));
        keyType = objectType;
        valueType = objectType;
      }

      return new MapType((InterfaceType) declaredType, keyType, valueType);
View Full Code Here


    }
    else if (declaration instanceof TypeDeclaration) {
      TypeDeclaration typeDeclaration = (TypeDeclaration) declaration;
     
      // Context usage is not thread-safe!!
      AnnotationProcessorEnvironment ape = Context.getCurrentEnvironment();
      typeDeclaration = ape.getTypeDeclaration(typeDeclaration.getQualifiedName()); //unwrap the decorated stuff as necessary...
      DeclaredType declaredType = ape.getTypeUtils().getDeclaredType(typeDeclaration);
      return findAdapterType(declaredType, null, null);
    }
    else {
      throw new IllegalArgumentException("A " + declaration.getClass().getSimpleName() + " is not an adaptable declaration according to the JAXB spec.");
    }
View Full Code Here

    if (typeAdapterInfo != null) {
      ClassType adapterTypeMirror;

      try {
        Class adaptedClass = typeAdapterInfo.value();
        AnnotationProcessorEnvironment ape = Context.getCurrentEnvironment();
        adapterTypeMirror = (ClassType) ape.getTypeUtils().getDeclaredType(ape.getTypeDeclaration(adaptedClass.getName()));
      }
      catch (MirroredTypeException e) {
        adapterTypeMirror = (ClassType) e.getTypeMirror();
      }
View Full Code Here

      }
      else if (declaration.getBounds() != null && !declaration.getBounds().isEmpty()) {
        boundTypeMirror = declaration.getBounds().iterator().next();
      }
      else {
        AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
        boundTypeMirror = env.getTypeUtils().getDeclaredType(env.getTypeDeclaration(Object.class.getName()));
      }
    }

    this.adaptedType = TypeMirrorDecorator.decorate((ReferenceType) boundTypeMirror);
  }
View Full Code Here

    DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(adaptedType);
    TypeMirror componentType = null;
    if (decorated.isCollection()) {
      Iterator<TypeMirror> itemTypes = ((DeclaredType) decorated).getActualTypeArguments().iterator();
      if (!itemTypes.hasNext()) {
        AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
        Types typeUtils = env.getTypeUtils();
        componentType = TypeMirrorDecorator.decorate(typeUtils.getDeclaredType(env.getTypeDeclaration(java.lang.Object.class.getName())));
      }
      else {
        componentType = itemTypes.next();
      }
    }
    else if (decorated.isArray()) {
      componentType = ((ArrayType) decorated).getComponentType();
    }

    if (componentType instanceof ReferenceType && canAdapt((ReferenceType) componentType)) {
      //if we can adapt the component type, then the adapting type is the collection of the declared adapting type.
      AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
      TypeDeclaration collection = env.getTypeDeclaration(java.util.Collection.class.getName());
      TypeMirror declaredAdapting = getAdaptingType();
      while (declaredAdapting instanceof DecoratedTypeMirror) {
        declaredAdapting = ((DecoratedTypeMirror) declaredAdapting).getDelegate();
      }
      return env.getTypeUtils().getDeclaredType(collection, declaredAdapting);
    }
    else {
      return getAdaptingType();
    }
  }
View Full Code Here

    else if (decoratedType.isCollection()) {
      //if it's a collection type, the xml type is its component type.
      Iterator<TypeMirror> actualTypeArguments = ((DeclaredType) decoratedType).getActualTypeArguments().iterator();
      if (!actualTypeArguments.hasNext()) {
        //no type arguments, java.lang.Object type.
        AnnotationProcessorEnvironment ape = Context.getCurrentEnvironment();
        typeMirror = ape.getTypeUtils().getDeclaredType(ape.getTypeDeclaration(Object.class.getName()));
      }
      else {
        typeMirror = actualTypeArguments.next();
      }
    }
View Full Code Here

    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()));
      }
    }
  }
View Full Code Here

    EnunciateFreemarkerModel model = (EnunciateFreemarkerModel) super.getRootModel();
    model.setEnunciateConfig(config);

    //build up the list of all classes to which we are going to apply enunciate.
    TypeDeclaration[] additionalApiDefinitions = loadAdditionalApiDefinitions();
    AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
    Collection<TypeDeclaration> typeDeclarations = new ArrayList<TypeDeclaration>(env.getTypeDeclarations());
    typeDeclarations.addAll(Arrays.asList(additionalApiDefinitions));

    //trim the classes that are not "include"d.
    trimNotIncludedClasses(typeDeclarations);
View Full Code Here

   * 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);
View Full Code Here

   * @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);
  }
View Full Code Here

TOP

Related Classes of com.sun.mirror.apt.AnnotationProcessorEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.