vigoo/moonbit_codegen/name does not have a README file

    Namer

    pub struct Namer {
    // private fields
    }

    Allocates unique identifiers within one scope (a file's types, a struct's fields, a function's parameters). Create one per scope; names reserved in one scope do not affect other scopes.

    Namer::is_taken

    fn Namer::is_taken(self : Namer, name : String) -> Bool

    True if name has been reserved or allocated in this scope.

    Namer::new

    fn Namer::new() -> Namer

    Namer::reserve

    fn Namer::reserve(self : Namer, name : String) -> Unit

    Reserve name so unique / unique_type will never return it.

    Namer::reserve_builtin_types

    fn Namer::reserve_builtin_types(self : Namer) -> Unit

    Reserve MoonBit's un-declarable built-in and core/builtin prelude type names (Error, Self, Unit, Option, Result, Array, Map, Json, primitive numeric/string/byte types, views, FixedArray, etc.) so generated struct / enum / type declarations never trigger compiler error [4003] or shadow prelude types inside a package.

    Namer::unique

    fn Namer::unique(self : Namer, base : String) -> String

    Allocate a unique MoonBit value identifier based on base (guaranteed LIDENT starting with [a-z_] and keyword-escaped): returns base itself when free, otherwise base2, base3, ... The returned name is reserved.

    base is defensively sanitized, keyword-escaped and made valid first, so raw spec input ("", "a b", "type", "2xx", "Foo") cannot produce an invalid value identifier. Use unique_type for UIDENT type/variant names.

    Namer::unique_type

    fn Namer::unique_type(self : Namer, base : String) -> String

    Allocate a unique MoonBit type/variant identifier (guaranteed UIDENT, starting with [A-Z] and keyword-escaped). Note: runs sanitize (not to_pascal), so callers wanting PascalCase should pass ident_pascal(raw).

    ensure_valid_ident

    fn ensure_valid_ident(s : String) -> String

    Ensure s is a valid MoonBit value identifier (LIDENT: non-empty, starts with [a-z_], not bare _, no uppercase/digit start).

    ensure_valid_type_ident

    fn ensure_valid_type_ident(s : String) -> String

    Ensure s is a valid MoonBit type/variant identifier (starts with [A-Z]).

    escape_keyword

    fn escape_keyword(name : String) -> String

    Append _ if name is a MoonBit reserved keyword; otherwise return name unchanged.

    ident_pascal

    fn ident_pascal(input : String) -> String

    Sanitize + PascalCase + UIDENT validity + keyword escape: a valid MoonBit type/variant identifier from any input (r#CreateParams -> CreateParams, $float -> Float, 2xx -> V2Xx, "" -> Unnamed, self -> Self_).

    ident_snake

    fn ident_snake(input : String) -> String

    Sanitize + lower_snake_case + LIDENT validity + keyword escape: a valid MoonBit value identifier from any input (type -> type_, displayName -> display_name, $float -> float, 2xx -> _2_xx, "" -> __).

    is_keyword

    fn is_keyword(s : String) -> Bool

    True if s is a MoonBit hard keyword, lexer reserved keyword (from moonbitlang/lexer 0.4.5), receiver/type-reserved name (self, Self), wildcard (_), or boolean literal (true, false).

    sanitize

    fn sanitize(input : String) -> String

    Strip Rust r# raw-identifier prefixes and replace non-ASCII-identifier characters with _.

    split_words

    fn split_words(input : String) -> Array[String]

    to_camel

    fn to_camel(input : String) -> String

    Convert input to camelCase.

    to_kebab

    fn to_kebab(input : String) -> String

    Convert input to kebab-case.

    to_pascal

    fn to_pascal(input : String) -> String

    Convert input to PascalCase (for type and variant names).

    to_snake

    fn to_snake(input : String) -> String

    Convert input to snake_case (for function, parameter, and field names).