<commit_before>import { Value, Tag, valueTag, CompressedJSON } from "./CompressedJSON";
import { assertNever } from "../support/Support";
import { TypeBuilder } from "../TypeBuilder";
import { UnionBuilder, UnionAccumulator } from "../UnionBuilder";
import { isTime, isDateTime, isDate } from "../DateTime";
import { ClassProperty } from "../Type";
import { TypeAttributes, emptyTypeAttributes } from "../TypeAttributes";
import { StringTypes } from "../StringTypes";
import { TypeRef } from "../TypeGraph";

// This should be the recursive type
//   Value[] | NestedValueArray[]
// but TypeScript doesn't support that.
export type NestedValueArray = any;

function forEachArrayInNestedValueArray(va: NestedValueArray, f: (va: Value[]) => void): void {
    if (va.length === 0) {
        return;
    }
    if (Array.isArray(va[0])) {
        for (const x of va) {
            forEachArrayInNestedValueArray(x, f);
        }
    } else {
        f(va);
    }
}

function forEachValueInNestedValueArray(va: NestedValueArray, f: (v: Value) => void): void {
    forEachArrayInNestedValueArray(va, a => {
        for (const x of a) {
            f(x);
        }
    });
}

class InferenceUnionBuilder extends UnionBuilder<TypeBuilder, NestedValueArray, NestedValueArray> {
    constructor(
        typeBuilder: TypeBuilder,
        private readonly _typeInference: TypeInference,
        private readonly _fixed: boolean
    ) {
        super(typeBuilder);
    }

    protected makeObject(
        objects: NestedValueArray,
        typeAttributes: TypeAttributes,
        forwardingRef: TypeRef | undefined
    ): TypeRef {
        return this._typeInference.inferClassType(typeAttributes, objects, this._fixed, forwardingRef);
    }

    protected makeArray(
        arrays: NestedValueArray,
        typeAttributes: TypeAttributes,
        forwardingRef: TypeRef | undefined
    ): TypeRef {
        return this.typeBuilder.getArrayType(
            typeAttributes,
            this._typeInference.inferType(emptyTypeAttributes, arrays, this._fixed, forwardingRef)
        );
    }
}

function canBeEnumCase(s: string): boolean {
    if (s.length === 0) return true; // FIXME: Do we really want this?
    // FIXME: Haven't we dealt with date-time in compressed JSON?
    return !isDate(s) && !isTime(s) && !isDateTime(s);<commit_msg>Remove dead code<commit_after>import { Value, Tag, valueTag, CompressedJSON } from "./CompressedJSON";
import { assertNever } from "../support/Support";
import { TypeBuilder } from "../TypeBuilder";
import { UnionBuilder, UnionAccumulator } from "../UnionBuilder";
import { ClassProperty } from "../Type";
import { TypeAttributes, emptyTypeAttributes } from "../TypeAttributes";
import { StringTypes } from "../StringTypes";
import { TypeRef } from "../TypeGraph";

// This should be the recursive type
//   Value[] | NestedValueArray[]
// but TypeScript doesn't support that.
export type NestedValueArray = any;

function forEachArrayInNestedValueArray(va: NestedValueArray, f: (va: Value[]) => void): void {
    if (va.length === 0) {
        return;
    }
    if (Array.isArray(va[0])) {
        for (const x of va) {
            forEachArrayInNestedValueArray(x, f);
        }
    } else {
        f(va);
    }
}

function forEachValueInNestedValueArray(va: NestedValueArray, f: (v: Value) => void): void {
    forEachArrayInNestedValueArray(va, a => {
        for (const x of a) {
            f(x);
        }
    });
}

class InferenceUnionBuilder extends UnionBuilder<TypeBuilder, NestedValueArray, NestedValueArray> {
    constructor(
        typeBuilder: TypeBuilder,
        private readonly _typeInference: TypeInference,
        private readonly _fixed: boolean
    ) {
        super(typeBuilder);
    }

    protected makeObject(
        objects: NestedValueArray,
        typeAttributes: TypeAttributes,
        forwardingRef: TypeRef | undefined
    ): TypeRef {
        return this._typeInference.inferClassType(typeAttributes, objects, this._fixed, forwardingRef);
    }

    protected makeArray(
        arrays: NestedValueArray,
        typeAttributes: TypeAttributes,
        forwardingRef: TypeRef | undefined
    ): TypeRef {
        return this.typeBuilder.getArrayType(
            typeAttributes,
            this._typeInference.inferType(emptyTypeAttributes, arrays, this._fixed, forwardingRef)
        );
    }
}

function canBeEnumCase(_s: string): boolean {
    return true;
{'fraction_non_alphanumeric': 0.11279043537108054, 'fraction_numerical': 0.0011279043537108053, 'mean_word_length': 3.034576888080073, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1066521', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1227, 'n_words': 327}