MCPcopy Create free account
hub / github.com/nsf/gocode / strip_method_receiver

Function strip_method_receiver

package_text.go:596–627  ·  view source on GitHub ↗
(recv *ast.FieldList)

Source from the content-addressed store, hash-verified

594}
595
596func strip_method_receiver(recv *ast.FieldList) string {
597 var sel *ast.SelectorExpr
598
599 // find selector expression
600 typ := recv.List[0].Type
601 switch t := typ.(type) {
602 case *ast.StarExpr:
603 sel, _ = t.X.(*ast.SelectorExpr)
604 case *ast.SelectorExpr:
605 sel = t
606 }
607
608 // extract package path
609 if sel != nil {
610 pkg := sel.X.(*ast.Ident).Name
611
612 // write back stripped type
613 switch typ.(type) {
614 case *ast.StarExpr:
615 *recv = ast.FieldList{
616 List: []*ast.Field{{Names: recv.List[0].Names, Type: &ast.StarExpr{X: sel.Sel}}},
617 }
618 case *ast.SelectorExpr:
619 *recv = ast.FieldList{
620 List: []*ast.Field{{Names: recv.List[0].Names, Type: sel.Sel}},
621 }
622 }
623 return pkg
624 } else {
625 return ""
626 }
627}
628
629// MethodDecl = "func" Receiver Name Signature .
630// Receiver = "(" ( identifier | "?" ) [ "*" ] ExportedName ")" [ FuncBody ] .

Callers 3

parse_method_declMethod · 0.85
objMethod · 0.85
typMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected