<commit_before>"use strict";

import { TargetLanguage } from "../TargetLanguage";
import {
    Type,
    ClassType,
    EnumType,
    UnionType,
    ArrayType,
    MapType,
    matchType,
    nullableFromUnion,
    removeNullFromUnion,
    TypeKind,
    ClassProperty
} from "../Type";
import { TypeGraph } from "../TypeGraph";
import { Name, Namer, funPrefixNamer } from "../Naming";
import { BooleanOption, EnumOption, Option } from "../RendererOptions";
import { Sourcelike, maybeAnnotated, modifySource } from "../Source";
import { anyTypeIssueAnnotation, nullTypeIssueAnnotation } from "../Annotation";
import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
import {
    legalizeCharacters,
    isLetterOrUnderscore,
    isNumeric,
    isDigit,
    utf32ConcatMap,
    escapeNonPrintableMapper,
    isPrintable,
    intToHex,
    splitIntoWords,
    combineWords,
    firstUpperWordStyle,
    allLowerWordStyle,
    allUpperWordStyle,
    camelCase
} from "../Strings";
import { intercalate } from "../Support";
import { List } from "immutable";

const MAX_SAMELINE_PROPERTIES = 4;

export type Version = 4 | 4.1;

export default class SwiftTargetLanguage extends TargetLanguage {
    private readonly _justTypesOption = new BooleanOption("just-types", "Plain types only", false);
    private readonly _convenienceInitializers = new BooleanOption("initializers", "Convenience initializers", true);
    private readonly _alamofireHandlers = new BooleanOption("alamofire", "Alamofire extensions", false);

    private readonly _classOption = new EnumOption("struct-or-class", "Structs or classes", [
        ["struct", false],
        ["class", true]
    ]);

    private readonly _versionOption = new EnumOption<Version>(
        "swift-version",
        "Swift version",
        [["4", 4], ["4.1", 4.1]],
        "4",
        "secondary"
    );

    private readonly _denseOption = new EnumOption(
        "density",
        "Code density",
        [["dense", true], ["normal", false]],
        "dense",
        "secondary"
    );

    private readonly _accessLevelOption = new EnumOption(
        "access-level",
        "Access level",
        [["public", "public"], ["internal", "internal"]],
        "internal"
    );

    constructor() {
        super("Swift", ["swift", "swift4"], "swift");
    }

    protected getOptions(): Option<any>[] {
        return [
            this._justTypesOption,
            this._classOption,
            this._denseOption,
            this._versionOption,
            this._convenienceInitializers,
            this._accessLevelOption,
            this._alamofireHandlers
        ];
    }

    get supportsOptionalClassProperties(): boolean {
        return true;
    }

    get supportsUnionsWithBothNumberTypes(): boolean {
        return true;
    }
<commit_msg>Swift access level is really a secondary option<commit_after>"use strict";

import { TargetLanguage } from "../TargetLanguage";
import {
    Type,
    ClassType,
    EnumType,
    UnionType,
    ArrayType,
    MapType,
    matchType,
    nullableFromUnion,
    removeNullFromUnion,
    TypeKind,
    ClassProperty
} from "../Type";
import { TypeGraph } from "../TypeGraph";
import { Name, Namer, funPrefixNamer } from "../Naming";
import { BooleanOption, EnumOption, Option } from "../RendererOptions";
import { Sourcelike, maybeAnnotated, modifySource } from "../Source";
import { anyTypeIssueAnnotation, nullTypeIssueAnnotation } from "../Annotation";
import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
import {
    legalizeCharacters,
    isLetterOrUnderscore,
    isNumeric,
    isDigit,
    utf32ConcatMap,
    escapeNonPrintableMapper,
    isPrintable,
    intToHex,
    splitIntoWords,
    combineWords,
    firstUpperWordStyle,
    allLowerWordStyle,
    allUpperWordStyle,
    camelCase
} from "../Strings";
import { intercalate } from "../Support";
import { List } from "immutable";

const MAX_SAMELINE_PROPERTIES = 4;

export type Version = 4 | 4.1;

export default class SwiftTargetLanguage extends TargetLanguage {
    private readonly _justTypesOption = new BooleanOption("just-types", "Plain types only", false);
    private readonly _convenienceInitializers = new BooleanOption("initializers", "Convenience initializers", true);
    private readonly _alamofireHandlers = new BooleanOption("alamofire", "Alamofire extensions", false);

    private readonly _classOption = new EnumOption("struct-or-class", "Structs or classes", [
        ["struct", false],
        ["class", true]
    ]);

    private readonly _versionOption = new EnumOption<Version>(
        "swift-version",
        "Swift version",
        [["4", 4], ["4.1", 4.1]],
        "4",
        "secondary"
    );

    private readonly _denseOption = new EnumOption(
        "density",
        "Code density",
        [["dense", true], ["normal", false]],
        "dense",
        "secondary"
    );

    private readonly _accessLevelOption = new EnumOption(
        "access-level",
        "Access level",
        [["internal", "internal"], ["public", "public"]],
        "internal",
        "secondary"
    );

    constructor() {
        super("Swift", ["swift", "swift4"], "swift");
    }

    protected getOptions(): Option<any>[] {
        return [
            this._justTypesOption,
            this._classOption,
            this._denseOption,
            this._versionOption,
            this._convenienceInitializers,
            this._accessLevelOption,
            this._alamofireHandlers
        ];
    }

    get supportsOptionalClassProperties(): boolean {
        return true;
    }

    get supportsUnionsWithBothNumberTypes(): boolean {
        return true;
    }

{'fraction_non_alphanumeric': 0.1178627553693033, 'fraction_numerical': 0.004889121704208137, 'mean_word_length': 2.8886625933469112, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6680018', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1564, 'n_words': 398}