Package com.sun.mirror.declaration

Examples of com.sun.mirror.declaration.TypeDeclaration


          catch (MirroredTypeException e) {
            TypeMirror adaptedType = e.getTypeMirror();
            if (!(adaptedType instanceof DeclaredType)) {
              throw new ValidationException(pckg.getPosition(), "Package " + pckg.getSimpleName() + ": unadaptable type: " + adaptedType);
            }
            TypeDeclaration typeDeclaration = ((DeclaredType) adaptedType).getDeclaration();
            if (typeDeclaration == null) {
              throw new IllegalStateException("Class not found: " + adaptedType);
            }
            typeFqn = typeDeclaration.getQualifiedName();
          }

          adaptersOfPackage.put(typeFqn, adaptedTypeInfo);
        }
      }
View Full Code Here


    return this.baseType == XmlQNameEnum.BaseType.URI;
  }

  @Override
  public TypeMirror getEnumBaseClass() {
    TypeDeclaration decl = isUriBaseType() ?
      getEnv().getTypeDeclaration(URI.class.getName()) :
      getEnv().getTypeDeclaration(QName.class.getName());
    return getEnv().getTypeUtils().getDeclaredType(decl);
  }
View Full Code Here

        TypeMirror candidateToNarrow = typeArgs.iterator().next();
        NarrowingCollectionComponentVisitor visitor = new NarrowingCollectionComponentVisitor();
        candidateToNarrow.accept(visitor);
        TypeMirror narrowing = visitor.getResult();
        if (narrowing != null) {
          TypeDeclaration decl = ((DeclaredType) base).getDeclaration();
          while (decl instanceof DecoratedTypeDeclaration) {
            decl = (TypeDeclaration) ((DecoratedTypeDeclaration) decl).getDelegate();
          }

          while (narrowing instanceof DecoratedTypeMirror) {
View Full Code Here

  private static TypeMirror findCollectionStrippedOfExtensions(TypeMirror typeMirror) {
    TypeMirror found = null;

    if (typeMirror instanceof DeclaredType) {
      TypeDeclaration decl = ((DeclaredType) typeMirror).getDeclaration();
      if (decl != null) {
        String qn = decl.getQualifiedName();
        if (List.class.getName().equals(qn) || Collection.class.getName().equals(qn)) {
          return typeMirror;
        }
        else {
          for (InterfaceType si : decl.getSuperinterfaces()) {
            found = findCollectionStrippedOfExtensions(si);
            if (found != null) {
              break;
            }
          }

          if (found == null && decl instanceof ClassDeclaration) {
            found = findCollectionStrippedOfExtensions(((ClassDeclaration) decl).getSuperclass());
          }

          if (found != null) {
            TypeParameterDeclaration typeParam = null;
            for (TypeMirror typeArg : ((DeclaredType) found).getActualTypeArguments()) {
              if (typeArg instanceof TypeVariable) {
                typeParam = ((TypeVariable) typeArg).getDeclaration();
                break;
              }
            }

            if (typeParam != null) {
              int typeArgIndex = -1;
              for (TypeParameterDeclaration typeParamDeclaration : decl.getFormalTypeParameters()) {
                typeArgIndex++;
                if (typeParam.getSimpleName().equals(typeParamDeclaration.getSimpleName())) {
                  Iterator<TypeMirror> resolvingTypeArgs = ((DeclaredType) typeMirror).getActualTypeArguments().iterator();
                  TypeMirror resolved = null;
                  for (int resolvingTypeIndex = 0; resolvingTypeIndex <= typeArgIndex && resolvingTypeArgs.hasNext(); resolvingTypeIndex++) {
                    resolved = resolvingTypeArgs.next();
                  }
                  if (resolved != null) {
                    //got the resolved type mirror, create a new type mirror with the resolved argument instead.
                    TypeDeclaration foundDecl = ((DeclaredType) found).getDeclaration();
                    while (foundDecl instanceof DecoratedTypeDeclaration) {
                      foundDecl = (TypeDeclaration) ((DecoratedTypeDeclaration) foundDecl).getDelegate();
                    }

                    while (resolved instanceof DecoratedTypeMirror) {
View Full Code Here

    }

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

  }

  public Boolean overridesAnother(Accessor a) {
    String name = a.getSimpleName();
    EnunciateFreemarkerModel model = (EnunciateFreemarkerModel) FreemarkerModel.get();
    TypeDeclaration declaringType = a.getDeclaringType();
    if (declaringType instanceof ClassDeclaration) {
      declaringType = ((ClassDeclaration) declaringType).getSuperclass().getDeclaration();
      while (declaringType instanceof ClassDeclaration && !Object.class.getName().equals(declaringType.getQualifiedName())) {
        TypeDefinition typeDef = model.findTypeDefinition((ClassDeclaration) declaringType);
        if (typeDef != null) {
          ArrayList<Accessor> accessors = new ArrayList<Accessor>();
          accessors.addAll(typeDef.getAttributes());
          accessors.add(typeDef.getValue());
View Full Code Here

    }

    SubResource resource;
    TypeMirror returnType = delegate.getReturnType();
    if ((returnType instanceof DeclaredType) && ((DeclaredType) returnType).getDeclaration() != null) {
      TypeDeclaration declaration = ((DeclaredType) returnType).getDeclaration();
      resource = findRecursiveSubResource(declaration, getPath());
      resource = resource == null ? new SubResource(declaration, getPath(), this) : resource;
    }
    else {
      resource = new SubResource(Context.getCurrentEnvironment().getTypeDeclaration(Object.class.getName()), getPath(), this);
View Full Code Here

    if (!(unwrapped instanceof TypeDeclaration)) {
      throw new TemplateModelException("A type declaration must be provided.");
    }

    boolean noParams = list.size() > 1 && Boolean.FALSE.equals(BeansWrapper.getDefaultInstance().unwrap((TemplateModel) list.get(1)));
    TypeDeclaration declaration = (TypeDeclaration) unwrapped;
    String simpleNameWithParams = this.typeConversion.isUseClientNameConversions() && declaration.getAnnotation(ClientName.class) != null ? declaration.getAnnotation(ClientName.class).value() : declaration.getSimpleName();
    if (!noParams && this.typeConversion.isJdk15() && declaration.getFormalTypeParameters() != null && !declaration.getFormalTypeParameters().isEmpty()) {
      simpleNameWithParams += "<";
      Iterator<TypeParameterDeclaration> paramIt = declaration.getFormalTypeParameters().iterator();
      while (paramIt.hasNext()) {
        simpleNameWithParams += this.typeConversion.convert(paramIt.next());
        if (paramIt.hasNext()) {
          simpleNameWithParams += ", ";
        }
View Full Code Here

    if (elementDeclaration instanceof RootElementDeclaration) {
      TypeDefinition typeDef = ((RootElementDeclaration) elementDeclaration).getTypeDefinition();
      addReferencedNamespaces(typeDef, referencedNamespaces);
    }
    else if (elementDeclaration instanceof LocalElementDeclaration) {
      TypeDeclaration typeDecl = ((LocalElementDeclaration) elementDeclaration).getElementTypeDeclaration();
      if (typeDecl instanceof ClassDeclaration) {
        EnunciateFreemarkerModel model = (EnunciateFreemarkerModel) FreemarkerModel.get();
        TypeDefinition typeDefinition = model.findTypeDefinition((ClassDeclaration) typeDecl);
        if (typeDefinition != null) {
          addReferencedNamespaces(typeDefinition, referencedNamespaces);
View Full Code Here

    }

    TemplateModel from = (TemplateModel) list.get(0);
    Object unwrapped = BeansWrapper.getDefaultInstance().unwrap(from);
    if (unwrapped instanceof TypeDeclaration) {
      TypeDeclaration typeDecl = (TypeDeclaration) unwrapped;
      StringBuilder builder = new StringBuilder();
      if (typeDecl.getPackage() != null) {
        builder.append(typeDecl.getPackage().getQualifiedName());
      }
      LinkedList<String> innerClassStack = new LinkedList<String>();
      innerClassStack.addFirst(typeDecl.getSimpleName());
      while (typeDecl.getDeclaringType() != null) {
        typeDecl = typeDecl.getDeclaringType();
        innerClassStack.addFirst(typeDecl.getSimpleName());
      }

      builder.append('.');
      Iterator<String> it = innerClassStack.iterator();
      while (it.hasNext()) {
View Full Code Here

TOP

Related Classes of com.sun.mirror.declaration.TypeDeclaration

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.