if (type.isArrayType()) {
if (this.scope == null) {
return null;
}
ArrayType arrayType = (ArrayType) type;
ArrayBinding arrayBinding = (ArrayBinding) typeBinding;
int dimensions = arrayType.getDimensions();
boolean isVarargs = typeReference.isVarargs();
if (dimensions == arrayBinding.dimensions)
return getTypeBinding(arrayBinding); // reuse.
return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, dimensions, getTypeAnnotations(dimensions, arrayBinding, isVarargs)));
}
if (typeBinding.isArrayType()) {
// 'typeBinding' can still be an array type because 'node' may be "larger" than 'type' (see comment of newAstToOldAst).
typeBinding = ((ArrayBinding) typeBinding).leafComponentType;
}
int index;
if (type.isQualifiedType()) {
index = ((QualifiedType) type).index;
} else if (type.isParameterizedType()) {
index = ((ParameterizedType) type).index;
} else {
index = 1;
}
final int numberOfTypeArgumentsNotNull = getTypeCount(typeReference);
if (index != numberOfTypeArgumentsNotNull) {
int i = numberOfTypeArgumentsNotNull;
while (i != index) {
typeBinding = typeBinding.enclosingType();
i --;
}
binding = typeBinding;
} else {
binding = typeBinding;
}
} else if (node instanceof TypeReference) {
if (type instanceof SimpleType && node instanceof QualifiedTypeReference) {
return resolveTypeBindingForName(((SimpleType)type).getName());
} else if (type instanceof QualifiedType) {
return resolveTypeBindingForName(((QualifiedType)type).getName());
} else if (type instanceof NameQualifiedType){
return resolveTypeBindingForName(((NameQualifiedType)type).getName());
}
TypeReference typeReference = (TypeReference) node;
binding = typeReference.resolvedType;
} else if (node instanceof SingleNameReference && ((SingleNameReference)node).isTypeReference()) {
binding = (((SingleNameReference)node).resolvedType);
} else if (node instanceof QualifiedNameReference && ((QualifiedNameReference)node).isTypeReference()) {
binding = (((QualifiedNameReference)node).resolvedType);
} else if (node instanceof ArrayAllocationExpression) {
binding = ((ArrayAllocationExpression) node).resolvedType;
}
if (binding != null) {
if (type.isArrayType()) {
ArrayType arrayType = (ArrayType) type;
if (this.scope == null) {
return null;
}
ArrayBinding arrayBinding = (ArrayBinding) binding;
int dimensions = arrayType.getDimensions();
boolean isVarargs = node instanceof TypeReference && ((TypeReference) node).isVarargs();
if (dimensions == arrayBinding.dimensions)
return getTypeBinding(arrayBinding); // reuse
return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, dimensions, getTypeAnnotations(dimensions, arrayBinding, isVarargs)));
} else if (binding.isArrayType()) {
// 'binding' can still be an array type because 'node' may be "larger" than 'type' (see comment of newAstToOldAst).
ArrayBinding arrayBinding = (ArrayBinding) binding;
return getTypeBinding(arrayBinding.leafComponentType);
}
return getTypeBinding(binding);
}
} else if (type.isPrimitiveType()) {