PsiExpression (PsiExpression expression, LanguageLevel languageLevel) { expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression == null) { return null; } if (languageLevel.isAtLeast(LanguageLevel.JDK_1_7)) { final PsiExpression jdk17Expression = determinePossibleJdk17SwitchExpression(expression, null); if (jdk17Expression != null) { return jdk17Expression; } } final EqualityCheck check = EqualityCheck.from(expression); if (check != null) { final PsiExpression left = check.getLeft(); final PsiExpression right = check.getRight(); if (canBeCaseLabel(left, languageLevel, null)) { return right; } else if (canBeCaseLabel(right, languageLevel, null)) { return left; } } if (HighlightingFeature.PATTERNS_IN_SWITCH.isAvailable(expression)) { final PsiExpression patternSwitchExpression = findPatternSwitchExpression(expression); if (patternSwitchExpression != null) return patternSwitchExpression; } if (!(expression instanceof PsiPolyadicExpression polyadicExpression)) { return null; } final IElementType operation = polyadicExpression.getOperationTokenType(); final PsiExpression[] operands = polyadicExpression.getOperands(); if (operation.equals(JavaTokenType.OROR) && operands.length > 0) { return getPossibleSwitchSelectorExpression(operands[0], languageLevel); } else if (operation.equals(JavaTokenType.EQEQ) && operands.length == 2) { final PsiExpression lhs = PsiUtil.skipParenthesizedExprDown(operands[0]); final PsiExpression rhs = PsiUtil.skipParenthesizedExprDown(operands[1]); if (canBeCaseLabel(lhs, languageLevel, null)) { return rhs; } else if (canBeCaseLabel(rhs, languageLevel, null)) { return lhs; } } return null; }