Package javax.lang.model.type

Examples of javax.lang.model.type.TypeKind


  public static TypeMirror typeFromClass(Types types, Elements elements, Class<?> clazz) {
    if (clazz == void.class) {
      return types.getNoType(TypeKind.VOID);
    } else if (clazz.isPrimitive()) {
      String primitiveName = clazz.getName().toUpperCase();
      TypeKind primitiveKind = TypeKind.valueOf(primitiveName);
      return types.getPrimitiveType(primitiveKind);
    } else if (clazz.isArray()) {
      TypeMirror componentType = typeFromClass(types, elements, clazz.getComponentType());
      return types.getArrayType(componentType);
    } else {
View Full Code Here


            }

            final TypeList parameterTypes = methodBuilder.getParameterTypes();
           
            for (int i = 0, n = parameterTypes.size(); i < localIndex && i < n; i++) {
                final TypeKind kind = parameterTypes.get(i).getKind();
                if (kind == TypeKind.LONG || kind == TypeKind.DOUBLE) {
                    ++index;
                }
            }
        }
View Full Code Here

            throw Error.invalidCast(sourceType, targetType);
        }
    }

    private void emitNumericConversion(final Type<?> sourceType, final Type<?> targetType) {
        final TypeKind sourceKind = sourceType.getKind();
        final TypeKind targetKind = targetType.getKind();

        if (sourceKind == targetKind) {
            return;
        }
View Full Code Here

    TypeM result = new TypeM(packageName, classname).withTypeParameter(getTypeMArray(typeElem.getTypeParameters()));
    return result;
  }

  public TypeM getTypeM(TypeMirror typeMirror) {
    TypeKind kind = typeMirror.getKind();
    switch (kind) {
      case BOOLEAN:
        return PrimitiveTypeM.BOOLEAN;
      case CHAR:
        return PrimitiveTypeM.CHAR;
View Full Code Here

                                int offset, String cname, boolean padWord) {
        boolean first = true;
        List<VariableElement> fields = ElementFilter.fieldsIn(clazz.getEnclosedElements());

        for (VariableElement field: fields) {
            TypeKind tk = field.asType().getKind();
            boolean twoWords = (tk == TypeKind.LONG || tk == TypeKind.DOUBLE);
            if (twoWords && doField(res, field, cname, first && padWord)) {
                offset += 8; first = false;
            }
        }
View Full Code Here

            if (doubleAlign && !didTwoWordFields && (offset % 8) == 0) {
                offset = doTwoWordFields(res, clazz, offset, cname, false);
                didTwoWordFields = true;
            }

            TypeKind tk = field.asType().getKind();
            boolean twoWords = (tk == TypeKind.LONG || tk == TypeKind.DOUBLE);

            if (!doubleAlign || !twoWords) {
                if (doField(res, field, cname, false)) offset += 4;
            }
View Full Code Here

            }
            public Boolean visitArray(ArrayType t, Void p) {
                return visit(t.getComponentType(), p);
            }
            public Boolean visitPrimitive(PrimitiveType t, Void p) {
                TypeKind tk = t.getKind();
                return (tk == TypeKind.LONG || tk == TypeKind.DOUBLE);
            }
        };
        return v.visit(t, null);
    }
View Full Code Here

        if(type instanceof TypeVariable)
            return TypeKind.TYPEVAR;
        if(type instanceof WildcardType)
            return TypeKind.WILDCARD;
        if(type instanceof Class){
            TypeKind kind = primitives.get(type);
            if(kind != null)
                return kind;
            return ((Class<?>)type).isArray() ? TypeKind.ARRAY : TypeKind.DECLARED;
        }
        throw new RuntimeException("Unknown type: "+type);
View Full Code Here

            case "long":
            case "float":
            case "double":
            case "char":
            case "boolean":
                final TypeKind kind = TypeKind.valueOf(name.toUpperCase(Locale.ENGLISH));
                return types.boxedClass(types.getPrimitiveType(kind));
            default:
                return (TypeElement) types.asElement(returnType);
        }
    }
View Full Code Here

        switch(e.getKind()) {
        case ANNOTATION_TYPE:
        case CLASS:
        case ENUM:
        case INTERFACE:
            TypeKind kind = e.asType().getKind();
            return !kind.isPrimitive() && kind!= TypeKind.VOID; // primitive elements don't work well.
        }
        return false;
    }
View Full Code Here

TOP

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

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.