Example usage for org.eclipse.jdt.internal.compiler.ast MessageSend genericTypeArguments

List of usage examples for org.eclipse.jdt.internal.compiler.ast MessageSend genericTypeArguments

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.ast MessageSend genericTypeArguments.

Prototype

TypeBinding[] genericTypeArguments

To view the source code for org.eclipse.jdt.internal.compiler.ast MessageSend genericTypeArguments.

Click Source Link

Usage

From source file:spoon.support.compiler.jdt.JDTTreeBuilder.java

License:Open Source License

@Override
public boolean visit(MessageSend messageSend, BlockScope scope) {
    if (messageSend.actualReceiverType == null || !messageSend.actualReceiverType.isAnnotationType()) {
        CtInvocation<Object> inv = factory.Core().createInvocation();
        if (messageSend.binding != null) {
            inv.setExecutable(references.getExecutableReference(messageSend.binding));
            if (messageSend.binding instanceof ProblemMethodBinding) {
                // We are in a static complex in noclasspath mode.
                if (inv.getExecutable() != null && inv.getExecutable().getDeclaringType() != null) {
                    final CtTypeAccess ta = factory.Core().createTypeAccess();
                    ta.setType(inv.getExecutable().getDeclaringType());
                    inv.setTarget(ta);/*from w w w.  j a va2 s . c o  m*/
                }
                if (messageSend.expectedType() != null) {
                    inv.getExecutable().setType(references.getTypeReference(messageSend.expectedType()));
                }
            }
        } else {
            CtExecutableReference<Object> ref = factory.Core().createExecutableReference();
            ref.setSimpleName(new String(messageSend.selector));
            ref.setType(references.getTypeReference(messageSend.expectedType()));
            if (messageSend.receiver.resolvedType == null) {
                // It is crisis dude! static context, we don't have much more information.
                if (messageSend.receiver instanceof SingleNameReference
                        || messageSend.receiver instanceof QualifiedNameReference) {
                    final CtTypeReference<Object> typeReference = factory.Core().createTypeReference();
                    typeReference.setSimpleName(messageSend.receiver.toString());
                    ref.setDeclaringType(typeReference);
                }
            } else {
                ref.setDeclaringType(references.getTypeReference(messageSend.receiver.resolvedType));
            }
            if (messageSend.arguments != null) {
                final List<CtTypeReference<?>> parameters = new ArrayList<CtTypeReference<?>>();
                for (Expression argument : messageSend.arguments) {
                    parameters.add(references.getTypeReference(argument.resolvedType));
                }
                ref.setParameters(parameters);
            }
            inv.setExecutable(ref);
        }
        // inv
        // .setType(references
        // .getTypeReference(messageSend.binding.returnType));
        context.enter(inv, messageSend);
        if (!(messageSend.receiver.getClass().equals(ThisReference.class))) {
            messageSend.receiver.traverse(this, scope);
        }
        context.pushArgument(inv);
        if (messageSend.arguments != null) {
            for (Expression e : messageSend.arguments) {
                e.traverse(this, scope);
            }
        }
        if (messageSend.genericTypeArguments() != null) {
            for (TypeBinding typeBinding : messageSend.genericTypeArguments()) {
                inv.getExecutable().addActualTypeArgument(references.getTypeReference(typeBinding));
            }
        }
        context.popArgument(inv);
        return false;

    } else {
        CtAnnotationFieldAccess<Object> acc = factory.Core().createAnnotationFieldAccess();
        acc.setVariable(references.getVariableReference(messageSend.binding));
        acc.setType(references.getTypeReference(messageSend.resolvedType));

        context.enter(acc, messageSend);

        context.target.push(acc);
        messageSend.receiver.traverse(this, scope);
        context.target.pop();

        return false;
    }
}