MCPcopy
hub / github.com/sqldef/sqldef / parseEnumValuesWithRename

Function parseEnumValuesWithRename

schema/parser.go:1168–1184  ·  view source on GitHub ↗

parseEnumValuesWithRename parses enum values from DDL and extracts @renamed annotations. It looks for patterns like: 'value' /* @renamed from=old_value */ or 'value' -- @renamed from=old_value

(ddl string, rawValues []string, mode GeneratorMode)

Source from the content-addressed store, hash-verified

1166// parseEnumValuesWithRename parses enum values from DDL and extracts @renamed annotations.
1167// It looks for patterns like: 'value' /* @renamed from=old_value */ or 'value' -- @renamed from=old_value
1168func parseEnumValuesWithRename(ddl string, rawValues []string, mode GeneratorMode) []EnumValue {
1169 result := make([]EnumValue, len(rawValues))
1170 for i, value := range rawValues {
1171 result[i] = EnumValue{value: value}
1172 }
1173
1174 // Extract comments using tokenizer-based approach
1175 valueComments := extractEnumValueComments(ddl, mode)
1176
1177 // Match comments to enum values
1178 for i, value := range rawValues {
1179 if comment, exists := valueComments[value]; exists {
1180 result[i].renamedFrom = extractRenameFrom(comment)
1181 }
1182 }
1183 return result
1184}
1185
1186// extractEnumValueComments extracts inline comments from a CREATE TYPE ... AS ENUM statement
1187// and maps them to enum values

Callers 1

parseDDLFunction · 0.85

Calls 2

extractEnumValueCommentsFunction · 0.85
extractRenameFromFunction · 0.85

Tested by

no test coverage detected