Example usage for org.eclipse.jdt.core.dom ArrayCreation DIMENSIONS_PROPERTY

List of usage examples for org.eclipse.jdt.core.dom ArrayCreation DIMENSIONS_PROPERTY

Introduction

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

Prototype

ChildListPropertyDescriptor DIMENSIONS_PROPERTY

To view the source code for org.eclipse.jdt.core.dom ArrayCreation DIMENSIONS_PROPERTY.

Click Source Link

Document

The "dimensions" structural property of this node type (element type: Expression ).

Usage

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

License:Open Source License

private VariableReference retrieveVariableReference(ArrayCreation arrayCreation) {
    Class<?> arrayType = retrieveTypeClass(arrayCreation.getType());
    List<?> dimensions = ((AbstractList<?>) arrayCreation
            .getStructuralProperty(ArrayCreation.DIMENSIONS_PROPERTY));
    if (dimensions.size() > 1) {
        throw new RuntimeException("Multidimensional arrays not implemented!");
    }/* www .  j  a  v  a 2 s  . c  om*/
    Integer length = (Integer) ((NumberLiteral) dimensions.get(0)).resolveConstantExpressionValue();
    // ArrayReference arrayReference = new
    // ValidArrayReference(testCase.getReference(), arrayType, length);
    ArrayStatement arrayAssignment = new ArrayStatement(testCase.getReference(), arrayType, length);
    testCase.addStatement(arrayAssignment);
    return arrayAssignment.getReturnValue();
}