private static boolean encodeQualifier(PsiClass containingClass, PsiElement reference, PsiClass targetClass) {
    if (reference instanceof PsiReferenceExpression ref) {
      final PsiElement qualifier = ref.getQualifier();
      if (qualifier != null) {
        if (qualifier instanceof PsiReferenceExpression qualifierRef) {
          final PsiElement resolved = qualifierRef.resolve();
          if (resolved == containingClass || 
              resolved instanceof PsiClass resolvedClass && InheritanceUtil.isInheritorOrSelf(targetClass, resolvedClass, true)) {
            return true;
          }
        }
        qualifier.putCopyableUserData(ChangeContextUtil.CAN_REMOVE_QUALIFIER_KEY,
                                      ChangeContextUtil.canRemoveQualifier(ref));
      }
    }
    return false;
  }
private static boolean encodeQualifier(PsiClass containingClass, PsiElement reference, PsiClass targetClass)