"Compilation unit services required");
Validate.notNull(typeDeclaration, "Type declaration required");
// Convert the ClassOrInterfaceDeclaration name into a JavaType
final NameExpr nameExpr = getNameExpr(typeDeclaration.getName());
final JavaType effectiveType = getJavaType(compilationUnitServices,
nameExpr, null);
final List<JavaType> parameterTypes = new ArrayList<JavaType>();
if (typeDeclaration instanceof ClassOrInterfaceDeclaration) {
final ClassOrInterfaceDeclaration clazz = (ClassOrInterfaceDeclaration) typeDeclaration;
// Populate JavaType with type parameters
final List<TypeParameter> typeParameters = clazz
.getTypeParameters();
if (typeParameters != null) {
final Set<JavaSymbolName> locatedTypeParameters = new HashSet<JavaSymbolName>();
for (final TypeParameter candidate : typeParameters) {
final JavaSymbolName currentTypeParam = new JavaSymbolName(
candidate.getName());
locatedTypeParameters.add(currentTypeParam);
JavaType javaType = null;
if (candidate.getTypeBound() == null) {
javaType = new JavaType(
OBJECT.getFullyQualifiedTypeName(), 0,
DataType.TYPE, currentTypeParam, null);
}
else {
final ClassOrInterfaceType cit = candidate
.getTypeBound().get(0);
javaType = JavaParserUtils.getJavaTypeNow(
compilationUnitServices, cit,
locatedTypeParameters);
javaType = new JavaType(
javaType.getFullyQualifiedTypeName(),
javaType.getArray(), javaType.getDataType(),
currentTypeParam, javaType.getParameters());
}
parameterTypes.add(javaType);
}
}
}
return new JavaType(effectiveType.getFullyQualifiedTypeName(),
effectiveType.getArray(), effectiveType.getDataType(), null,
parameterTypes);
}