Search in sources :

Example 6 with CollectionLiteralAnnotationTerm

use of org.eclipse.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm in project ceylon by eclipse.

the class AnnotationLoader method readFloatValuesAnnotation.

private LiteralAnnotationTerm readFloatValuesAnnotation(AnnotationMirror valueAnnotation, boolean singleValue) {
    if (singleValue) {
        Double value = getAnnotationDoubleValues(valueAnnotation, "value").get(0);
        FloatLiteralAnnotationTerm term = new FloatLiteralAnnotationTerm(value);
        return term;
    } else {
        CollectionLiteralAnnotationTerm result = new CollectionLiteralAnnotationTerm(FloatLiteralAnnotationTerm.FACTORY);
        for (Double value : getAnnotationDoubleValues(valueAnnotation, "value")) {
            result.addElement(new FloatLiteralAnnotationTerm(value));
        }
        return result;
    }
}
Also used : FloatLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.FloatLiteralAnnotationTerm) CollectionLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)

Example 7 with CollectionLiteralAnnotationTerm

use of org.eclipse.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm in project ceylon by eclipse.

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);
        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);
            result.addElement(new ObjectLiteralAnnotationTerm(type));
        }
        return result;
    }
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) DeclarationType(org.eclipse.ceylon.model.loader.ModelLoader.DeclarationType) ObjectLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm) TypeMirror(org.eclipse.ceylon.model.loader.mirror.TypeMirror) CollectionLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)

Aggregations

CollectionLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)7 BooleanLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.BooleanLiteralAnnotationTerm)1 CharacterLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.CharacterLiteralAnnotationTerm)1 DeclarationLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.DeclarationLiteralAnnotationTerm)1 FloatLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.FloatLiteralAnnotationTerm)1 IntegerLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.IntegerLiteralAnnotationTerm)1 ObjectLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm)1 StringLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.StringLiteralAnnotationTerm)1 DeclarationType (org.eclipse.ceylon.model.loader.ModelLoader.DeclarationType)1 TypeMirror (org.eclipse.ceylon.model.loader.mirror.TypeMirror)1 Type (org.eclipse.ceylon.model.typechecker.model.Type)1