Package javax.lang.model.element

Examples of javax.lang.model.element.Element


  FactoryMethodDescriptor generateDescriptorForConstructor(final AutoFactoryDeclaration declaration,
      ExecutableElement constructor) {
    checkNotNull(constructor);
    checkArgument(constructor.getKind() == ElementKind.CONSTRUCTOR);
    Element classElement = constructor.getEnclosingElement();
    Name returnType = classElement.accept(
        new ElementKindVisitor6<Name, Void>() {
          @Override
          protected Name defaultAction(Element e, Void p) {
            throw new AssertionError();
          }

          @Override
          public Name visitTypeAsClass(TypeElement e, Void p) {
            if (!e.getTypeParameters().isEmpty()) {
              messager.printMessage(ERROR, "AutoFactory does not support generic types", e);
            }
            return e.getQualifiedName();
          }
        }, null);
    ImmutableListMultimap<Boolean, ? extends VariableElement> parameterMap =
        Multimaps.index(constructor.getParameters(), Functions.forPredicate(
            new Predicate<VariableElement>() {
              @Override
              public boolean apply(VariableElement parameter) {
                return parameter.getAnnotation(Provided.class) != null;
              }
            }));
    ImmutableSet<Parameter> providedParameters = Parameter.forParameterList(parameterMap.get(true));
    ImmutableSet<Parameter> passedParameters = Parameter.forParameterList(parameterMap.get(false));
    return new FactoryMethodDescriptor.Builder(declaration)
        .factoryName(declaration.getFactoryName(
            elements.getPackageOf(constructor).getQualifiedName(), classElement.getSimpleName()))
        .name("create")
        .returnType(returnType.toString())
        .publicMethod(constructor.getEnclosingElement().getModifiers().contains(PUBLIC))
        .providedParameters(providedParameters)
        .passedParameters(passedParameters)
View Full Code Here


  @Override
  public void enterProperty(Property node)
  {
    properties.peek().add(node);

    Element element = node.getAccessor();

    String type = node.getType().accept(new TypeResolver(), null);
    Visibility visibility = node.getVisibility();
    QualifiedName containerName = new QualifiedName(node.getContainer());
    try
View Full Code Here

        @Override
         public Set<TypeElement> scan(Element e, Set<TypeElement> p) {
            for (AnnotationMirror annotationMirror :
                     elements.getAllAnnotationMirrors(e) ) {
                Element e2 = annotationMirror.getAnnotationType().asElement();
                p.add((TypeElement) e2);
            }
            return super.scan(e, p);
        }
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

  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

        if (eventHandlerAnnotationValue != null && !hasSinkNative) {
          @SuppressWarnings("unchecked")
          List<AnnotationValue> eventHandlerAnnotationValues = (List<AnnotationValue>) eventHandlerAnnotationValue.getValue();
          for (AnnotationValue av : eventHandlerAnnotationValues) {
            String referencedFieldName = (String) av.getValue();
            Element referencedField = getField(enclosingClassElement, referencedFieldName);
            if (referencedField == null || (!types.isAssignable(referencedField.asType(), gwtWidgetType) &&!types.isAssignable(referencedField.asType(), gwtElementType))) {
              processingEnv.getMessager().printMessage(
                      Kind.ERROR, "\"" + referencedFieldName + "\" must refer to a field of type Widget or Element. To reference template elements directly, use @SinkNative.",
                      target, eventHandlerAnnotation, av);
            }
          }
View Full Code Here

    }
    return null;
  }

  public static TypeElement getEnclosingTypeElement(final Element element) {
    Element currentElement = element;
    while (currentElement != null && currentElement.getKind() != ElementKind.CLASS) {
      currentElement = currentElement.getEnclosingElement();
    }

    if (currentElement == null) {
      throw new RuntimeException("No enclosing class for " + element);
    }
View Full Code Here

        if (!types.isAssignable(target.asType(), gwtWidgetType) && !types.isAssignable(target.asType(), gwtElementType)) {
          processingEnv.getMessager().printMessage(
                  Kind.ERROR, "Fields anotated with @DataField must be assignable to Widget or Element", target);
        }
       
        Element enclosingClassElement = target.getEnclosingElement();
        if (!hasAnnotation(enclosingClassElement, TypeNames.TEMPLATED)) {
          processingEnv.getMessager().printMessage(
                  Kind.WARNING, "@DataField annotations have no effect outside of @Templated classes",
                  target, getAnnotation(target, TypeNames.DATA_FIELD));
        }
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) {
            return getMetadataClass(typeMirror.toString());
        } else {
            return getMetadataClass(element);
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.