use of com.github.antlrjavaparser.api.expr.NameExpr in project spring-roo by spring-projects.
the class JavaParserUtils method getJavaTypeNow.
/**
* Resolves the effective {@link JavaType} a {@link ClassOrInterfaceType}
* represents, including any type arguments.
*
* @param compilationUnitServices for package management (required)
* @param cit the class or interface type to resolve (required)
* @return the effective Java type (never null)
*/
public static JavaType getJavaTypeNow(final CompilationUnitServices compilationUnitServices, final ClassOrInterfaceType cit, final Set<JavaSymbolName> typeParameters) {
Validate.notNull(compilationUnitServices, "Compilation unit services required");
Validate.notNull(cit, "ClassOrInterfaceType required");
final JavaPackage compilationUnitPackage = compilationUnitServices.getCompilationUnitPackage();
Validate.notNull(compilationUnitPackage, "Compilation unit package required");
String typeName = cit.getName();
ClassOrInterfaceType scope = cit.getScope();
while (scope != null) {
typeName = scope.getName() + "." + typeName;
scope = scope.getScope();
}
final NameExpr nameExpr = getNameExpr(typeName);
final JavaType effectiveType = getJavaType(compilationUnitServices, nameExpr, typeParameters);
// Handle any type arguments
final List<JavaType> parameterTypes = new ArrayList<JavaType>();
if (cit.getTypeArgs() != null) {
for (final Type ta : cit.getTypeArgs()) {
parameterTypes.add(getJavaType(compilationUnitServices, ta, typeParameters));
}
}
return new JavaType(effectiveType.getFullyQualifiedTypeName(), effectiveType.getArray(), effectiveType.getDataType(), null, parameterTypes);
}
Aggregations