PsiElementPredicate () { return element -> { if (!(element instanceof GrConditionalExpression condExp)) { return false; } PsiType condType = condExp.getType(); if (condType == null || !PsiTypes.booleanType().isConvertibleFrom(condType)) { return false; } GrExpression thenBranch = condExp.getThenBranch(); GrExpression elseBranch = condExp.getElseBranch(); Object thenVal = GroovyConstantExpressionEvaluator.evaluate(thenBranch); if (Boolean.TRUE.equals(thenVal) && elseBranch != null) { return true; } Object elseVal = GroovyConstantExpressionEvaluator.evaluate(elseBranch); if (thenBranch != null && Boolean.FALSE.equals(elseVal)) { return true; } return false; }; }