Package javax.lang.model.type

Examples of javax.lang.model.type.DeclaredType.asElement()


      Object value = entry.getValue().getValue();
      if (value instanceof TypeMirror) {
        TypeMirror tm = (TypeMirror) value;
        if (tm.getKind() == TypeKind.DECLARED) {
          DeclaredType declType = (DeclaredType) tm;
          TypeElement elem = (TypeElement) declType.asElement();
          result.put(name, elem.getQualifiedName().toString());
        } else {
          // TODO could this really happen?
          result.put(name, String.valueOf(value));
        }
View Full Code Here


  private void getAnnotationHierarchy(TypeElement annoTypeEl, Set<TypeElement> result) {
    if (result.add(annoTypeEl)) {
      List<? extends AnnotationMirror> annos = annoTypeEl.getAnnotationMirrors();
      for (AnnotationMirror anno : annos) {
        DeclaredType annoDeclType = anno.getAnnotationType();
        Element annoEl = annoDeclType.asElement();
        if (annoEl.getKind() == ElementKind.ANNOTATION_TYPE) {
          getAnnotationHierarchy((TypeElement) annoEl, result);
        }
      }
    }
View Full Code Here

        Attribute.Compound anno = cast(Attribute.Compound.class, a);
        DeclaredType annotype = a.getAnnotationType();
        Map<MethodSymbol, Attribute> valmap = anno.getElementValues();

        for (ExecutableElement ex :
                 methodsIn(annotype.asElement().getEnclosedElements())) {
            MethodSymbol meth = (MethodSymbol) ex;
            Attribute defaultValue = meth.getDefaultValue();
            if (defaultValue != null && !valmap.containsKey(meth)) {
                valmap.put(meth, defaultValue);
            }
View Full Code Here

            throw new Exception("Unexpected output from compiler");
    }

    void testParseType(TypeElement clazz) {
        DeclaredType type = (DeclaredType)task.parseType("List<String>", clazz);
        for (Element member : elements.getAllMembers((TypeElement)type.asElement())) {
            TypeMirror mt = types.asMemberOf(type, member);
            System.out.format("%s : %s -> %s%n", member.getSimpleName(), member.asType(), mt);
        }
    }
View Full Code Here

        void test(TypeElement element, boolean fbound) {
            TypeParameterElement tpe = element.getTypeParameters().iterator().next();
            tpe.getBounds().getClass();
            if (fbound) {
                DeclaredType type = (DeclaredType)tpe.getBounds().get(0);
                if (type.asElement() != element)
                    throw error("%s != %s", type.asElement(), element);
                TypeVariable tv = (TypeVariable)type.getTypeArguments().get(0);
                if (tv.asElement() != tpe)
                    throw error("%s != %s", tv.asElement(), tpe);
            }
View Full Code Here

            TypeParameterElement tpe = element.getTypeParameters().iterator().next();
            tpe.getBounds().getClass();
            if (fbound) {
                DeclaredType type = (DeclaredType)tpe.getBounds().get(0);
                if (type.asElement() != element)
                    throw error("%s != %s", type.asElement(), element);
                TypeVariable tv = (TypeVariable)type.getTypeArguments().get(0);
                if (tv.asElement() != tpe)
                    throw error("%s != %s", tv.asElement(), tpe);
            }
        }
View Full Code Here

    if (wrapper != null) {
      return wrapper.getName();
    }
    if (type instanceof DeclaredType) {
      DeclaredType declaredType = (DeclaredType) type;
      Element enclosingElement = declaredType.asElement().getEnclosingElement();
      if (enclosingElement != null && enclosingElement instanceof TypeElement) {
        return getType(enclosingElement) + "$"
            + declaredType.asElement().getSimpleName().toString();
      }
    }
View Full Code Here

    if (type instanceof DeclaredType) {
      DeclaredType declaredType = (DeclaredType) type;
      Element enclosingElement = declaredType.asElement().getEnclosingElement();
      if (enclosingElement != null && enclosingElement instanceof TypeElement) {
        return getType(enclosingElement) + "$"
            + declaredType.asElement().getSimpleName().toString();
      }
    }
    return type.toString();
  }
View Full Code Here

    String types[] = new String[2];
    for ( Element elem : element.getEnclosedElements() ) {
      if ( elem.getSimpleName().toString().equals( propertyName ) ) {
        DeclaredType type = ( ( DeclaredType ) elem.asType() );
        types[0] = type.getTypeArguments().get( 0 ).toString();
        types[1] = COLLECTIONS.get( type.asElement().toString() );
      }
    }
    return types;
  }
View Full Code Here

  Attribute.Compound anno = cast(Attribute.Compound.class, a);
  DeclaredType annotype = a.getAnnotationType();
  Map<MethodSymbol, Attribute> valmap = anno.getElementValues();

  for (ExecutableElement ex :
     methodsIn(annotype.asElement().getEnclosedElements())) {
      MethodSymbol meth = (MethodSymbol) ex;
      Attribute defaultValue = meth.getDefaultValue();
      if (defaultValue != null && !valmap.containsKey(meth)) {
    valmap.put(meth, defaultValue);
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.