void (@NotNull PsiClass outerClass, @NotNull PsiElementFactory elementFactory, @NotNull PsiMethodCallExpression callExpression) { String className = ClassUtil.getJVMClassName(myPsiClass); String returnType = PsiReflectionAccessUtil.getAccessibleReturnType(myNewExpression, myPsiClass); PsiExpressionList argumentList = myNewExpression.getArgumentList(); if (className == null || argumentList == null || returnType == null) { LOG.warn("code is incomplete: " + myNewExpression); return; } String methodName = PsiReflectionAccessUtil.getUniqueMethodName(outerClass, methodName(className)); ReflectionAccessMethodBuilder methodBuilder = new ReflectionAccessMethodBuilder(methodName); methodBuilder.accessedConstructor(className) .setStatic(outerClass.hasModifierProperty(PsiModifier.STATIC)) .setReturnType(returnType); if (myConstructor != null) { methodBuilder.addParameters(myConstructor.getParameterList()); } PsiMethod newPsiMethod = methodBuilder.build(elementFactory, outerClass); outerClass.add(newPsiMethod); String args = StreamEx.of(argumentList.getExpressions()).map(x -> x.getText()).joining(", ", "(", ")"); String newCallExpression = newPsiMethod.getName() + args; myNewExpression.replace(elementFactory.createExpressionFromText(newCallExpression, myNewExpression)); }