MCPcopy Index your code
hub / github.com/google/go-github / nodeServiceMethod

Function nodeServiceMethod

tools/metadata/metadata.go:514–544  ·  view source on GitHub ↗

nodeServiceMethod returns the name of the service method represented by fn, or "" if fn is not a service method. Name is in the form of "Receiver.Function", for example "IssuesService.Create".

(fn *ast.FuncDecl)

Source from the content-addressed store, hash-verified

512// nodeServiceMethod returns the name of the service method represented by fn, or "" if fn is not a service method.
513// Name is in the form of "Receiver.Function", for example "IssuesService.Create".
514func nodeServiceMethod(fn *ast.FuncDecl) string {
515 if fn.Recv == nil || len(fn.Recv.List) != 1 {
516 return ""
517 }
518 recv := fn.Recv.List[0]
519 se, ok := recv.Type.(*ast.StarExpr)
520 if !ok {
521 return ""
522 }
523 id, ok := se.X.(*ast.Ident)
524 if !ok {
525 return ""
526 }
527
528 // We only want exported methods on exported types where the type name ends in "Service".
529 if !id.IsExported() || !fn.Name.IsExported() || !strings.HasSuffix(id.Name, "Service") {
530 return ""
531 }
532
533 // Skip generated Iterator methods.
534 if strings.HasSuffix(fn.Name.Name, "Iter") {
535 return ""
536 }
537
538 serviceMethod := id.Name + "." + fn.Name.Name
539 if skipServiceMethod[serviceMethod] {
540 return ""
541 }
542
543 return serviceMethod
544}
545
546// See: https://github.com/google/go-github/issues/3894
547var skipServiceMethod = map[string]bool{

Callers 1

visitFileMethodsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…