Search in sources :

Example 1 with ParameterAnnotationTerm

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

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

the class AnnotationLoader method decode.

private AnnotationTerm decode(Module moduleScope, List<Parameter> sourceParameters, AnnotationInvocation info, Parameter parameter, AnnotatedMirror dpm, List<AnnotationFieldName> path, int code) {
    AnnotationTerm result;
    if (code == Short.MIN_VALUE) {
        return findLiteralAnnotationTerm(moduleScope, path, parameter, dpm);
    } else if (code < 0) {
        InvocationAnnotationTerm invocation = new InvocationAnnotationTerm();
        result = invocation;
    } else if (code >= 0 && code < 512) {
        ParameterAnnotationTerm parameterArgument = new ParameterAnnotationTerm();
        boolean spread = false;
        if (code >= 256) {
            spread = true;
            code -= 256;
        }
        parameterArgument.setSpread(spread);
        Parameter sourceParameter = sourceParameters.get(code);
        parameterArgument.setSourceParameter(sourceParameter);
        // result.setTargetParameter(sourceParameter);
        result = parameterArgument;
    } else {
        throw new RuntimeException();
    }
    return result;
}
Also used : ParameterAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.ParameterAnnotationTerm) AnnotationConstructorParameter(org.eclipse.ceylon.compiler.java.codegen.AnnotationConstructorParameter) Parameter(org.eclipse.ceylon.model.typechecker.model.Parameter) InvocationAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.InvocationAnnotationTerm) CollectionLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm) FloatLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.FloatLiteralAnnotationTerm) ObjectLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm) LiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.LiteralAnnotationTerm) DeclarationLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.DeclarationLiteralAnnotationTerm) BooleanLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.BooleanLiteralAnnotationTerm) InvocationAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.InvocationAnnotationTerm) AnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.AnnotationTerm) CharacterLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.CharacterLiteralAnnotationTerm) ParameterAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.ParameterAnnotationTerm) IntegerLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.IntegerLiteralAnnotationTerm) StringLiteralAnnotationTerm(org.eclipse.ceylon.compiler.java.codegen.StringLiteralAnnotationTerm)

Aggregations

AnnotationConstructorParameter (org.eclipse.ceylon.compiler.java.codegen.AnnotationConstructorParameter)2 ParameterAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.ParameterAnnotationTerm)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 AnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.AnnotationTerm)1 BooleanLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.BooleanLiteralAnnotationTerm)1 CharacterLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.CharacterLiteralAnnotationTerm)1 CollectionLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm)1 DeclarationLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.DeclarationLiteralAnnotationTerm)1 FloatLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.FloatLiteralAnnotationTerm)1 IntegerLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.IntegerLiteralAnnotationTerm)1 InvocationAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.InvocationAnnotationTerm)1 LiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.LiteralAnnotationTerm)1 ObjectLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm)1 StringLiteralAnnotationTerm (org.eclipse.ceylon.compiler.java.codegen.StringLiteralAnnotationTerm)1