PsiExpression (@NotNull PsiExpression arg) { arg = ObjectUtils.coalesce(unwrapExpression(arg), arg); if (PsiUtil.isLanguageLevel5OrHigher(arg)) { return arg; } final PsiType type = arg.getType(); if (!(type instanceof PsiPrimitiveType) || type.equals(PsiTypes.nullType())) { return arg; } final PsiPrimitiveType primitiveType = (PsiPrimitiveType)type; final String boxedQName = primitiveType.getBoxedTypeName(); if (boxedQName == null) { return arg; } final GlobalSearchScope resolveScope = arg.getResolveScope(); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(arg.getProject()); final PsiJavaCodeReferenceElement ref = factory.createReferenceElementByFQClassName(boxedQName, resolveScope); final PsiNewExpression newExpr = (PsiNewExpression)factory.createExpressionFromText("new A(b)", null); final PsiElement classRef = newExpr.getClassReference(); assert classRef != null; classRef.replace(ref); final PsiExpressionList argumentList = newExpr.getArgumentList(); assert argumentList != null; argumentList.getExpressions()[0].replace(arg); return newExpr; }