Documentation
¶
Index ¶
Constants ¶
const PackagePathContextKey = ContextKey("packagePath")
PackagePathContextKey is the context key for the package path.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompiledConfig ¶
type CompiledConfig struct {
PackageName string // The name of the package to be generated
Packages []*CompiledPackage
// RulesByPackageAndType stores compiled rules, organized for efficient lookup.
// Outer map key: PackageName (empty string for global/wildcard rules).
// Inner map key: RuleType (e.g., RuleTypeType, RuleTypeFunc).
// Value: A slice of CompiledRenameRule, sorted by Priority.
RulesByPackageAndType map[string]map[RuleType][]CompiledRenameRule
}
CompiledConfig holds all the compiled information needed for generation.
type CompiledPackage ¶
type CompiledPackage struct {
ImportPath string
ImportAlias string
Types interface{} // Types defined in this package
Functions interface{} // Functions defined in this package
Variables interface{} // Variables defined in this package
Constants interface{} // Constants defined in this package
}
CompiledPackage holds the compiled information for a single source package.
type CompiledRenameRule ¶
type CompiledRenameRule struct {
Type string // e.g., "prefix", "suffix", "explicit", "regex"
RuleType RuleType // The category of the rule (const, var, func, type)
OriginalName string // The original name from the config rule (e.g., "*", "Worker")
Value string // For prefix/suffix
From string // For explicit
To string // For explicit
Pattern string // Original regex pattern string
Replace string // Replacement string for regex
CompiledRegex *regexp.Regexp // Pre-compiled regex for "regex" type rules
Priority int // Priority of the rule
IsWildcard bool // Indicates if the rule applies to all packages (wildcard)
}
CompiledRenameRule represents a fully compiled and ready-to-apply renaming rule.
type Context ¶
type Context interface {
WithValue(key, value interface{}) Context
Value(key interface{}) interface{}
Push(nodeType RuleType) Context
CurrentNodeType() RuleType
}
Context defines the interface for passing context across calls. It allows for carrying metadata in a key-value manner and managing a stack of node types.
type ContextInfo ¶
type ContextInfo struct {
NodeType string // e.g., "const", "var", "type", "func"
}
ContextInfo holds information about the current processing context.
type RenameRule ¶
type RenameRule struct {
Type string // e.g., "prefix", "suffix", "explicit", "regex"
RuleType RuleType // The category of the rule (const, var, func, type)
Value string // For prefix/suffix
From string // For explicit
To string // For explicit
Pattern string // For regex
Replace string // For regex
}
RenameRule defines a single renaming rule.
type Replacer ¶
Replacer defines the interface for applying code transformations based on compiled rules. It takes an AST node and returns a potentially modified node.
type RuleType ¶
type RuleType int
RuleType is an enum for different container rule types.