Example usage for org.eclipse.jdt.core.dom InfixExpression resolveTypeBinding

List of usage examples for org.eclipse.jdt.core.dom InfixExpression resolveTypeBinding

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom InfixExpression resolveTypeBinding.

Prototype

public final ITypeBinding resolveTypeBinding() 

Source Link

Document

Resolves and returns the binding for the type of this expression.

Usage

From source file:ca.mcgill.cs.swevo.ppa.inference.BinaryInferenceStrategy.java

License:Open Source License

private void processOperators(ASTNode node, TypeFact newFact) {
    InfixExpression infix = (InfixExpression) node;
    InfixExpression.Operator operator = infix.getOperator();

    //      if (node.toString().equals("falseTb == ShortBinding")) {
    //         System.out.println();
    //      }// w  ww.  j a  va 2 s . co  m

    Expression left = infix.getLeftOperand();
    Expression right = infix.getRightOperand();
    boolean isSecondaryIndex = newFact != null && isSecondary(node, newFact);
    boolean isPrimaryIndex = newFact != null && !isSecondaryIndex;

    boolean leftSafe = !PPABindingsUtil.isUnknownType(left.resolveTypeBinding())
            && (indexer.isSafe(left) || (isSecondaryIndex && isLeftIndex(node, newFact)));
    boolean rightSafe = !PPABindingsUtil.isUnknownType(right.resolveTypeBinding())
            && (indexer.isSafe(right) || (isSecondaryIndex && !isLeftIndex(node, newFact)));
    boolean leftBoolean = isBoolean(left, leftSafe);
    boolean rightBoolean = isBoolean(right, rightSafe);
    ITypeBinding newType = null;
    ITypeBinding factType = newFact != null ? newFact.getNewType() : null;

    boolean isNewType = true;

    // && and ||
    if (operator == InfixExpression.Operator.CONDITIONAL_AND
            || operator == InfixExpression.Operator.CONDITIONAL_OR) {
        if (!leftSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("boolean", left);
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        }

        if (!rightSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("boolean", right);
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        }
    }

    // & and |
    else if (operator == InfixExpression.Operator.AND || operator == InfixExpression.Operator.CONDITIONAL_OR
            || operator == InfixExpression.Operator.XOR) {
        if (leftBoolean && !rightSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("boolean", right);
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (rightBoolean && !leftSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("boolean", left);
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (leftSafe && !rightSafe) {
            ITypeBinding newBinding = left.resolveTypeBinding();
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (rightSafe && !leftSafe) {
            ITypeBinding newBinding = right.resolveTypeBinding();
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (!rightSafe && !leftSafe && isPrimaryIndex) {
            ITypeBinding newBinding = factType;
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newBinding = factType;
            oldBinding = right.resolveTypeBinding();
            typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN, newBinding,
                    TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        }
    }
    // << >> >>>
    else if (operator == InfixExpression.Operator.LEFT_SHIFT
            || operator == InfixExpression.Operator.RIGHT_SHIFT_SIGNED
            || operator == InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED) {
        if (!leftSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("int", left);
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        }

        if (!rightSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("int", right);
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        }
    }
    // - / * % < <= > >=
    else if (operator == InfixExpression.Operator.MINUS || operator == InfixExpression.Operator.DIVIDE
            || operator == InfixExpression.Operator.REMAINDER || operator == InfixExpression.Operator.TIMES
            || operator == InfixExpression.Operator.LESS || operator == InfixExpression.Operator.LESS_EQUALS
            || operator == InfixExpression.Operator.GREATER
            || operator == InfixExpression.Operator.GREATER_EQUALS) {
        if (leftSafe && !rightSafe) {
            ITypeBinding newBinding = left.resolveTypeBinding();
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (rightSafe && !leftSafe) {
            ITypeBinding newBinding = right.resolveTypeBinding();
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (!rightSafe && !leftSafe && !isPrimaryIndex) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("int", left);
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);

            newBinding = ppaEngine.getRegistry().getPrimitiveBinding("int", right);
            oldBinding = right.resolveTypeBinding();
            typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN, newBinding,
                    TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (!rightSafe && !leftSafe && isPrimaryIndex) {
            ITypeBinding newBinding = factType;
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);

            newBinding = factType;
            oldBinding = right.resolveTypeBinding();
            typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN, newBinding,
                    TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        }
    }
    // == !=
    else if (operator == InfixExpression.Operator.EQUALS || operator == InfixExpression.Operator.NOT_EQUALS) {
        if (leftSafe && !rightSafe) {
            ITypeBinding newBinding = left.resolveTypeBinding();
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        } else if (rightSafe && !leftSafe) {
            ITypeBinding newBinding = right.resolveTypeBinding();
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        }
    }
    // +
    else if (operator == InfixExpression.Operator.PLUS) {
        if (isPrimaryIndex && !factType.isPrimitive()) {
            ITypeBinding newBinding = factType;
            if (!leftSafe) {

                ITypeBinding oldBinding = left.resolveTypeBinding();
                TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                        newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
                isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            }
            if (!rightSafe) {
                newBinding = factType;
                ITypeBinding oldBinding = right.resolveTypeBinding();
                TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                        newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
                isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            }
            newType = newBinding;
        }
    }

    if (newType != null && !isPrimaryIndex && isNewType) {
        ITypeBinding oldBinding = infix.resolveTypeBinding();
        TypeFact typeFact = new TypeFact(indexer.getMainIndex(node), oldBinding, TypeFact.UNKNOWN, newType,
                TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
        ppaEngine.reportTypeFact(typeFact);
        // report new type for this expression.
        // fix this expression.
    } else if (isPrimaryIndex) {
        if (newType != null && isNewType) {
            ppaEngine.getRegistry().fixBinary(node, newType);
        } else if (factType != null) {
            ppaEngine.getRegistry().fixBinary(node, factType);
        }
    }
}

From source file:com.google.devtools.j2cpp.types.BindingMapBuilder.java

License:Open Source License

@Override
public boolean visit(InfixExpression node) {
    put(node, node.resolveTypeBinding());
    return true;
}

From source file:edu.cmu.cs.crystal.tac.eclipse.EclipseTACInstructionFactory.java

License:Open Source License

public TACInstruction create(InfixExpression node, IEclipseVariableQuery eclipseVariableQuery) {
    BinaryOperator operator = null;
    if (InfixExpression.Operator.AND.equals(node.getOperator()))
        operator = BinaryOperator.BITWISE_AND;
    else if (InfixExpression.Operator.CONDITIONAL_AND.equals(node.getOperator()))
        return new EclipseMergeHelper(node, eclipseVariableQuery);
    else if (InfixExpression.Operator.CONDITIONAL_OR.equals(node.getOperator()))
        return new EclipseMergeHelper(node, eclipseVariableQuery);
    else if (InfixExpression.Operator.DIVIDE.equals(node.getOperator()))
        operator = BinaryOperator.ARIT_DIVIDE;
    else if (InfixExpression.Operator.EQUALS.equals(node.getOperator()))
        operator = BinaryOperator.REL_EQ;
    else if (InfixExpression.Operator.GREATER.equals(node.getOperator()))
        operator = BinaryOperator.REL_GT;
    else if (InfixExpression.Operator.GREATER_EQUALS.equals(node.getOperator()))
        operator = BinaryOperator.REL_GEQ;
    else if (InfixExpression.Operator.LEFT_SHIFT.equals(node.getOperator()))
        operator = BinaryOperator.SHIFT_LEFT;
    else if (InfixExpression.Operator.LESS.equals(node.getOperator()))
        operator = BinaryOperator.REL_LT;
    else if (InfixExpression.Operator.LESS_EQUALS.equals(node.getOperator()))
        operator = BinaryOperator.REL_LEQ;
    else if (InfixExpression.Operator.MINUS.equals(node.getOperator()))
        operator = BinaryOperator.ARIT_SUBTRACT;
    else if (InfixExpression.Operator.NOT_EQUALS.equals(node.getOperator()))
        operator = BinaryOperator.REL_NEQ;
    else if (InfixExpression.Operator.OR.equals(node.getOperator()))
        operator = BinaryOperator.BITWISE_OR;
    else if (InfixExpression.Operator.PLUS.equals(node.getOperator()) && node.resolveTypeBinding() != null) {
        // TODO is this sufficient to distinguish addition and concatenation?
        if (node.resolveTypeBinding().isPrimitive())
            operator = BinaryOperator.ARIT_ADD;
        else/*from ww  w .  j a v a 2s  .  c om*/
            operator = BinaryOperator.STRING_CONCAT;
    } else if (InfixExpression.Operator.REMAINDER.equals(node.getOperator()))
        operator = BinaryOperator.ARIT_MODULO;
    else if (InfixExpression.Operator.RIGHT_SHIFT_SIGNED.equals(node.getOperator()))
        operator = BinaryOperator.SHIFT_RIGHT;
    else if (InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED.equals(node.getOperator()))
        operator = BinaryOperator.SHIFT_UNSIGNED_RIGHT;
    else if (InfixExpression.Operator.TIMES.equals(node.getOperator()))
        operator = BinaryOperator.ARIT_MULTIPLY;
    else if (InfixExpression.Operator.XOR.equals(node.getOperator()))
        operator = BinaryOperator.BITWISE_XOR;
    else
        throw new IllegalArgumentException("Unknown infix operator \"" + node.getOperator() + "\" in: " + node);

    // TODO handle extended argument list!!!
    return new EclipseBinaryInfixOperation(node, operator, eclipseVariableQuery);
}

From source file:net.sf.j2s.core.astvisitors.ASTScriptVisitor.java

License:Open Source License

public boolean visit(InfixExpression node) {
    String constValue = checkConstantValue(node);
    if (constValue != null) {
        buffer.append(constValue);/*from  w  w w .j  a v  a2s  .c o  m*/
        return false;
    }
    ITypeBinding expTypeBinding = node.resolveTypeBinding();
    boolean beCare = false;
    if (expTypeBinding != null && expTypeBinding.getName().indexOf("String") == -1) {
        beCare = true;
    }
    String operator = node.getOperator().toString();
    Expression left = node.getLeftOperand();
    Expression right = node.getRightOperand();
    ITypeBinding typeBinding = left.resolveTypeBinding();

    if (/*(left instanceof SimpleName || left instanceof CharacterLiteral) && (right instanceof SimpleName || right instanceof CharacterLiteral)
        && */(">".equals(operator) || "<".equals(operator) || ">=".equals(operator) || "<=".equals(operator)
            || "==".equals(operator) || "!=".equals(operator))) {
        ITypeBinding rightBinding = right.resolveTypeBinding();
        if (typeBinding.isPrimitive() && "char".equals(typeBinding.getName()) && rightBinding.isPrimitive()
                && "char".equals(rightBinding.getName())) {
            boxingNode(left);
            buffer.append(' ');
            buffer.append(operator);
            buffer.append(' ');
            boxingNode(right);
            return false;
        }
    }
    if ("/".equals(operator)) {
        if (typeBinding != null && typeBinding.isPrimitive()) {
            if (isIntegerType(typeBinding.getName())) {
                ITypeBinding rightTypeBinding = right.resolveTypeBinding();
                if (isIntegerType(rightTypeBinding.getName())) {
                    StringBuffer tmpBuffer = buffer;
                    buffer = new StringBuffer();

                    //buffer.append("Math.floor (");
                    // TODO
                    buffer.append("Clazz.doubleToInt (");
                    charVisit(left, beCare);
                    buffer.append(' ');
                    buffer.append(operator);
                    buffer.append(' ');
                    charVisit(right, beCare);
                    buffer.append(')');
                    List extendedOperands = node.extendedOperands();
                    if (extendedOperands.size() > 0) {
                        for (Iterator iter = extendedOperands.iterator(); iter.hasNext();) {
                            ASTNode element = (ASTNode) iter.next();
                            boolean is2Floor = false;
                            if (element instanceof Expression) {
                                Expression exp = (Expression) element;
                                ITypeBinding expBinding = exp.resolveTypeBinding();
                                if (isIntegerType(expBinding.getName())) {
                                    //buffer.insert(0, "Math.floor (");
                                    buffer.insert(0, "Clazz.doubleToInt (");
                                    is2Floor = true;
                                }
                            }
                            buffer.append(' ');
                            buffer.append(operator);
                            buffer.append(' ');
                            charVisit(element, beCare);
                            if (is2Floor) {
                                buffer.append(')');
                            }
                        }
                    }

                    tmpBuffer.append(buffer);
                    buffer = tmpBuffer;
                    tmpBuffer = null;

                    return false;
                }
            }
        }
    }
    boolean simple = false;
    if (typeBinding != null && typeBinding.isPrimitive()) {
        if ("boolean".equals(typeBinding.getName())) {
            if (checkInfixOperator(node)) {
                buffer.append(" new Boolean (");
                simple = true;
            }
        }
    }

    charVisit(left, beCare);
    buffer.append(' ');
    buffer.append(operator);
    if ("==".equals(operator) || "!=".equals(operator)) {
        if (typeBinding != null && !typeBinding.isPrimitive() && !(left instanceof NullLiteral)
                && !(right instanceof NullLiteral)
        /*&& !(node.getLeftOperand() instanceof StringLiteral) // "abc" == ...
        && !(node.getRightOperand() instanceof StringLiteral)*/) {
            buffer.append('=');
        }
    }
    buffer.append(' ');
    charVisit(right, beCare);
    List extendedOperands = node.extendedOperands();
    if (extendedOperands.size() > 0) {
        for (Iterator iter = extendedOperands.iterator(); iter.hasNext();) {
            buffer.append(' ');
            buffer.append(operator);
            buffer.append(' ');
            ASTNode element = (ASTNode) iter.next();
            charVisit(element, beCare);
        }
    }
    if (simple) {
        buffer.append(").valueOf ()");
    }
    return false;
}

From source file:org.autorefactor.refactoring.rules.SimplifyExpressionRefactoring.java

License:Open Source License

private Expression getExpressionWithoutParentheses(ParenthesizedExpression node) {
    final ASTNode parent = node.getParent();
    final Expression innerExpr = node.getExpression();
    if (innerExpr instanceof ParenthesizedExpression) {
        return getExpressionWithoutParentheses((ParenthesizedExpression) innerExpr);
    }/*from w  ww.  j  a v a 2 s  .  c om*/
    if (parent instanceof InfixExpression) {
        final InfixExpression parentInfixExpr = (InfixExpression) parent;
        if (innerExpr instanceof InfixExpression) {
            final Operator innerOp = ((InfixExpression) innerExpr).getOperator();
            if (innerOp == parentInfixExpr.getOperator() && OperatorEnum.isAssociative(innerOp)
            // Leave String concatenations with mixed type
            // to other if statements in this method.
                    && equalNotNull(innerExpr.resolveTypeBinding(), parentInfixExpr.resolveTypeBinding())) {
                return innerExpr;
            }
        }
    }
    if (isHardToRead(innerExpr, parent)) {
        return node;
    }
    if (isUselessParenthesesInStatement(parent, node)) {
        return innerExpr;
    }
    final int compareTo = OperatorEnum.compareTo(innerExpr, parent);
    if (compareTo < 0) {
        return node;
    } else if (compareTo > 0) {
        return innerExpr;
    }
    if (
    // TODO JNR can we revert the condition in the InfixExpression?
    // parentheses are sometimes needed to explicit code,
    // some like it like that
    innerExpr instanceof InfixExpression
            // TODO JNR add additional code to check if the cast is really required
            // or if it can be removed.
            || innerExpr instanceof CastExpression) {
        return node;
    }
    return innerExpr;
}

From source file:org.evosuite.junit.TestExtractingVisitor.java

License:Open Source License

/**
 * <p>/*from  w w w  .  java2 s  .c o m*/
 * retrieveTypeClass
 * </p>
 * 
 * @param argument
 *            a {@link java.lang.Object} object.
 * @return a {@link java.lang.Class} object.
 */
protected Class<?> retrieveTypeClass(Object argument) {
    assert argument != null;
    if (argument instanceof SimpleType) {
        SimpleType simpleType = (SimpleType) argument;
        return retrieveTypeClass(simpleType);
    }
    if (argument instanceof ITypeBinding) {
        ITypeBinding binding = (ITypeBinding) argument;
        return retrieveTypeClass(binding);
    }
    if (argument instanceof IVariableBinding) {
        IVariableBinding variableBinding = (IVariableBinding) argument;
        return retrieveTypeClass(variableBinding.getType());
    }
    if (argument instanceof SimpleName) {
        SimpleName simpleName = (SimpleName) argument;
        return retrieveTypeClass(simpleName.resolveBinding());
    }
    if (argument instanceof StringLiteral) {
        return String.class;
    }
    if (argument instanceof NumberLiteral) {
        return retrieveTypeClass((NumberLiteral) argument);
    }
    if (argument instanceof PrimitiveType) {
        PrimitiveType primitiveType = (PrimitiveType) argument;
        String typeCode = primitiveType.getPrimitiveTypeCode().toString();
        Class<?> result = PRIMITIVE_TYPECODE_MAPPING.get(typeCode);
        assert result != null : "Could not resolve typecode " + typeCode + ".";
        return result;
    }
    if (argument instanceof ArrayType) {
        ArrayType arrayType = (ArrayType) argument;
        return retrieveTypeClass(arrayType);
    }
    if (argument instanceof ParameterizedType) {
        ParameterizedType parameterizedType = (ParameterizedType) argument;
        return retrieveTypeClass(parameterizedType.getType());
    }
    if (argument instanceof VariableDeclarationFragment) {
        VariableDeclarationFragment varDeclFrgmnt = (VariableDeclarationFragment) argument;
        return retrieveTypeClass(varDeclFrgmnt.resolveBinding());
    }
    if (argument instanceof InfixExpression) {
        InfixExpression infixExpr = (InfixExpression) argument;
        ITypeBinding refTypeBinding = infixExpr.resolveTypeBinding();
        if (refTypeBinding != null) {
            return retrieveTypeClass(refTypeBinding);
        } else {
            throw new RuntimeException(
                    "Could not determine type class of infix expression '" + infixExpr + "'.");
        }
    }
    if (argument instanceof MethodInvocation) {
        MethodInvocation methodInvocation = (MethodInvocation) argument;
        ITypeBinding typeBinding = methodInvocation.resolveTypeBinding();
        if (typeBinding != null) {
            return retrieveTypeClass(typeBinding);
        }
        Expression typeExpression = methodInvocation.getExpression();
        if (typeExpression instanceof MethodInvocation) {
            MethodInvocation parentMethodInvocation = (MethodInvocation) typeExpression;
            IMethodBinding parentMethodBinding = parentMethodInvocation.resolveMethodBinding();
            return retrieveTypeClass(parentMethodBinding.getDeclaringClass());
        } else {
            return retrieveTypeClass(typeExpression);
        }
    }
    if (argument instanceof ArrayAccess) {
        ArrayAccess arrayAccess = (ArrayAccess) argument;
        return retrieveTypeClass(arrayAccess.getArray());
    }
    if (argument instanceof Class<?>) {
        return (Class<?>) argument;
    }
    if (argument instanceof ClassInstanceCreation) {
        return retrieveTypeClass(((ClassInstanceCreation) argument).resolveTypeBinding());
    }
    if (argument instanceof BooleanLiteral) {
        return Boolean.TYPE;
    }
    throw new UnsupportedOperationException(
            "Retrieval of type " + argument.getClass() + " not implemented yet!");
}