boolean (final PsiExpression expression) { if (expression instanceof PsiFunctionalExpression) { return true; } if (expression instanceof PsiParenthesizedExpression) { return isPolyExpression(((PsiParenthesizedExpression)expression).getExpression()); } if (expression instanceof PsiNewExpression && PsiDiamondType.hasDiamond((PsiNewExpression)expression)) { return isInAssignmentOrInvocationContext(expression); } if (expression instanceof PsiMethodCallExpression) { return isMethodCallPolyExpression(expression, expr -> ((PsiMethodCallExpression)expr).resolveMethod()); } if (expression instanceof PsiConditionalExpression) { final ConditionalKind conditionalKind = isBooleanOrNumeric(expression); if (conditionalKind == null) { return isInAssignmentOrInvocationContext(expression); } } if (expression instanceof PsiSwitchExpression) { return isInAssignmentOrInvocationContext(expression); } return false; }