Search in sources :

Example 1 with CollectionLiteralAnnotationTerm

use of com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm in project ceylon-compiler by ceylon.

the class AnnotationLoader method readCharacterValuesAnnotation.

private LiteralAnnotationTerm readCharacterValuesAnnotation(AnnotationMirror valueAnnotation, boolean singleValue) {
    if (singleValue) {
        Integer value = getAnnotationIntegerValues(valueAnnotation, "value").get(0);
        CharacterLiteralAnnotationTerm term = new CharacterLiteralAnnotationTerm(value);
        return term;
    } else {
        CollectionLiteralAnnotationTerm result = new CollectionLiteralAnnotationTerm(CharacterLiteralAnnotationTerm.FACTORY);
        for (Integer value : getAnnotationIntegerValues(valueAnnotation, "value")) {
            result.addElement(new CharacterLiteralAnnotationTerm(value));
        }
        return result;
    }
}
Also used : CharacterLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CharacterLiteralAnnotationTerm) CollectionLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)

Example 2 with CollectionLiteralAnnotationTerm

use of com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm in project ceylon-compiler by ceylon.

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(com.redhat.ceylon.compiler.java.codegen.FloatLiteralAnnotationTerm) CollectionLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)

Example 3 with CollectionLiteralAnnotationTerm

use of com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm in project ceylon-compiler by ceylon.

the class AnnotationLoader method readDeclarationValuesAnnotation.

private LiteralAnnotationTerm readDeclarationValuesAnnotation(AnnotationMirror valueAnnotation, boolean singleValue) {
    if (singleValue) {
        String value = getAnnotationStringValues(valueAnnotation, "value").get(0);
        DeclarationLiteralAnnotationTerm term = new DeclarationLiteralAnnotationTerm(value);
        return term;
    } else {
        CollectionLiteralAnnotationTerm result = new CollectionLiteralAnnotationTerm(DeclarationLiteralAnnotationTerm.FACTORY);
        for (String value : getAnnotationStringValues(valueAnnotation, "value")) {
            result.addElement(new DeclarationLiteralAnnotationTerm(value));
        }
        return result;
    }
}
Also used : DeclarationLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.DeclarationLiteralAnnotationTerm) CollectionLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)

Example 4 with CollectionLiteralAnnotationTerm

use of com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm 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 CollectionLiteralAnnotationTerm

use of com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm in project ceylon-compiler by ceylon.

the class AnnotationLoader method readBooleanValuesAnnotation.

private LiteralAnnotationTerm readBooleanValuesAnnotation(AnnotationMirror valueAnnotation, boolean singleValue) {
    if (singleValue) {
        boolean value = getAnnotationBooleanValues(valueAnnotation, "value").get(0);
        BooleanLiteralAnnotationTerm term = new BooleanLiteralAnnotationTerm(value);
        return term;
    } else {
        CollectionLiteralAnnotationTerm result = new CollectionLiteralAnnotationTerm(BooleanLiteralAnnotationTerm.FACTORY);
        for (Boolean value : getAnnotationBooleanValues(valueAnnotation, "value")) {
            result.addElement(new BooleanLiteralAnnotationTerm(value));
        }
        return result;
    }
}
Also used : BooleanLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.BooleanLiteralAnnotationTerm) CollectionLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)

Aggregations

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