void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiExpression expression = tryCast(element, PsiExpression.class); if (expression == null) return; if (!InheritanceUtil.isInheritor(expression.getType(), CommonClassNames.JAVA_UTIL_COLLECTION)) return; PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); String fullReplacementText = ParenthesesUtils.getText(expression, ParenthesesUtils.METHOD_CALL_PRECEDENCE + 1) + ".toArray(new " + myClassName + "[0])"; expression.replace(factory.createExpressionFromText(fullReplacementText, expression)); }