MCPcopy Index your code
hub / github.com/coder/coder / interfaceMethods

Function interfaceMethods

scripts/dbgen/main.go:501–525  ·  view source on GitHub ↗

interfaceMethods returns all embedded methods of an interface.

(i *dst.InterfaceType)

Source from the content-addressed store, hash-verified

499
500// interfaceMethods returns all embedded methods of an interface.
501func interfaceMethods(i *dst.InterfaceType) []*dst.Field {
502 var allMethods []*dst.Field
503 for _, field := range i.Methods.List {
504 switch fieldType := field.Type.(type) {
505 case *dst.FuncType:
506 allMethods = append(allMethods, field)
507 case *dst.InterfaceType:
508 allMethods = append(allMethods, interfaceMethods(fieldType)...)
509 case *dst.Ident:
510 // Embedded interfaces are Idents -> TypeSpec -> InterfaceType
511 // If the embedded interface is not in the parsed file, then
512 // the Obj will be nil.
513 if fieldType.Obj != nil {
514 objDecl, ok := fieldType.Obj.Decl.(*dst.TypeSpec)
515 if ok {
516 isInterface, ok := objDecl.Type.(*dst.InterfaceType)
517 if ok {
518 allMethods = append(allMethods, interfaceMethods(isInterface)...)
519 }
520 }
521 }
522 }
523 }
524 return allMethods
525}

Callers 1

loadInterfaceFuncsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected