MCPcopy
hub / github.com/MadAppGang/dingo / getPatternCaseKey

Method getPatternCaseKey

pkg/codegen/match.go:233–244  ·  view source on GitHub ↗

getPatternCaseKey returns the case key for a pattern. Constructor patterns return their full type name. Wildcard and variable patterns return "default".

(pattern ast.Pattern)

Source from the content-addressed store, hash-verified

231// Constructor patterns return their full type name.
232// Wildcard and variable patterns return "default".
233func (g *MatchCodeGen) getPatternCaseKey(pattern ast.Pattern) string {
234 switch p := pattern.(type) {
235 case *ast.ConstructorPattern:
236 return g.constructorToTypeName(p.Name)
237 case *ast.LiteralPattern:
238 return "literal:" + p.Value
239 case *ast.WildcardPattern, *ast.VariablePattern:
240 return "default"
241 default:
242 return "default"
243 }
244}
245
246// generateGroupedCase generates a single case clause for a group of arms.
247// If the group has multiple arms, generates if/else chain for guards.

Callers 2

generateGroupedCasesMethod · 0.95

Calls 1

constructorToTypeNameMethod · 0.95

Tested by

no test coverage detected