Search in sources :

Example 1 with TypeMirror

use of com.redhat.ceylon.model.loader.mirror.TypeMirror in project ceylon-compiler by ceylon.

the class JavacClass method getInterfaces.

@Override
public List<TypeMirror> getInterfaces() {
    if (interfaces == null) {
        List<TypeMirror> ret = new ArrayList<TypeMirror>(classSymbol.getInterfaces().size());
        for (Type interfce : classSymbol.getInterfaces()) ret.add(new JavacType(interfce));
        interfaces = Collections.unmodifiableList(ret);
    }
    return interfaces;
}
Also used : Type(com.sun.tools.javac.code.Type) TypeMirror(com.redhat.ceylon.model.loader.mirror.TypeMirror) ArrayList(java.util.ArrayList)

Example 2 with TypeMirror

use of com.redhat.ceylon.model.loader.mirror.TypeMirror in project ceylon-compiler by ceylon.

the class JavacTypeParameter method getBounds.

@Override
public List<TypeMirror> getBounds() {
    if (bounds == null) {
        com.sun.tools.javac.util.List<Type> bnds = typeSymbol.getBounds();
        List<TypeMirror> ret = new ArrayList<TypeMirror>(bnds.size());
        for (Type type : bnds) ret.add(new JavacType(type));
        bounds = Collections.unmodifiableList(ret);
    }
    return bounds;
}
Also used : Type(com.sun.tools.javac.code.Type) TypeMirror(com.redhat.ceylon.model.loader.mirror.TypeMirror) ArrayList(java.util.ArrayList)

Example 3 with TypeMirror

use of com.redhat.ceylon.model.loader.mirror.TypeMirror in project ceylon-compiler by ceylon.

the class AnnotationLoader method setPrimaryFromAnnotationInvocationAnnotation.

private void setPrimaryFromAnnotationInvocationAnnotation(AnnotationMirror annotationInvocationAnnotation, AnnotationInvocation ai) {
    TypeMirror annotationType = (TypeMirror) annotationInvocationAnnotation.getValue(AbstractModelLoader.CEYLON_ANNOTATION_INSTANTIATION_ANNOTATION_MEMBER);
    ClassMirror annotationClassMirror = annotationType.getDeclaredClass();
    Module module = modelLoader.findModuleForClassMirror(annotationClassMirror);
    if (annotationClassMirror.getAnnotation(AbstractModelLoader.CEYLON_METHOD_ANNOTATION) != null) {
        ai.setPrimary((Function) modelLoader.convertToDeclaration(module, annotationClassMirror, DeclarationType.VALUE));
    } else {
        ai.setPrimary((Class) modelLoader.convertToDeclaration(module, annotationClassMirror, DeclarationType.TYPE));
    }
}
Also used : TypeMirror(com.redhat.ceylon.model.loader.mirror.TypeMirror) Module(com.redhat.ceylon.model.typechecker.model.Module) ClassMirror(com.redhat.ceylon.model.loader.mirror.ClassMirror)

Example 4 with TypeMirror

use of com.redhat.ceylon.model.loader.mirror.TypeMirror in project ceylon-compiler by ceylon.

the class AnnotationLoader method readObjectValuesAnnotation.

private LiteralAnnotationTerm readObjectValuesAnnotation(Module moduleScope, AnnotationMirror valueAnnotation, boolean singleValue) {
    if (singleValue) {
        TypeMirror klass = getAnnotationClassValues(valueAnnotation, "value").get(0);
        Type type = modelLoader.obtainType(moduleScope, klass, null, null, null);
        ObjectLiteralAnnotationTerm term = new ObjectLiteralAnnotationTerm(type);
        return term;
    } else {
        CollectionLiteralAnnotationTerm result = new CollectionLiteralAnnotationTerm(ObjectLiteralAnnotationTerm.FACTORY);
        for (TypeMirror klass : getAnnotationClassValues(valueAnnotation, "value")) {
            Type type = modelLoader.obtainType(moduleScope, klass, null, null, null);
            result.addElement(new ObjectLiteralAnnotationTerm(type));
        }
        return result;
    }
}
Also used : Type(com.redhat.ceylon.model.typechecker.model.Type) DeclarationType(com.redhat.ceylon.model.loader.ModelLoader.DeclarationType) ObjectLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm) TypeMirror(com.redhat.ceylon.model.loader.mirror.TypeMirror) CollectionLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)

Example 5 with TypeMirror

use of com.redhat.ceylon.model.loader.mirror.TypeMirror in project ceylon-compiler by ceylon.

the class JavacType method getTypeArguments.

@Override
public List<TypeMirror> getTypeArguments() {
    if (typeArguments == null) {
        List<TypeMirror> args = new ArrayList<TypeMirror>(type.getTypeArguments().size());
        for (Type typeArg : type.getTypeArguments()) {
            args.add(new JavacType(typeArg));
        }
        typeArguments = Collections.unmodifiableList(args);
    }
    return typeArguments;
}
Also used : ArrayType(com.sun.tools.javac.code.Type.ArrayType) WildcardType(com.sun.tools.javac.code.Type.WildcardType) Type(com.sun.tools.javac.code.Type) TypeMirror(com.redhat.ceylon.model.loader.mirror.TypeMirror) ArrayList(java.util.ArrayList)

Aggregations

TypeMirror (com.redhat.ceylon.model.loader.mirror.TypeMirror)5 Type (com.sun.tools.javac.code.Type)3 ArrayList (java.util.ArrayList)3 CollectionLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)1 ObjectLiteralAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm)1 DeclarationType (com.redhat.ceylon.model.loader.ModelLoader.DeclarationType)1 ClassMirror (com.redhat.ceylon.model.loader.mirror.ClassMirror)1 Module (com.redhat.ceylon.model.typechecker.model.Module)1 Type (com.redhat.ceylon.model.typechecker.model.Type)1 ArrayType (com.sun.tools.javac.code.Type.ArrayType)1 WildcardType (com.sun.tools.javac.code.Type.WildcardType)1