int (PsiExpression expression) { if (!isBoolean(expression)) { return 1; } if (expression instanceof PsiPolyadicExpression polyadicExpression) { final PsiExpression[] operands = polyadicExpression.getOperands(); return Arrays.stream(operands).mapToInt(this::countTerms).sum(); } else if (expression instanceof PsiPrefixExpression prefixExpression) { return countTerms(prefixExpression.getOperand()); } else if (expression instanceof PsiParenthesizedExpression parenthesizedExpression) { return countTerms(parenthesizedExpression.getExpression()); } return 1; }