MCPcopy
hub / github.com/livebud/bud / loadActionResultFields

Method loadActionResultFields

framework/controller/loader.go:418–435  ·  view source on GitHub ↗

Load the inner fields of the result type, if it's a struct

(result *parser.Result, def parser.Declaration)

Source from the content-addressed store, hash-verified

416
417// Load the inner fields of the result type, if it's a struct
418func (l *loader) loadActionResultFields(result *parser.Result, def parser.Declaration) (fields []*ActionResultField) {
419 // Fields should be empty if the definition isn't a struct
420 if def.Kind() != parser.KindStruct {
421 return fields
422 }
423 // Find the struct in the package
424 stct := def.Package().Struct(def.Name())
425 if stct == nil {
426 l.Bail(fmt.Errorf("controller: unable to find struct for %s", result.Type()))
427 }
428 for _, field := range stct.PublicFields() {
429 fields = append(fields, &ActionResultField{
430 Name: field.Name(),
431 Type: field.Type().String(),
432 })
433 }
434 return fields
435}
436
437// TODO: Clean this up, the logic is quite complicated and could be simplified
438// with better methods

Callers 1

loadActionResultMethod · 0.95

Calls 8

BailMethod · 0.80
PublicFieldsMethod · 0.80
KindMethod · 0.65
PackageMethod · 0.65
NameMethod · 0.65
TypeMethod · 0.65
StringMethod · 0.65
StructMethod · 0.45

Tested by

no test coverage detected