void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { final PsiIdentifier name = (PsiIdentifier)startElement; final PsiReferenceExpression expression = (PsiReferenceExpression)name.getParent(); if (expression == null) { return; } final PsiExpression call = (PsiExpression)expression.getParent(); final PsiExpression qualifier = expression.getQualifierExpression(); if (qualifier == null) { return; } final PsiBinaryExpression multiplication = (PsiBinaryExpression)getContainingExpression(call); if (multiplication == null) { return; } final PsiExpression cast = getContainingExpression(multiplication); if (cast == null) { return; } final PsiExpression lhs = multiplication.getLOperand(); final PsiExpression strippedLhs = PsiUtil.skipParenthesizedExprDown(lhs); final PsiExpression multiplierExpression = call.equals(strippedLhs) ? multiplication.getROperand() : lhs; assert multiplierExpression != null; CommentTracker commentTracker = new CommentTracker(); final String multiplierText = commentTracker.text(multiplierExpression); PsiReplacementUtil.replaceExpression(cast, commentTracker.text(qualifier) + ".nextInt((int) " + multiplierText + ')', commentTracker); }