Search in sources :

Example 1 with AnnotationConstructorParameter

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

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.addConstructorParameter(0, acp);
        else
            ai.addConstructorParameter(acp);
        annotationArgs.add(argument);
    }
    ai.getAnnotationArguments().addAll(annotationArgs);
}
Also used : ParameterAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.ParameterAnnotationTerm) AnnotationInvocation(org.eclipse.ceylon.compiler.java.codegen.AnnotationInvocation) AnnotationConstructorParameter(org.eclipse.ceylon.compiler.java.codegen.AnnotationConstructorParameter) ArrayList(java.util.ArrayList) AnnotationConstructorParameter(org.eclipse.ceylon.compiler.java.codegen.AnnotationConstructorParameter) Parameter(org.eclipse.ceylon.model.typechecker.model.Parameter) AnnotationArgument(org.eclipse.ceylon.compiler.java.codegen.AnnotationArgument)

Example 2 with AnnotationConstructorParameter

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

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.addConstructorParameter(acp);
    }
}
Also used : AnnotationConstructorParameter(org.eclipse.ceylon.compiler.java.codegen.AnnotationConstructorParameter) AnnotationConstructorParameter(org.eclipse.ceylon.compiler.java.codegen.AnnotationConstructorParameter) Parameter(org.eclipse.ceylon.model.typechecker.model.Parameter)

Aggregations

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