use of net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType in project pmd by pmd.
the class MethodNameDeclaration method hashCode.
@Override
public int hashCode() {
int hash = node.getImage().hashCode() * 31 + ((ASTMethodDeclarator) node).getParameterCount();
ASTFormalParameters myParams = (ASTFormalParameters) node.jjtGetChild(0);
for (int i = 0; i < ((ASTMethodDeclarator) node).getParameterCount(); i++) {
ASTFormalParameter myParam = (ASTFormalParameter) myParams.jjtGetChild(i);
Node myTypeNode = myParam.getTypeNode().jjtGetChild(0);
String myTypeImg;
if (myTypeNode instanceof ASTPrimitiveType) {
myTypeImg = myTypeNode.getImage();
} else {
myTypeImg = myTypeNode.jjtGetChild(0).getImage();
}
hash = hash * 31 + myTypeImg.hashCode();
}
return hash;
}
use of net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType in project pmd by pmd.
the class ConstructorCallsOverridableMethodRule method getMethodDeclaratorParameterTypes.
private static List<String> getMethodDeclaratorParameterTypes(Node methodOrConstructorDeclarator) {
List<ASTFormalParameter> parameters = methodOrConstructorDeclarator.findDescendantsOfType(ASTFormalParameter.class);
List<String> parameterTypes = new ArrayList<>();
if (parameters != null) {
for (ASTFormalParameter p : parameters) {
ASTType type = p.getFirstChildOfType(ASTType.class);
if (type.jjtGetChild(0) instanceof ASTPrimitiveType) {
parameterTypes.add(type.jjtGetChild(0).getImage());
} else if (type.jjtGetChild(0) instanceof ASTReferenceType) {
parameterTypes.add("ref");
} else {
parameterTypes.add("<unkown>");
}
}
}
return parameterTypes;
}
Aggregations