use of com.github.javaparser.ast.nodeTypes.NodeWithTypeParameters in project javaparser by javaparser.
the class JavaParserTypeAdapter method solveType.
public SymbolReference<ResolvedTypeDeclaration> solveType(String name, TypeSolver typeSolver) {
if (wrappedNode instanceof NodeWithTypeParameters<?>) {
NodeList<TypeParameter> typeParameters = ((NodeWithTypeParameters<?>) wrappedNode).getTypeParameters();
for (com.github.javaparser.ast.type.TypeParameter typeParameter : typeParameters) {
if (typeParameter.getName().getId().equals(name)) {
return SymbolReference.solved(new JavaParserTypeVariableDeclaration(typeParameter, typeSolver));
}
}
}
// Internal classes
for (BodyDeclaration<?> member : this.wrappedNode.getMembers()) {
if (member instanceof com.github.javaparser.ast.body.TypeDeclaration) {
com.github.javaparser.ast.body.TypeDeclaration<?> internalType = (com.github.javaparser.ast.body.TypeDeclaration<?>) member;
String prefix = internalType.getName() + ".";
if (internalType.getName().getId().equals(name)) {
if (internalType instanceof ClassOrInterfaceDeclaration) {
return SymbolReference.solved(new JavaParserClassDeclaration((com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) internalType, typeSolver));
} else if (internalType instanceof EnumDeclaration) {
return SymbolReference.solved(new JavaParserEnumDeclaration((com.github.javaparser.ast.body.EnumDeclaration) internalType, typeSolver));
} else {
throw new UnsupportedOperationException();
}
} else if (name.startsWith(prefix) && name.length() > prefix.length()) {
if (internalType instanceof ClassOrInterfaceDeclaration) {
return new JavaParserClassDeclaration((com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) internalType, typeSolver).solveType(name.substring(prefix.length()), typeSolver);
} else if (internalType instanceof EnumDeclaration) {
return new SymbolSolver(typeSolver).solveTypeInType(new JavaParserEnumDeclaration((com.github.javaparser.ast.body.EnumDeclaration) internalType, typeSolver), name.substring(prefix.length()));
} else {
throw new UnsupportedOperationException();
}
}
}
}
return SymbolReference.unsolved(ResolvedTypeDeclaration.class);
}
Aggregations