private boolean processReference(@NotNull PsiVariable variable, @NotNull PsiReferenceExpression expr, PsiElement parent) {
            if (NullabilityKt.isUsedInAutoUnboxingContext(expr)) {
                registerNotNullAnnotation(variable);
                return true;
            }

            if (PsiUtil.isAccessedForWriting(expr)) return true;

            if (NullabilityKt.getDfaNullability(expr) == DfaNullability.NOT_NULL) {
                // If Java DFA can determine that the nullability of the reference is definitely not-null,
                // we are probably inside an "instance of" check (which is like a smart cast for Java DFA).
                // So we give up trying to guess the nullability of the declaration from this reference.
                return false;
            }

            if (parent instanceof PsiThrowStatement) {
                registerNotNullAnnotation(variable);
                return true;
            } else if (parent instanceof PsiSynchronizedStatement) {
                registerNotNullAnnotation(variable);
                return true;
            } else if (parent instanceof PsiArrayAccessExpression) {
                // For both array and index expressions
                registerNotNullAnnotation(variable);
                return true;
            } else if (parent instanceof PsiBinaryExpression binOp) {
                PsiExpression opposite = null;
                final PsiExpression lOperand = binOp.getLOperand();
                final PsiExpression rOperand = binOp.getROperand();
                if (lOperand == expr) {
                    opposite = rOperand;
                } else if (rOperand == expr) {
                    opposite = lOperand;
                }

                if (opposite != null && opposite.getType() == PsiTypes.nullType()) {
                    if (DfaPsiUtil.isAssertionEffectively(binOp, binOp.getOperationTokenType() == JavaTokenType.NE)) {
                        registerNotNullAnnotation(variable);
                        return true;
                    }
                    registerNullableAnnotation(variable);
                    return true;
                }
            } else if (parent instanceof PsiReferenceExpression ref) {
                final PsiExpression qualifierExpression = ref.getQualifierExpression();
                if (qualifierExpression == expr) {
                    registerNotNullAnnotation(variable);
                    return true;
                } else {
                    PsiElement exprParent = expr.getParent();
                    while (exprParent instanceof PsiTypeCastExpression || exprParent instanceof PsiParenthesizedExpression) {
                        if (qualifierExpression == exprParent) {
                            registerNotNullAnnotation(variable);
                            return true;
                        }
                        exprParent = exprParent.getParent();
                    }
                }
            } else if (parent instanceof PsiAssignmentExpression assignment) {
                if (assignment.getRExpression() == expr &&
                    assignment.getLExpression() instanceof PsiReferenceExpression ref &&
                    ref.resolve() instanceof PsiVariable localVar && isNotNull(localVar)) {
                    registerNotNullAnnotation(variable);
                    return true;
                }
            } else if (parent instanceof PsiForeachStatement forEach) {
                if (forEach.getIteratedValue() == expr) {
                    registerNotNullAnnotation(variable);
                    return true;
                }
            } else if (parent instanceof PsiSwitchStatement switchStatement && switchStatement.getExpression() == expr) {
                registerNotNullAnnotation(variable);
                return true;
            }

            if (processArgumentReference(variable, expr)) {
                return true;
            }

            return false;
        }
private boolean processReference(@NotNull PsiVariable variable, @NotNull PsiReferenceExpression expr, PsiElement parent)