private static @Nullable SearchScope getScope(@NotNull PsiVariable variable) {
        if (!(variable instanceof PsiField field)) {
            return variable.getUseScope();
        }

        if (isPrivate(field)) {
            return variable.getUseScope();
        }

        // Optimization: for public and protected fields, don't try to search for usages outside the file
        // because it can be very slow in large projects
        PsiFile containingFile = variable.getContainingFile();
        return containingFile != null ? new LocalSearchScope(containingFile) : null;
    }
private static @Nullable SearchScope getScope(@NotNull PsiVariable variable)