use of net.sourceforge.pmd.lang.java.ast.ASTTypeArguments in project pmd by pmd.
the class ClassTypeResolver method visit.
@Override
public Object visit(ASTClassOrInterfaceType node, Object data) {
super.visit(node, data);
String typeName = node.getImage();
if (node.isAnonymousClass()) {
QualifiableNode parent = node.getFirstParentOfAnyType(ASTAllocationExpression.class, ASTEnumConstant.class);
if (parent != null) {
typeName = parent.getQualifiedName().toString();
}
}
populateType(node, typeName, node.getArrayDepth());
ASTTypeArguments typeArguments = node.getFirstChildOfType(ASTTypeArguments.class);
if (typeArguments != null) {
final JavaTypeDefinition[] boundGenerics = new JavaTypeDefinition[typeArguments.jjtGetNumChildren()];
for (int i = 0; i < typeArguments.jjtGetNumChildren(); ++i) {
boundGenerics[i] = ((TypeNode) typeArguments.jjtGetChild(i)).getTypeDefinition();
}
node.setTypeDefinition(JavaTypeDefinition.forClass(node.getType(), boundGenerics));
}
return data;
}
use of net.sourceforge.pmd.lang.java.ast.ASTTypeArguments in project pmd by pmd.
the class MethodTypeResolution method getMethodExplicitTypeArugments.
public static List<JavaTypeDefinition> getMethodExplicitTypeArugments(Node node) {
ASTMemberSelector memberSelector = node.getFirstChildOfType(ASTMemberSelector.class);
if (memberSelector == null) {
return Collections.emptyList();
}
ASTTypeArguments typeArguments = memberSelector.getFirstChildOfType(ASTTypeArguments.class);
if (typeArguments == null) {
return Collections.emptyList();
}
List<JavaTypeDefinition> result = new ArrayList<>();
for (int childIndex = 0; childIndex < typeArguments.jjtGetNumChildren(); ++childIndex) {
result.add(((TypeNode) typeArguments.jjtGetChild(childIndex)).getTypeDefinition());
}
return result;
}
Aggregations