void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { final PsiConditionalExpression expression = (PsiConditionalExpression)startElement; CommentTracker ct = new CommentTracker(); final PsiExpression replacement = calculateReplacementExpression(expression); PsiType type = replacement.getType(); PsiType expressionType = expression.getType(); if (type != null && expressionType != null && !type.equals(expressionType) && PsiTypesUtil.isDenotableType(expressionType, expression)) { PsiTypeCastExpression castExpression = (PsiTypeCastExpression)ct .replaceAndRestoreComments(expression, "(" + expressionType.getCanonicalText() + ")" + ct.text(replacement, PsiPrecedenceUtil.TYPE_CAST_PRECEDENCE)); if (RedundantCastUtil.isCastRedundant(castExpression)) { RemoveRedundantCastUtil.removeCast(castExpression); } } else { ct.replaceAndRestoreComments(expression, replacement); } }