String className = expression.getClassName();
// Only test the constructor if it has been specified
if (ExpressionTools.stringIsNotEmpty(className)) {
IType type = getType(className);
// Unknown type
if (!type.isResolvable()) {
int startIndex = position(expression) + 4; // NEW + space
int endIndex = startIndex + className.length();
addProblem(expression, startIndex, endIndex, ConstructorExpression_UnknownType);
}
// Test the arguments' types with the constructors' types
// TODO: Add support for ... (array)
else if (expression.hasLeftParenthesis()) {
boolean validated = false;
// Retrieve the constructor's arguments so their type can be calculated
ItemExpression visitor = new ItemExpression();
expression.getConstructorItems().accept(visitor);
IType[] calculatedTypes = null;
// Retrieve the type's constructors
for (IConstructor constructor : type.constructors()) {
ITypeDeclaration[] types1 = constructor.getParameterTypes();
// The number of items match, check their types are equivalent
if (visitor.expressions.size() == types1.length) {