parseEnumsWithValues method
Parses enums with their values
Implementation
Map<String, String> parseEnumsWithValues(String content) {
final enumsWithValues = <String, String>{};
final enumRegex = RegExp(
r'enum\s+(\w+)\s*\{([^}]+)\}',
multiLine: true,
dotAll: true,
);
final matches = enumRegex.allMatches(content);
for (final match in matches) {
final enumName = match.group(1)!;
final enumBody = match.group(2)!;
// Extract first value
final values = enumBody
.split(',')
.map((e) => e.trim())
.where((e) => e.isNotEmpty && !e.startsWith('//'))
.toList();
if (values.isNotEmpty) {
final firstValue = values.first.split('//')[0].trim();
enumsWithValues[enumName] = firstValue;
}
}
return enumsWithValues;
}