SafeNavCodeGen generates Go code for safe navigation expressions. With context (human-like output): return config?.Database?.Host → if config != nil && config.Database != nil { return config.Database.Host } return nil Without context (IIFE fallback): config?.Database?.Host → func() in
| 39 | // |
| 40 | // This avoids duplicate receiver evaluation and ensures correct type inference. |
| 41 | type SafeNavCodeGen struct { |
| 42 | *BaseGenerator |
| 43 | expr *ast.SafeNavExpr |
| 44 | callExpr *ast.SafeNavCallExpr |
| 45 | Context *GenContext // Optional context for human-like code generation |
| 46 | } |
| 47 | |
| 48 | // NewSafeNavGenerator creates a SafeNavCodeGen for field access (x?.field) |
| 49 | func NewSafeNavGenerator(expr *ast.SafeNavExpr) *SafeNavCodeGen { |
nothing calls this directly
no outgoing calls
no test coverage detected