/** * Required for accurate reporting. * If condition is && or || expression, then return its right operand. */ private static ExpressionTree cleanupCondition(ExpressionTree condition) { ExpressionTree cleanedUpCondition = ExpressionUtils.skipParentheses(condition); if (cleanedUpCondition.is(Tree.Kind.CONDITIONAL_AND, Tree.Kind.CONDITIONAL_OR)) { cleanedUpCondition = cleanupCondition(((BinaryExpressionTree) cleanedUpCondition).rightOperand()); } return cleanedUpCondition; }
/** * Required for accurate reporting. * If condition is && or || expression, then return its right operand. */ private static ExpressionTree cleanupCondition(ExpressionTree condition) { ExpressionTree cleanedUpCondition = ExpressionUtils.skipParentheses(condition); if (cleanedUpCondition.is(Tree.Kind.CONDITIONAL_AND, Tree.Kind.CONDITIONAL_OR)) { cleanedUpCondition = cleanupCondition(((BinaryExpressionTree) cleanedUpCondition).rightOperand()); } return cleanedUpCondition; }
alwaysTrueOrFalseExpressionCollector.evaluatedToFalse(cleanupCondition((ExpressionTree) condition), node); alwaysTrueOrFalseExpressionCollector.evaluatedToTrue(cleanupCondition((ExpressionTree) condition), node);
alwaysTrueOrFalseExpressionCollector.evaluatedToFalse(cleanupCondition((ExpressionTree) condition), node); alwaysTrueOrFalseExpressionCollector.evaluatedToTrue(cleanupCondition((ExpressionTree) condition), node);
switch (terminator.kind()) { case IF_STATEMENT: handleBranch(block, cleanupCondition(((IfStatementTree) terminator).condition())); return; case CONDITIONAL_OR: case WHILE_STATEMENT: ExpressionTree whileCondition = ((WhileStatementTree) terminator).condition(); handleBranch(block, cleanupCondition(whileCondition), !whileCondition.is(Tree.Kind.BOOLEAN_LITERAL)); return; case DO_STATEMENT: ExpressionTree doCondition = ((DoWhileStatementTree) terminator).condition(); handleBranch(block, cleanupCondition(doCondition), !doCondition.is(Tree.Kind.BOOLEAN_LITERAL)); return; case SYNCHRONIZED_STATEMENT:
case IF_STATEMENT: ExpressionTree ifCondition = ((IfStatementTree) terminator).condition(); handleBranch(block, cleanupCondition(ifCondition), verifyCondition(ifCondition)); return; case CONDITIONAL_OR: case WHILE_STATEMENT: ExpressionTree whileCondition = ((WhileStatementTree) terminator).condition(); handleBranch(block, cleanupCondition(whileCondition), verifyCondition(whileCondition)); return; case DO_STATEMENT: ExpressionTree doCondition = ((DoWhileStatementTree) terminator).condition(); handleBranch(block, cleanupCondition(doCondition), verifyCondition(doCondition)); return; case SYNCHRONIZED_STATEMENT:
case IF_STATEMENT: ExpressionTree ifCondition = ((IfStatementTree) terminator).condition(); handleBranch(block, cleanupCondition(ifCondition), verifyCondition(ifCondition)); return; case CONDITIONAL_OR: case WHILE_STATEMENT: ExpressionTree whileCondition = ((WhileStatementTree) terminator).condition(); handleBranch(block, cleanupCondition(whileCondition), verifyCondition(whileCondition)); return; case DO_STATEMENT: ExpressionTree doCondition = ((DoWhileStatementTree) terminator).condition(); handleBranch(block, cleanupCondition(doCondition), verifyCondition(doCondition)); return; case SYNCHRONIZED_STATEMENT: