void (@NotNull ActionContext context, @NotNull PsiExpression expressionToReplace, @NotNull ModPsiUpdater updater) { PsiElementFactory factory = JavaPsiFacade.getElementFactory(context.project()); PsiExpression collectionExpression = myCollectionPointer.getElement(); if (collectionExpression == null) return; String replacement = ParenthesesUtils.getText(collectionExpression, ParenthesesUtils.POSTFIX_PRECEDENCE) + ".toArray(" + myNewArrayText + ")"; expressionToReplace.replace(factory.createExpressionFromText(replacement, collectionExpression)); }