Search in sources :

Example 1 with AnnotationArgument

use of org.eclipse.ceylon.compiler.java.codegen.AnnotationArgument 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 AnnotationArgument

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

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 : AnnotationConstructorParameter(org.eclipse.ceylon.compiler.java.codegen.AnnotationConstructorParameter) Parameter(org.eclipse.ceylon.model.typechecker.model.Parameter) ArrayList(java.util.ArrayList) List(java.util.List) AnnotationArgument(org.eclipse.ceylon.compiler.java.codegen.AnnotationArgument)

Aggregations

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