Search in sources :

Example 6 with ASTLiteralExpression

use of net.sourceforge.pmd.lang.apex.ast.ASTLiteralExpression in project pmd by pmd.

the class ApexXSSFromEscapeFalseRule method validateBooleanParameter.

private void validateBooleanParameter(ASTMethodCallExpression methodCall, Object data) {
    int numberOfChildren = methodCall.jjtGetNumChildren();
    if (numberOfChildren == 3) {
        // addError('',false)
        Object potentialLiteral = methodCall.jjtGetChild(2);
        if (potentialLiteral instanceof ASTLiteralExpression) {
            ASTLiteralExpression parameter = (ASTLiteralExpression) potentialLiteral;
            Object o = parameter.getNode().getLiteral();
            if (o instanceof Boolean) {
                Boolean paramValue = (Boolean) o;
                if (paramValue.equals(Boolean.FALSE)) {
                    validateLiteralPresence(methodCall, data);
                }
            }
        }
    }
}
Also used : ASTLiteralExpression(net.sourceforge.pmd.lang.apex.ast.ASTLiteralExpression)

Aggregations

ASTLiteralExpression (net.sourceforge.pmd.lang.apex.ast.ASTLiteralExpression)6 ASTVariableExpression (net.sourceforge.pmd.lang.apex.ast.ASTVariableExpression)5 ASTBinaryExpression (net.sourceforge.pmd.lang.apex.ast.ASTBinaryExpression)2 ASTMethodCallExpression (net.sourceforge.pmd.lang.apex.ast.ASTMethodCallExpression)2 ASTVariableDeclaration (net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclaration)2 VariableDeclaration (apex.jorje.semantic.ast.statement.VariableDeclaration)1 StandardFieldInfo (apex.jorje.semantic.symbol.member.variable.StandardFieldInfo)1 Field (java.lang.reflect.Field)1 ASTAssignmentExpression (net.sourceforge.pmd.lang.apex.ast.ASTAssignmentExpression)1 ASTField (net.sourceforge.pmd.lang.apex.ast.ASTField)1