Documentation
¶
Overview ¶
Package naming implements the lowered-name scheme: a lowered function keeps its method's own name when that name is unique in the package, falling back to the receiver-prefixed concatenation when it collides — the same discipline enum variant structs use. Visibility never widens: the name is exported iff BOTH the receiver type and the member are.
Index ¶
- func BareName(owner, member string) string
- func FieldName(paramName string, variantExported bool) string
- func FuncName(recvType, method string, shared map[string]int) string
- func MarkerMethodName(enumName string) string
- func PrefixedName(owner, member string) string
- func VariantTypeName(enumName, variantName string, prefixed bool) string
- type Decl
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BareName ¶ added in v0.5.1
BareName is the preferred lowered name: the member's own name, cased so the result is exported iff BOTH owner and member are exported.
(Stack).Map -> Map (stack).Map -> map (Stack).map -> map
func FieldName ¶ added in v0.2.0
FieldName computes the Go struct field name for a constructor parameter: capitalized iff the variant struct itself is exported (lowering never widens or narrows access).
func FuncName ¶
FuncName picks the lowered function name for a method: the bare method name when it is viable (not a keyword) and unshared in the package, the prefixed form otherwise. shared counts bare candidates across the package's lowered methods.
func MarkerMethodName ¶ added in v0.2.0
MarkerMethodName is the sealed interface's marker method: always unexported, tied to the enum name.
func PrefixedName ¶ added in v0.5.1
PrefixedName is the collision fallback: concat(owner, Capitalize(member)), exported iff both are.
(Stack).Map -> StackMap (stack).Map -> stackMap
func VariantTypeName ¶ added in v0.2.0
VariantTypeName computes the lowered struct type name for an enum variant.
- When the variant name is shared by multiple enums in the package (prefixed=true), the name is the concat of enum and variant names (OptionNone / listNone), disambiguating deterministically.
- Otherwise the variant name is used directly, cased by the combined visibility rule: exported iff both the enum and the variant are exported.
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table detects name collisions between generated functions and any other package-scope declaration (authored or generated).
func (*Table) AddAuthored ¶
AddAuthored records an existing package-scope identifier, e.g. AddAuthored("StackMap", "util.go:14:1"). Authored identifiers never collide with each other (go/types owns that); they only reserve names.
func (*Table) AddGenerated ¶
AddGenerated records a generated function name, returning an error if the name is already taken by an authored declaration or another generated function. origin describes the method, e.g. `method (Stack[T]) Map[U] at stack.gpp:5:1`.