Skip to content

Commit 91c2dac

Browse files
committed
Remove commented-out code.
1 parent b53f406 commit 91c2dac

File tree

1 file changed

+0
-76
lines changed

1 file changed

+0
-76
lines changed

internal/framework/flex/autoflex.go

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -156,82 +156,6 @@ func (fff *fuzzyFieldFinder) findField(ctx context.Context, fieldNameFrom string
156156
return reflect.StructField{}, false
157157
}
158158

159-
// func findFieldFuzzy(ctx context.Context, fieldNameFrom string, typeFrom reflect.Type, typeTo reflect.Type, flexer autoFlexer) (reflect.StructField, bool) {
160-
// // first precedence is exact match (case sensitive)
161-
// if fieldTo, ok := typeTo.FieldByName(fieldNameFrom); ok {
162-
// return fieldTo, true
163-
// }
164-
165-
// // If a "from" field fuzzy matches a "to" field, we are certain the fuzzy match
166-
// // is NOT correct if "from" also contains a field by the fuzzy matched name.
167-
// // For example, if "from" has "Value" and "Values", "Values" should *never*
168-
// // fuzzy match "Value" in "to" since "from" also has "Value". We check "from"
169-
// // to make sure fuzzy matches are not in "from".
170-
171-
// // second precedence is exact match (case insensitive)
172-
// opts := flexer.getOptions()
173-
// for field := range tfreflect.ExportedStructFields(typeTo) {
174-
// fieldNameTo := field.Name
175-
// if opts.isIgnoredField(fieldNameTo) {
176-
// continue
177-
// }
178-
// if fieldTo, ok := typeTo.FieldByName(fieldNameTo); ok && strings.EqualFold(fieldNameFrom, fieldNameTo) && !fieldExistsInStruct(fieldNameTo, typeFrom) {
179-
// // probably could assume validity here since reflect gave the field name
180-
// return fieldTo, true
181-
// }
182-
// }
183-
184-
// // third precedence is singular/plural
185-
// fieldNameTo := plural.Plural(fieldNameFrom)
186-
// if plural.IsSingular(fieldNameFrom) && !fieldExistsInStruct(fieldNameTo, typeFrom) {
187-
// if fieldTo, ok := typeTo.FieldByName(fieldNameTo); ok {
188-
// return fieldTo, true
189-
// }
190-
// }
191-
192-
// fieldNameTo = plural.Singular(fieldNameFrom)
193-
// if plural.IsPlural(fieldNameFrom) && !fieldExistsInStruct(fieldNameTo, typeFrom) {
194-
// if fieldTo, ok := typeTo.FieldByName(fieldNameTo); ok {
195-
// return fieldTo, true
196-
// }
197-
// }
198-
199-
// // fourth precedence is using field name prefix
200-
// if v := opts.fieldNamePrefix; v != "" {
201-
// v = strings.ReplaceAll(v, " ", "")
202-
// if ctx.Value(fieldNamePrefixRecurse) == nil {
203-
// // so it will only recurse once
204-
// ctxP := context.WithValue(ctx, fieldNamePrefixRecurse, true)
205-
// if trimmed, ok := strings.CutPrefix(fieldNameFrom, v); ok {
206-
// if f, ok2 := findFieldFuzzy(ctxP, trimmed, typeFrom, typeTo, flexer); ok2 {
207-
// return f, true
208-
// }
209-
// } else {
210-
// if f, ok2 := findFieldFuzzy(ctxP, v+fieldNameFrom, typeFrom, typeTo, flexer); ok2 {
211-
// return f, true
212-
// }
213-
// }
214-
// // no match via prefix mutation; fall through to suffix handling on the original name
215-
// }
216-
// }
217-
218-
// // fifth precedence is using field name suffix
219-
// if v := opts.fieldNameSuffix; v != "" {
220-
// v = strings.ReplaceAll(v, " ", "")
221-
// if ctx.Value(fieldNameSuffixRecurse) == nil {
222-
// // so it will only recurse once
223-
// ctx = context.WithValue(ctx, fieldNameSuffixRecurse, true)
224-
// if strings.HasSuffix(fieldNameFrom, v) {
225-
// return findFieldFuzzy(ctx, strings.TrimSuffix(fieldNameFrom, v), typeFrom, typeTo, flexer)
226-
// }
227-
// return findFieldFuzzy(ctx, fieldNameFrom+v, typeFrom, typeTo, flexer)
228-
// }
229-
// }
230-
231-
// // no finds, fuzzy or otherwise - return zero value
232-
// return reflect.StructField{}, false
233-
// }
234-
235159
func fieldExistsInStruct(field string, structType reflect.Type) bool {
236160
_, ok := structType.FieldByName(field)
237161
return ok

0 commit comments

Comments
 (0)