/**
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */
/* Generated By:JJTree: Do not edit this line. ASTExpression.java */

package net.sourceforge.pmd.lang.java.ast;

public class ASTExpression extends AbstractJavaTypeNode {
    public ASTExpression(int id) {
        super(id);
    }

    public ASTExpression(JavaParser p, int id) {
        super(p, id);
    }

    /**
     * Accept the visitor. *
     */
    public Object jjtAccept(JavaParserVisitor visitor, Object data) {
        return visitor.visit(this, data);
    }

    public boolean isStandAlonePrimitive() {
        if (jjtGetNumChildren() != 1) {
            return false;
        }

        ASTPrimaryExpression primaryExpression = getFirstChildOfType(ASTPrimaryExpression.class);

        if (primaryExpression == null || primaryExpression.jjtGetNumChildren() != 1) {
            return false;
        }

        ASTPrimaryPrefix primaryPrefix = primaryExpression.getFirstChildOfType(ASTPrimaryPrefix.class);

        if (primaryPrefix == null || primaryPrefix.jjtGetNumChildren() != 1) {
            return false;
        }

        ASTLiteral literal = primaryPrefix.getFirstChildOfType(ASTLiteral.class);

        if (literal == null || literal.isStringLiteral()
                || (literal.jjtGetNumChildren() != 0 && literal.jjtGetChild(0) instanceof ASTNullLiteral)) {
            return false;
        }

        // byte, short, char, int, long, float, double, boolean
        return true;
    }
}
