void (@NotNull PsiClass outerClass, @NotNull PsiElementFactory elementFactory, @NotNull PsiMethodCallExpression callExpression) { PsiClass containingClass = myMethod.getContainingClass(); String containingClassName = containingClass == null ? null : ClassUtil.getJVMClassName(containingClass); String name = myMethod.getName(); if (containingClassName == null) { LOG.warn("containing class for method \"" + name + "\" not found"); return; } String newMethodName = PsiReflectionAccessUtil.getUniqueMethodName(outerClass, "call" + StringUtil.capitalize(name)); ReflectionAccessMethodBuilder methodBuilder = new ReflectionAccessMethodBuilder(newMethodName); PsiMethod newMethod = methodBuilder.accessedMethod(containingClassName, myMethod.getName()) .setStatic(outerClass.hasModifierProperty(PsiModifier.STATIC)) .addParameter("java.lang.Object", "object") .addParameters(myMethod.getParameterList()) .setReturnType(myAccessibleReturnType) .build(elementFactory, outerClass); outerClass.add(newMethod); String objectToCallOn = MemberQualifierUtil .findObjectExpression(myCallExpression.getMethodExpression(), myMethod, outerClass, callExpression, elementFactory); String args = StreamEx.of(myCallExpression.getArgumentList().getExpressions()) .map(x -> x.getText()) .prepend(objectToCallOn == null ? "null" : objectToCallOn) .joining(", ", "(", ")"); String newMethodCallExpression = newMethod.getName() + args; myCallExpression.replace(elementFactory.createExpressionFromText(newMethodCallExpression, myCallExpression)); }