void (@NotNull ActionContext context, @NotNull PsiExpression expression, @NotNull ModPsiUpdater updater) { PsiType type = expression.getType(); if (type == null) { LOG.error("Expression type is null"); return; } PsiMethod wrapper = findWrapper(type, myExpectedType, myPrimitiveExpected, expression); if (wrapper == null) { LOG.error("Wrapper not found; expectedType = " + myExpectedType.getCanonicalText() + "; primitiveExpected = " + myPrimitiveExpected); return; } PsiElementFactory factory = JavaPsiFacade.getElementFactory(context.project()); @NonNls String methodCallText = "Foo." + wrapper.getName() + "()"; PsiMethodCallExpression call = (PsiMethodCallExpression)factory.createExpressionFromText(methodCallText, null); call.getArgumentList().add(expression); PsiReferenceExpression qualifier = (PsiReferenceExpression)Objects.requireNonNull(call.getMethodExpression().getQualifierExpression()); PsiClass wrapperClass = Objects.requireNonNull(wrapper.getContainingClass()); qualifier.bindToElement(wrapperClass); expression.replace(call); }