Search in sources :

Example 6 with ASTResultType

use of net.sourceforge.pmd.lang.java.ast.ASTResultType in project pmd-eclipse-plugin by pmd.

the class ASTUtil method returnType.

public static String returnType(ASTMethodDeclaration node) {
    for (int ix = 0; ix < node.jjtGetNumChildren(); ix++) {
        Node sn = node.jjtGetChild(ix);
        if (sn instanceof ASTResultType) {
            ASTResultType resultType = (ASTResultType) sn;
            AbstractNode param = resultType.getFirstDescendantOfType(ASTClassOrInterfaceType.class);
            if (param == null) {
                param = resultType.getFirstDescendantOfType(ASTPrimitiveType.class);
            }
            if (param == null) {
                continue;
            }
            return param.getImage();
        }
    }
    return null;
}
Also used : ASTPrimitiveType(net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType) AbstractNode(net.sourceforge.pmd.lang.ast.AbstractNode) AbstractNode(net.sourceforge.pmd.lang.ast.AbstractNode) Node(net.sourceforge.pmd.lang.ast.Node) AbstractJavaAccessNode(net.sourceforge.pmd.lang.java.ast.AbstractJavaAccessNode) ASTResultType(net.sourceforge.pmd.lang.java.ast.ASTResultType)

Aggregations

ASTResultType (net.sourceforge.pmd.lang.java.ast.ASTResultType)6 Node (net.sourceforge.pmd.lang.ast.Node)4 ASTPrimitiveType (net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType)3 ASTFieldDeclaration (net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration)2 ASTMethodDeclaration (net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration)2 AbstractNode (net.sourceforge.pmd.lang.ast.AbstractNode)1 ASTClassOrInterfaceDeclaration (net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration)1 ASTClassOrInterfaceType (net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType)1 ASTConstructorDeclaration (net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration)1 ASTFormalParameter (net.sourceforge.pmd.lang.java.ast.ASTFormalParameter)1 ASTMethodDeclarator (net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator)1 AbstractJavaAccessNode (net.sourceforge.pmd.lang.java.ast.AbstractJavaAccessNode)1