Documentation
¶
Overview ¶
Package unionnames allocates Go members for generated union carriers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Resolve ¶
Resolve allocates members keyed by original branch name. Ordinary names stay unchanged. Sanitized collisions receive numeric suffixes in logical-name order, independent of branch order. Storage allocation reserves every method and every original field candidate before adding suffixes, so a renamed field cannot steal another branch's name. JSON-only and form carriers share names.
Types ¶
type BranchSymbols ¶
type BranchSymbols struct {
// KindConst identifies this branch in the union's discriminator type.
KindConst string
// Constructor builds a union value with this branch selected.
Constructor string
}
BranchSymbols identifies a branch's declarations in its enclosing package.
func BranchDeclarations ¶
func BranchDeclarations(primary, method string) BranchSymbols
BranchDeclarations derives a branch's package identifiers from an allocated union name and the accessor suffix returned by Resolve. Emitters that already hold resolved member data use this same policy as the full family inventory.
type Member ¶
type Member struct {
// Method is the suffix of the constructor, As and Set methods and kind constant.
Method string
// Field is the storage field, distinct from every generated method and sibling.
Field string
}
Member separates a branch's public accessor suffix from its storage field.
type PackageSymbols ¶
type PackageSymbols struct {
// KindName is the named type of the union discriminator constants.
KindName string
// Branches maps authored branch names to their package declarations.
Branches map[string]BranchSymbols
// Names lists every companion declaration, excluding the primary union type.
// Order follows the authored branches; names use the resolved member identity.
Names []string
}
PackageSymbols identifies the package declarations accompanying one union. Its primary type is named by the caller's owning NameScope.
func PackageDeclarations ¶
func PackageDeclarations(union *expr.Union, primary string) PackageSymbols
PackageDeclarations derives a union's complete common package declaration inventory from its allocated primary name. Allocation, emitters and value construction consume this same policy, including sanitized member names. Owner-specific declarations, such as native Any aliases, are added by the domain that emits them before it allocates the complete family.