Search in sources :

Example 1 with ASTFormalParameters

use of net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameters in project pmd by pmd.

the class MethodNameDeclaration method getParameterDisplaySignature.

public String getParameterDisplaySignature() {
    StringBuilder sb = new StringBuilder("(");
    ASTFormalParameters params = (ASTFormalParameters) node.jjtGetChild(0);
    // no need to trim at the end
    for (int i = 0; i < ((ASTMethodDeclarator) node).getParameterCount(); i++) {
        ASTFormalParameter p = (ASTFormalParameter) params.jjtGetChild(i);
        sb.append(p.getTypeNode().getTypeImage());
        // if (p.isVarargs()) {
        // sb.append("...");
        // }
        sb.append(',');
    }
    if (sb.charAt(sb.length() - 1) == ',') {
        sb.deleteCharAt(sb.length() - 1);
    }
    sb.append(')');
    return sb.toString();
}
Also used : ASTFormalParameters(net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameters) ASTFormalParameter(net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameter)

Example 2 with ASTFormalParameters

use of net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameters in project pmd by pmd.

the class MethodNameDeclaration method equals.

@Override
public boolean equals(Object o) {
    if (!(o instanceof MethodNameDeclaration)) {
        return false;
    }
    MethodNameDeclaration other = (MethodNameDeclaration) o;
    // compare name
    if (!other.node.getImage().equals(node.getImage())) {
        return false;
    }
    // params, too
    if (((ASTMethodDeclarator) other.node).getParameterCount() != ((ASTMethodDeclarator) node).getParameterCount()) {
        return false;
    }
    // compare parameter types
    // SRT ASTFormalParameters myParams = (ASTFormalParameters)
    // node.jjtGetChild(0);
    // SRT ASTFormalParameters otherParams = (ASTFormalParameters)
    // other.node.jjtGetChild(0);
    ASTFormalParameters myParams = node.getFirstDescendantOfType(ASTFormalParameters.class);
    ASTFormalParameters otherParams = other.node.getFirstDescendantOfType(ASTFormalParameters.class);
    for (int i = 0; i < ((ASTMethodDeclarator) node).getParameterCount(); i++) {
        ASTFormalParameter myParam = (ASTFormalParameter) myParams.jjtGetChild(i);
        ASTFormalParameter otherParam = (ASTFormalParameter) otherParams.jjtGetChild(i);
        // Compare vararg
        // if (myParam.isVarargs() != otherParam.isVarargs()) {
        // return false;
        // }
        Node myTypeNode = myParam.getTypeNode().jjtGetChild(0);
        Node otherTypeNode = otherParam.getTypeNode().jjtGetChild(0);
        // compare primitive vs reference type
        if (myTypeNode.getClass() != otherTypeNode.getClass()) {
            return false;
        }
        // simple comparison of type images
        // this can be fooled by one method using "String"
        // and the other method using "java.lang.String"
        // once we get real types in here that should get fixed
        String myTypeImg;
        String otherTypeImg;
        // if (myTypeNode instanceof ASTPrimitiveType) {
        // myTypeImg = myTypeNode.getImage();
        // otherTypeImg = otherTypeNode.getImage();
        // } else {
        myTypeImg = ((AbstractPLSQLNode) myTypeNode.jjtGetChild(0)).getImage();
        otherTypeImg = ((AbstractPLSQLNode) otherTypeNode.jjtGetChild(0)).getImage();
        if (!myTypeImg.equals(otherTypeImg)) {
            return false;
        }
    // if type is ASTPrimitiveType and is an array, make sure the other
    // one is also
    }
    return true;
}
Also used : AbstractPLSQLNode(net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode) Node(net.sourceforge.pmd.lang.ast.Node) ASTFormalParameters(net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameters) ASTFormalParameter(net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameter)

Aggregations

ASTFormalParameter (net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameter)2 ASTFormalParameters (net.sourceforge.pmd.lang.plsql.ast.ASTFormalParameters)2 Node (net.sourceforge.pmd.lang.ast.Node)1 AbstractPLSQLNode (net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode)1