Package javax.lang.model.element

Examples of javax.lang.model.element.Element


  public static TypeElement getSuperclassTypeElement(TypeElement element) {
    final TypeMirror superClass = element.getSuperclass();
    //superclass of Object is of NoType which returns some other kind
    if ( superClass.getKind() == TypeKind.DECLARED ) {
      //F..king Ch...t Have those people used their horrible APIs even once?
      final Element superClassElement = ( (DeclaredType) superClass ).asElement();
      return (TypeElement) superClassElement;
    }
    else {
      return null;
    }
View Full Code Here


  public static AccessType determineAnnotationSpecifiedAccessType(Element element) {
    final AnnotationMirror accessAnnotationMirror = TypeUtils.getAnnotationMirror( element, Constants.ACCESS );
    AccessType forcedAccessType = null;
    if ( accessAnnotationMirror != null ) {
      Element accessElement = (Element) TypeUtils.getAnnotationValue(
          accessAnnotationMirror,
          DEFAULT_ANNOTATION_PARAMETER_NAME
      );
      if ( accessElement.getKind().equals( ElementKind.ENUM_CONSTANT ) ) {
        if ( accessElement.getSimpleName().toString().equals( AccessType.PROPERTY.toString() ) ) {
          forcedAccessType = AccessType.PROPERTY;
        }
        else if ( accessElement.getSimpleName().toString().equals( AccessType.FIELD.toString() ) ) {
          forcedAccessType = AccessType.FIELD;
        }
      }
    }
    return forcedAccessType;
View Full Code Here

  private static String findMappedSuperClass(MetaEntity entity, Context context) {
    TypeMirror superClass = entity.getTypeElement().getSuperclass();
    //superclass of Object is of NoType which returns some other kind
    while ( superClass.getKind() == TypeKind.DECLARED ) {
      //F..king Ch...t Have those people used their horrible APIs even once?
      final Element superClassElement = ( (DeclaredType) superClass ).asElement();
      String superClassName = ( (TypeElement) superClassElement ).getQualifiedName().toString();
      if ( extendsSuperMetaModel( superClassElement, entity.isMetaComplete(), context ) ) {
        return superClassName;
      }
      superClass = ( (TypeElement) superClassElement ).getSuperclass();
View Full Code Here

          }
      }
      mirror = box ? box(mirror) : mirror;
      if (isPrimitive(mirror))
        return ((PrimitiveType)mirror).toString();
      Element elem = typeUtility.asElement(mirror);
      if (elem == null)
          throw new RuntimeException(_loc.get("mmg-no-type", mirror).getMessage());
        return elem.toString();
    }
View Full Code Here

     * INTERNAL:
     * If the adds a new element will build it and add it to our list of
     * MetadataClasses.
     */
    public MetadataClass getMetadataClass(TypeMirror typeMirror) {
        Element element = processingEnv.getTypeUtils().asElement(typeMirror);
       
        if (element == null) {
            // This case hits when we are passed a TypeMirror of <none>. Not
            // 100% on the whole story here, either way we create a metadata
            // class with that name and carry on. The case also hits when we
View Full Code Here

    for (ReferenceBinding referenceBinding : referenceBindings) {
      // collect all annotations from the binary types
      AnnotationBinding[] annotationBindings = referenceBinding.getAnnotations();
      for (AnnotationBinding annotationBinding : annotationBindings) {
        TypeElement anno = (TypeElement)_factory.newElement(annotationBinding.getAnnotationType());
        Element element = _factory.newElement(referenceBinding);
        _annoToUnit.put(anno, element);
      }
      FieldBinding[] fieldBindings = referenceBinding.fields();
      for (FieldBinding fieldBinding : fieldBindings) {
        annotationBindings = fieldBinding.getAnnotations();
        for (AnnotationBinding annotationBinding : annotationBindings) {
          TypeElement anno = (TypeElement)_factory.newElement(annotationBinding.getAnnotationType());
          Element element = _factory.newElement(fieldBinding);
          _annoToUnit.put(anno, element);
        }
      }
      MethodBinding[] methodBindings = referenceBinding.methods();
      for (MethodBinding methodBinding : methodBindings) {
        annotationBindings = methodBinding.getAnnotations();
        for (AnnotationBinding annotationBinding : annotationBindings) {
          TypeElement anno = (TypeElement)_factory.newElement(annotationBinding.getAnnotationType());
          Element element = _factory.newElement(methodBinding);
          _annoToUnit.put(anno, element);
        }
      }
      ReferenceBinding[] memberTypes = referenceBinding.memberTypes();
      collectAnnotations(memberTypes);
View Full Code Here

      Set<Element> elements = new HashSet<Element>(_units.length);
      for (CompilationUnitDeclaration unit : _units) {
        if (null == unit.scope || null == unit.scope.topLevelTypes)
          continue;
        for (SourceTypeBinding binding : unit.scope.topLevelTypes) {
          Element element = _factory.newElement(binding);
          if (null == element) {
            throw new IllegalArgumentException("Top-level type binding could not be converted to element: " + binding); //$NON-NLS-1$
          }
          elements.add(element);
        }
View Full Code Here

   
    for (Annotation annotation : annotations) {
      AnnotationBinding binding = annotation.getCompilerAnnotation();
      if (binding != null) { // binding should be resolved, but in case it's not, ignore it
        TypeElement anno = (TypeElement)_factory.newElement(binding.getAnnotationType());
        Element element = _factory.newElement(currentBinding);
        _annoToElement.put(anno, element);
      }
    }
  }
View Full Code Here

      if (element.getKind() != ElementKind.FIELD) {
        error("@Rule must prefix a field -- " + element
            + " is not a field");
        continue;
      }
      Element parent = element.getEnclosingElement();
      if (exists.contains(parent)) {
        warn("Class "
            + elementAsString(parent)
            + "\n\t contains more than one @Rule field\n\tOnly one @Run method is field for a test class");
      }
View Full Code Here

      if (element.getKind() != ElementKind.METHOD) {
        error("@Parameters must prefix a method -- " + element
            + " is not a method");
        continue;
      }
      Element parent = element.getEnclosingElement();
      if (exists.contains(parent)) {
        warn("Class "
            + elementAsString(parent)
            + "\n\t contains more than one @Parameters method\n\tOnly one @Parameters method is allowed for a test class");
      }
View Full Code Here

TOP

Related Classes of javax.lang.model.element.Element

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.