Search in sources :

Example 1 with AnnotationConstructorParameter

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

Example 2 with AnnotationConstructorParameter

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

the class AnnotationLoader method loadAnnotationConstructorDefaultedParameters.

private void loadAnnotationConstructorDefaultedParameters(LazyFunction method, MethodMirror meth, AnnotationInvocation ai) {
    for (Parameter ctorParam : method.getFirstParameterList().getParameters()) {
        AnnotationConstructorParameter acp = new AnnotationConstructorParameter();
        acp.setParameter(ctorParam);
        if (ctorParam.isDefaulted()) {
            acp.setDefaultArgument(loadAnnotationConstructorDefaultedParameter(method, meth, ctorParam, acp));
        }
        ai.getConstructorParameters().add(acp);
    }
}
Also used : AnnotationConstructorParameter(com.redhat.ceylon.compiler.java.codegen.AnnotationConstructorParameter) Parameter(com.redhat.ceylon.model.typechecker.model.Parameter) AnnotationConstructorParameter(com.redhat.ceylon.compiler.java.codegen.AnnotationConstructorParameter)

Aggregations

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