Search in sources :

Example 1 with ParenthesizedLike

use of org.sonar.uast.helpers.ParenthesizedLike in project sonar-go by SonarSource.

the class CognitiveComplexity method flattenBinaryExpressions.

private static void flattenBinaryExpressions(UastNode node, List<BinaryExpressionLike> expressionAsList) {
    ParenthesizedLike parenthesizedNode = ParenthesizedLike.from(node);
    if (parenthesizedNode != null) {
        flattenBinaryExpressions(parenthesizedNode.expression(), expressionAsList);
        return;
    }
    BinaryExpressionLike binaryExpression = BinaryExpressionLike.from(node);
    if (binaryExpression != null && logicalOperatorKind(binaryExpression) != null) {
        flattenBinaryExpressions(binaryExpression.leftOperand(), expressionAsList);
        expressionAsList.add(binaryExpression);
        flattenBinaryExpressions(binaryExpression.rightOperand(), expressionAsList);
    }
}
Also used : ParenthesizedLike(org.sonar.uast.helpers.ParenthesizedLike) BinaryExpressionLike(org.sonar.uast.helpers.BinaryExpressionLike)

Aggregations

BinaryExpressionLike (org.sonar.uast.helpers.BinaryExpressionLike)1 ParenthesizedLike (org.sonar.uast.helpers.ParenthesizedLike)1