PsiExpression (@NotNull PsiSwitchExpression switchExpression) { PsiCodeBlock body = switchExpression.getBody(); if (body == null) return null; PsiStatement[] statements = body.getStatements(); if (statements.length != 1 || !(statements[0] instanceof PsiSwitchLabeledRuleStatement rule)) return null; PsiStatement ruleBody = rule.getBody(); if (!(ruleBody instanceof PsiExpressionStatement expressionStatement)) return null; return expressionStatement.getExpression(); }