void (@NotNull PsiMethodCallExpression methodCall, @NotNull String callText) { PsiElementFactory factory = JavaPsiFacade.getElementFactory(methodCall.getProject()); PsiMethodCallExpression newCall = (PsiMethodCallExpression)factory.createExpressionFromText(callText, methodCall); methodCall.getArgumentList().replace(newCall.getArgumentList()); PsiElement nameElement = methodCall.getMethodExpression().getReferenceNameElement(); assert nameElement != null; PsiElement newNameElement = newCall.getMethodExpression().getReferenceNameElement(); assert newNameElement != null; nameElement.replace(newNameElement); }