Package javax.lang.model.type

Examples of javax.lang.model.type.TypeMirror


        this.primitiveByte = env.getTypeUtils().getPrimitiveType(TypeKind.BYTE);
    }

    public TypeElement getSuperClass(TypeElement typeElement) {
        if (typeElement.getKind().equals(ElementKind.CLASS)) {
            TypeMirror sup = typeElement.getSuperclass();
            if (!sup.getKind().equals(TypeKind.NONE))
                return (TypeElement) ((DeclaredType) sup).asElement();
            else
                return null;
        }
        return env.getElementUtils().getTypeElement(Object.class.getName());
View Full Code Here


    public boolean isArrayButNotByteArray(TypeMirror t) {
        if(!isArray(t))
            return false;

        ArrayType at = (ArrayType) t;
        TypeMirror ct = at.getComponentType();

        return !ct.equals(primitiveByte);
    }
View Full Code Here

            columnElement.toString(), tableObject.getTableName()));
      }
    } else if (tableColumn.isOneToMany()) {
      // List<T> should only have one generic type. Get that type and make sure
      // it has @Table annotation
      TypeMirror typeMirror = ((DeclaredType) columnElement.asType()).getTypeArguments().get(0);
      if (typeUtils.asElement(typeMirror).getAnnotation(Table.class) == null) {
        logger.e("One to many relationship in class %s where %s is not annotated with @Table",
            tableObject.getTableName(), tableColumn.getColumnName());
      }
      oneToManyCache.put(typeMirror.toString(), tableObject);
      TypeElement childColumnElement = elementUtils.getTypeElement(typeMirror.toString());
      tableColumn.setType(getClassName(childColumnElement, getPackageName(childColumnElement)));
    } else if (tableColumn.getSqlType() == SqliteType.UNKNOWN) {
      @SuppressWarnings("ConstantConditions")
      Table annotation = typeElement.getAnnotation(Table.class);
      if (annotation == null) {
View Full Code Here

  @Override
  public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    final Types types = processingEnv.getTypeUtils();
    final Elements elements = processingEnv.getElementUtils();
    final TypeMirror gwtWidgetType = elements.getTypeElement(TypeNames.GWT_WIDGET).asType();
   
    for (TypeElement annotation : annotations) {
      for (Element target : roundEnv.getElementsAnnotatedWith(annotation)) {
        if (((ExecutableElement) target).getReturnType().getKind() != TypeKind.VOID) {
          processingEnv.getMessager().printMessage(
                  Kind.ERROR, "@EventHandler methods must return void", target);
        }
       
        AnnotationMirror eventHandlerAnnotation = getAnnotation(target, TypeNames.EVENT_HANDLER);
        TypeElement enclosingClassElement = (TypeElement) target.getEnclosingElement();
        boolean hasSinkNative = hasAnnotation(target, TypeNames.SINK_NATIVE);
       
        AnnotationValue eventHandlerAnnotationValue = getAnnotationParamValueWithoutDefaults(target, TypeNames.EVENT_HANDLER, "value");
       
        // if there is no annotation parameter value, this method handles events from the templated widget itself: nothing more to check.
        // if the method is also annotated with @SinkNative, the values refer to template elements and we can't (easily) check them
        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)) {
              processingEnv.getMessager().printMessage(
                      Kind.ERROR, "\"" + referencedFieldName + "\" must refer to a field of type Widget. To reference template elements directly, use @SinkNative.",
                      target, eventHandlerAnnotation, av);
            }
          }
        }
       
        List<? extends VariableElement> methodParams = ((ExecutableElement) target).getParameters();
        TypeMirror requiredArgType = hasSinkNative ?
                elements.getTypeElement(TypeNames.GWT_OPAQUE_DOM_EVENT).asType() :
                types.getDeclaredType(elements.getTypeElement(TypeNames.GWT_EVENT), types.getWildcardType(null, null));
        if (methodParams.size() != 1 || !types.isAssignable(methodParams.get(0).asType(), requiredArgType)) {
          if (hasSinkNative) {
            processingEnv.getMessager().printMessage(
View Full Code Here

  @Override
  public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    final Types types = processingEnv.getTypeUtils();
    final Elements elements = processingEnv.getElementUtils();
    final TypeMirror gwtWidgetType = elements.getTypeElement(TypeNames.GWT_WIDGET).asType();
   
    for (TypeElement annotation : annotations) {
      for (Element target : roundEnv.getElementsAnnotatedWith(annotation)) {
        if (!types.isAssignable(target.asType(), gwtWidgetType)) {
          processingEnv.getMessager().printMessage(
View Full Code Here

  @Override
  public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    final Types types = processingEnv.getTypeUtils();
    final Elements elements = processingEnv.getElementUtils();
    final TypeMirror gwtCompositeType = elements.getTypeElement(TypeNames.GWT_COMPOSITE).asType();
   
    for (TypeElement annotation : annotations) {
      for (Element target : roundEnv.getElementsAnnotatedWith(annotation)) {
        if (!types.isAssignable(target.asType(), gwtCompositeType)) {
          processingEnv.getMessager().printMessage(
View Full Code Here

  @Override
  public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    final Types types = processingEnv.getTypeUtils();
    final Elements elements = processingEnv.getElementUtils();
    final TypeMirror gwtWidgetType = elements.getTypeElement(TypeNames.GWT_WIDGET).asType();

    Map<TypeElement, List<Element>> classesWithBoundThings = new HashMap<TypeElement, List<Element>>();
    for (TypeElement annotation : annotations) {
      for (Element target : roundEnv.getElementsAnnotatedWith(annotation)) {
        TypeMirror targetType;
        if (target.getKind() == ElementKind.METHOD) {
          targetType = ((ExecutableElement) target).getReturnType();
        }
        else {
          targetType = target.asType();
        }
        if (!types.isAssignable(targetType, gwtWidgetType)) {
          processingEnv.getMessager().printMessage(
                  Kind.ERROR, "@Bound must target a type assignable to Widget", target); // FIXME actually HasText or HasValue
        }

        TypeElement enclosingClass = getEnclosingTypeElement(target);
        List<Element> boundThings = classesWithBoundThings.get(enclosingClass);
        if (boundThings == null) {
          boundThings = new ArrayList<Element>();
          classesWithBoundThings.put(enclosingClass, boundThings);
        }
        boundThings.add(target);
      }
    }

    for (Map.Entry<TypeElement, List<Element>> classWithItsBoundThings : classesWithBoundThings.entrySet()) {
      List<TypeMirror> modelTypes = findAllModelTypes(classWithItsBoundThings.getKey());
      if (modelTypes.size() == 0) {
        for (Element boundElement : classWithItsBoundThings.getValue()) {
          processingEnv.getMessager().printMessage(
                  Kind.ERROR, "@Bound requires that this class also contains a @Model or @AutoBound DataBinder",
                  boundElement, getAnnotation(boundElement, TypeNames.BOUND));
        }
      }
      else if (modelTypes.size() > 1) {
        // TODO mark everything annotated with @AutoBound or @Model with an error
      }
      else {
        TypeMirror modelType = modelTypes.get(0);
        Set<String> modelPropertyNames = getPropertyNames(modelType);
        for (Element boundElement : classWithItsBoundThings.getValue()) {
          switch (boundElement.getKind()) {
          case FIELD:
          case PARAMETER:
View Full Code Here

    protected void writeMethods(Writer out, ClassSymbol sym, String cname)
            throws IOException, TypeSignature.SignatureException {
        List<ExecutableElement> classmethods = ElementFilter.methodsIn(sym.getEnclosedElements());
        for (ExecutableElement md: classmethods) {
            if(md.getModifiers().contains(Modifier.NATIVE)){
                TypeMirror mtr = types.erasure(md.getReturnType());
                String sig = signature(md);
                TypeSignature newtypesig = new TypeSignature(elements);
                CharSequence methodName = md.getSimpleName();
                boolean longName = false;
                for (ExecutableElement md2: classmethods) {
View Full Code Here

        Element tclassDoc = types.asElement(t);


        switch (t.getKind()) {
            case ARRAY: {
                TypeMirror ct = ((ArrayType) t).getComponentType();
                switch (ct.getKind()) {
                    case BOOLEAN:  return "jbooleanArray";
                    case BYTE:     return "jbyteArray";
                    case CHAR:     return "jcharArray";
                    case SHORT:    return "jshortArray";
                    case INT:      return "jintArray";
                    case LONG:     return "jlongArray";
                    case FLOAT:    return "jfloatArray";
                    case DOUBLE:   return "jdoubleArray";
                    case ARRAY:
                    case DECLARED: return "jobjectArray";
                    default: throw new Error(ct.toString());
                }
            }

            case VOID:     return "void";
            case BOOLEAN:  return "jboolean";
View Full Code Here

        Types typeUtil = processingEnv.getTypeUtils();
        if (a.getKind() != ElementKind.ANNOTATION_TYPE)
            throw new IllegalArgumentException(NOT_AN_ANNOTATION_TYPE + a);

        DeclaredType annotationTypeElement;
        TypeMirror tm = a.asType();
        if ( tm instanceof DeclaredType )
            annotationTypeElement = (DeclaredType) a.asType();
        else
            throw new AssertionError("Bad implementation type for " + tm);
View Full Code Here

TOP

Related Classes of javax.lang.model.type.TypeMirror

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.