Search in sources :

Example 1 with AnnotationArgument

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

the class AnnotationLoader method loadAnnotationInvocationArguments.

private void loadAnnotationInvocationArguments(List<AnnotationFieldName> path, LazyFunction method, AnnotationInvocation ai, AnnotationMirror annotationInvocationAnnotation, List<AnnotationMirror> annotationTree, AnnotatedMirror dpm) {
    @SuppressWarnings("unchecked") List<Short> argumentCodes = (List<Short>) annotationInvocationAnnotation.getValue(AbstractModelLoader.CEYLON_ANNOTATION_INSTANTIATION_ARGUMENTS_MEMBER);
    if (argumentCodes != null) {
        for (int ii = 0; ii < argumentCodes.size(); ii++) {
            short code = argumentCodes.get(ii);
            AnnotationArgument argument = new AnnotationArgument();
            Parameter classParameter = ai.getParameters().get(ii);
            argument.setParameter(classParameter);
            path.add(argument);
            argument.setTerm(loadAnnotationArgumentTerm(path, method, ai, classParameter, annotationTree, dpm, code));
            path.remove(path.size() - 1);
            ai.getAnnotationArguments().add(argument);
        }
    }
}
Also used : Parameter(com.redhat.ceylon.model.typechecker.model.Parameter) AnnotationConstructorParameter(com.redhat.ceylon.compiler.java.codegen.AnnotationConstructorParameter) ArrayList(java.util.ArrayList) List(java.util.List) AnnotationArgument(com.redhat.ceylon.compiler.java.codegen.AnnotationArgument)

Example 2 with AnnotationArgument

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

the class AnnotationLoader method makeInterorAnnotationConstructorInvocation.

public void makeInterorAnnotationConstructorInvocation(AnnotationProxyMethod ctor, AnnotationProxyClass klass, java.util.List<Parameter> ctorParams) {
    AnnotationInvocation ai = new AnnotationInvocation();
    ai.setConstructorDeclaration(ctor);
    ai.setPrimary(klass);
    ai.setInterop(true);
    ctor.setAnnotationConstructor(ai);
    java.util.List<AnnotationArgument> annotationArgs = new ArrayList<AnnotationArgument>();
    for (Parameter ctorParam : ctorParams) {
        boolean isValue = ctorParam.getName().equals("value");
        ParameterAnnotationTerm term = new ParameterAnnotationTerm();
        AnnotationArgument argument = new AnnotationArgument();
        argument.setTerm(term);
        argument.setParameter(klass.getParameter(ctorParam.getName()));
        term.setSourceParameter(ctorParam);
        AnnotationConstructorParameter acp = new AnnotationConstructorParameter();
        acp.setParameter(ctorParam);
        if (isValue)
            ai.getConstructorParameters().add(0, acp);
        else
            ai.getConstructorParameters().add(acp);
        annotationArgs.add(argument);
    }
    ai.getAnnotationArguments().addAll(annotationArgs);
}
Also used : ParameterAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ParameterAnnotationTerm) AnnotationInvocation(com.redhat.ceylon.compiler.java.codegen.AnnotationInvocation) AnnotationConstructorParameter(com.redhat.ceylon.compiler.java.codegen.AnnotationConstructorParameter) ArrayList(java.util.ArrayList) Parameter(com.redhat.ceylon.model.typechecker.model.Parameter) AnnotationConstructorParameter(com.redhat.ceylon.compiler.java.codegen.AnnotationConstructorParameter) AnnotationArgument(com.redhat.ceylon.compiler.java.codegen.AnnotationArgument)

Aggregations

AnnotationArgument (com.redhat.ceylon.compiler.java.codegen.AnnotationArgument)2 AnnotationConstructorParameter (com.redhat.ceylon.compiler.java.codegen.AnnotationConstructorParameter)2 Parameter (com.redhat.ceylon.model.typechecker.model.Parameter)2 ArrayList (java.util.ArrayList)2 AnnotationInvocation (com.redhat.ceylon.compiler.java.codegen.AnnotationInvocation)1 ParameterAnnotationTerm (com.redhat.ceylon.compiler.java.codegen.ParameterAnnotationTerm)1 List (java.util.List)1