void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiElement parent = element.getParent(); while (parent instanceof PsiPrefixExpression) { parent = parent.getParent(); } if (!(parent instanceof PsiTypeCastExpression typeCastExpression)) { return; } final PsiElement grandParent = typeCastExpression.getParent(); if (!(grandParent instanceof PsiPolyadicExpression polyadicExpression)) { return; } final PsiExpression operand = typeCastExpression.getOperand(); if (operand == null) { return; } final PsiType type = polyadicExpression.getType(); if (type == null) { return; } @NonNls final StringBuilder newExpression = new StringBuilder(); CommentTracker commentTracker = new CommentTracker(); newExpression.append("(").append(type.getCanonicalText()).append(")("); final PsiExpression[] operands = polyadicExpression.getOperands(); for (final PsiExpression expression : operands) { final PsiJavaToken token = polyadicExpression.getTokenBeforeOperand(expression); if (token != null) { newExpression.append(token.getText()); } if (typeCastExpression.equals(expression)) { newExpression.append(commentTracker.text(operand)); } else { newExpression.append(commentTracker.text(expression)); } } newExpression.append(')'); PsiReplacementUtil.replaceExpression(polyadicExpression, newExpression.toString(), commentTracker); }