private static PsiMethodReferenceExpression createMethodReference( PsiMethodReferenceExpression expression, PsiTypeElement typeElement) { final PsiType type = typeElement.getType(); final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(expression.getProject()); final PsiMethodReferenceExpression copy = (PsiMethodReferenceExpression) expression.copy(); copy.getQualifierType() .replace(elementFactory.createTypeElement(((PsiClassType) type).rawType())); return copy; }