Example usage for org.eclipse.jdt.internal.compiler.ast Reference resolveType

List of usage examples for org.eclipse.jdt.internal.compiler.ast Reference resolveType

Introduction

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

Prototype

public TypeBinding resolveType(BlockScope scope) 

Source Link

Document

Resolve the type of this expression in the context of a blockScope

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseAllocationExpression.java

License:Open Source License

private static Expression[] createResolvedAccessArguments(AstGenerator gen, int accessId,
        Expression[] arguments, BlockScope scope) {
    IntLiteral accessIdLiteral = gen.intLiteral(accessId);
    accessIdLiteral.resolveType(scope);/* www . ja  v  a 2 s.  co  m*/

    IntLiteral opKindLiteral = gen.intLiteral(0);
    opKindLiteral.resolveType(scope);

    Expression[] boxedArgs = null;
    if (arguments != null) {
        boxedArgs = new Expression[arguments.length];
        for (int i = 0; i < arguments.length; i++) {
            Expression argument = arguments[i];
            if (argument.resolvedType.isPrimitiveType()) {
                BaseTypeBinding baseType = (BaseTypeBinding) argument.resolvedType;
                AllocationExpression boxingAllocation = gen.createBoxing(argument, baseType);
                boxingAllocation.resolvedType = scope.environment().computeBoxingType(baseType);
                boxingAllocation.binding = scope.getConstructor(
                        (ReferenceBinding) boxingAllocation.resolvedType, new TypeBinding[] { baseType },
                        boxingAllocation);
                boxingAllocation.constant = Constant.NotAConstant;
                argument = boxingAllocation;
            }
            boxedArgs[i] = argument;
        }
    }
    ArrayAllocationExpression packedArgs = gen.arrayAllocation(
            gen.qualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT), boxedArgs != null ? 1 : 0, boxedArgs); // arguments are already resolved at this point
    ArrayBinding objectArray = scope.createArrayType(scope.getJavaLangObject(), 1);
    if (packedArgs.initializer != null)
        packedArgs.initializer.binding = objectArray;
    else
        packedArgs.dimensions[0].resolveType(scope);
    packedArgs.resolvedType = objectArray;
    packedArgs.constant = Constant.NotAConstant;

    Reference teamReference = gen.qualifiedThisReference(scope.enclosingSourceType().enclosingType());
    teamReference.resolveType(scope);

    return new Expression[] { accessIdLiteral, opKindLiteral, packedArgs, teamReference };
}