private static PsiJavaCodeReferenceElement rebind(PsiJavaCodeReferenceElement reference, PsiClass targetClass) {
    PsiElementFactory factory = JavaPsiFacade.getElementFactory(reference.getProject());
    PsiReferenceExpression copy = (PsiReferenceExpression)factory.createExpressionFromText("A." + reference.getReferenceName(), null);
    reference = (PsiReferenceExpression)reference.replace(copy);
    PsiReferenceExpression qualifier = Objects.requireNonNull((PsiReferenceExpression)reference.getQualifier());
    qualifier.bindToElement(targetClass);
    return reference;
  }
private static PsiJavaCodeReferenceElement rebind(PsiJavaCodeReferenceElement reference, PsiClass targetClass)