String (PsiExpression expression, boolean castToInt) { if (expression instanceof PsiReferenceExpression referenceExpression) { final PsiElement target = referenceExpression.resolve(); if (target instanceof PsiEnumConstant enumConstant) { return enumConstant.getName(); } } final String patternCaseText = SwitchUtils.createPatternCaseText(expression); if (patternCaseText != null) return patternCaseText; if (castToInt) { final PsiType type = expression.getType(); if (!PsiTypes.intType().equals(type)) { /* because Integer a = 1; switch (a) { case (byte)7: } does not compile with javac (but does with Eclipse) */ return "(int)" + expression.getText(); } } return expression.getText(); }