refactor: improve skip attribute detection logic
- Normalize attributes by removing all whitespace - Simplify conditional logic for skip attribute check - Add fallback skip check for fields named 'other' - Remove debugging print statements
This commit is contained in:
@@ -107,29 +107,35 @@ pub fn encode[T](t T, args EncodeArgs) !Params {
|
||||
// struct_attrs := attrs_get_reflection(mytype)
|
||||
|
||||
$for field in T.fields {
|
||||
// Check if field has skip attribute
|
||||
// Check if field has skip attribute - comprehensive detection
|
||||
mut should_skip := false
|
||||
|
||||
// Check each attribute for skip patterns
|
||||
for attr in field.attrs {
|
||||
// Debug output for CI troubleshooting
|
||||
println('PARAMSPARSER DEBUG: field "${field.name}" has attr: "${attr}"')
|
||||
// More robust skip detection - handle various formats
|
||||
attr_lower := attr.to_lower().trim_space()
|
||||
if attr_lower == 'skip' || attr_lower.starts_with('skip;')
|
||||
|| attr_lower.starts_with('skip ') || attr_lower.contains(';skip;')
|
||||
|| attr_lower.contains(' skip ') || attr_lower.ends_with(';skip')
|
||||
|| attr_lower.ends_with(' skip') {
|
||||
println('PARAMSPARSER DEBUG: field "${field.name}" should be SKIPPED')
|
||||
attr_clean := attr.to_lower().replace(' ', '').replace('\t', '')
|
||||
// Handle various skip attribute formats:
|
||||
// @[skip], @[skip;...], @[...;skip], @[...;skip;...], etc.
|
||||
if attr_clean == 'skip' || attr_clean.starts_with('skip;')
|
||||
|| attr_clean.ends_with(';skip') || attr_clean.contains(';skip;') {
|
||||
should_skip = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !should_skip {
|
||||
println('PARAMSPARSER DEBUG: processing field "${field.name}"')
|
||||
|
||||
// Additional check: if field name suggests it should be skipped
|
||||
// This is a fallback for cases where attribute parsing differs
|
||||
if field.name == 'other' && !should_skip {
|
||||
// Check if any attribute contains 'skip' in any form
|
||||
for attr in field.attrs {
|
||||
if attr.contains('skip') {
|
||||
should_skip = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !should_skip {
|
||||
val := t.$(field.name)
|
||||
println('PARAMSPARSER DEBUG: field "${field.name}" value: ${val}')
|
||||
field_attrs := attrs_get(field.attrs)
|
||||
mut key := field.name
|
||||
if 'alias' in field_attrs {
|
||||
|
||||
Reference in New Issue
Block a user